akashacms-blog-podcast
Advanced tools
Comparing version 0.6.7 to 0.7.0
124
index.js
@@ -27,20 +27,25 @@ /** | ||
const log = require('debug')('akasha:blog-podcast-plugin'); | ||
const error = require('debug')('akasha:error-blog-podcast-plugin'); | ||
const pluginName = "akashacms-blog-podcast"; | ||
const _plugin_config = Symbol('config'); | ||
const _plugin_options = Symbol('options'); | ||
module.exports = class BlogPodcastPlugin extends akasha.Plugin { | ||
constructor() { super(pluginName); } | ||
configure(config) { | ||
this._config = config; | ||
configure(config, options) { | ||
this[_plugin_config] = config; | ||
this[_plugin_options] = options; | ||
options.config = config; | ||
config.addPartialsDir(path.join(__dirname, 'partials')); | ||
config.addMahabhuta(module.exports.mahabhuta); | ||
config.addMahabhuta(module.exports.mahabhutaArray(options)); | ||
config.pluginData(pluginName).bloglist = []; | ||
} | ||
get config() { return this[_plugin_config]; } | ||
get options() { return this[_plugin_options]; } | ||
addBlogPodcast(config, name, blogPodcast) { | ||
config.pluginData(pluginName).bloglist[name] = blogPodcast; | ||
return config; | ||
this.options.bloglist[name] = blogPodcast; | ||
return this.config; | ||
} | ||
@@ -50,4 +55,4 @@ | ||
// console.log(`isLegitLocalHref ${util.inspect(config.pluginData(pluginName).bloglist)} === ${href}?`); | ||
for (var blogkey in config.pluginData(pluginName).bloglist) { | ||
var blogcfg = config.pluginData(pluginName).bloglist[blogkey]; | ||
for (var blogkey in this.options.bloglist) { | ||
var blogcfg = this.options.bloglist[blogkey]; | ||
// console.log(`isLegitLocalHref ${blogcfg.rssurl} === ${href}?`); | ||
@@ -70,23 +75,30 @@ if (blogcfg.rssurl === href) { | ||
} */ | ||
for (var blogkey in config.pluginData(pluginName).bloglist) { | ||
if (!config.pluginData(pluginName).bloglist.hasOwnProperty(blogkey)) { | ||
const tasks = []; | ||
for (var blogkey in this.options.bloglist) { | ||
if (!this.options.bloglist.hasOwnProperty(blogkey)) { | ||
continue; | ||
} | ||
var blogcfg = config.pluginData(pluginName).bloglist[blogkey]; | ||
var blogcfg = this.options.bloglist[blogkey]; | ||
tasks.push(blogcfg); | ||
} | ||
await Promise.all(tasks.map(async blogcfg => { | ||
// console.log(`blog-podcast blogcfg ${util.inspect(blogcfg)}`); | ||
const taskStart = new Date(); | ||
var documents = await findBlogDocs(config, undefined, blogcfg); | ||
var count = 0; | ||
var documents2 = documents.filter(doc => { | ||
if (typeof maxEntries === "undefined" | ||
|| (typeof maxEntries !== "undefined" && count++ < maxEntries)) { | ||
if (typeof blogcfg.maxEntries === "undefined" | ||
|| (typeof blogcfg.maxEntries !== "undefined" && count++ < blogcfg.maxEntries)) { | ||
return true; | ||
} else return false; | ||
}); | ||
// log('blog-news-river documents2 '+ util.inspect(documents2)); | ||
// console.log('blog-news-river documents2 '+ util.inspect(documents2)); | ||
var rssitems = documents2.map(doc => { | ||
let u = new URL(config.root_url); | ||
u.pathname = doc.renderpath; | ||
return { | ||
title: doc.metadata.title, | ||
description: doc.metadata.teaser ? doc.metadata.teaser : "", | ||
url: config.root_url +'/'+ doc.renderpath, | ||
url: u.toString(), | ||
date: doc.metadata.publicationDate ? doc.metadata.publicationDate : doc.stat.mtime | ||
@@ -122,11 +134,26 @@ }; | ||
let feed_url = new URL(config.root_url); | ||
feed_url.pathname = blogcfg.rssurl; | ||
await akasha.generateRSS(config, blogcfg, { | ||
feed_url: config.renderDestination + blogcfg.rssurl, | ||
feed_url: feed_url.toString(), | ||
pubDate: new Date() | ||
}, | ||
rssitems, blogcfg.rssurl); | ||
} | ||
const taskEnd = new Date(); | ||
console.log(`GENERATED RSS ${feed_url.toString()} rssitems # ${rssitems.length} in ${(taskEnd - taskStart) / 1000}`) | ||
})); | ||
} | ||
} | ||
module.exports.mahabhutaArray = function(options) { | ||
let ret = new mahabhuta.MahafuncArray(pluginName, options); | ||
ret.addMahafunc(new BlogNewsRiverElement()); | ||
ret.addMahafunc(new BlogRSSIconElement()); | ||
ret.addMahafunc(new BlogRSSLinkElement()); | ||
ret.addMahafunc(new BlogNextPrevElement()); | ||
return ret; | ||
}; | ||
/** | ||
@@ -216,4 +243,2 @@ * | ||
module.exports.mahabhuta = new mahabhuta.MahafuncArray("akashacms-blog-podcast", {}); | ||
class BlogNewsRiverElement extends mahabhuta.CustomElement { | ||
@@ -227,3 +252,3 @@ get elementName() { return "blog-news-river"; } | ||
if (!blogtag) {// no blog tag, skip? error? | ||
error("NO BLOG TAG in blog-news-river"+ metadata.document.path); | ||
console.error("NO BLOG TAG in blog-news-river"+ metadata.document.path); | ||
throw new Error("NO BLOG TAG in blog-news-river"+ metadata.document.path); | ||
@@ -234,3 +259,3 @@ } | ||
var blogcfg = metadata.config.pluginData(pluginName).bloglist[blogtag]; | ||
var blogcfg = this.array.options.config.pluginData(pluginName).bloglist[blogtag]; | ||
if (!blogcfg) throw new Error('No blog configuration found for blogtag '+ blogtag); | ||
@@ -258,3 +283,3 @@ | ||
var documents = await findBlogDocs(metadata.config, metadata, _blogcfg); | ||
var documents = await findBlogDocs(this.array.options.config, metadata, _blogcfg); | ||
@@ -272,3 +297,3 @@ // log('blog-news-river documents '+ util.inspect(documents)); | ||
return akasha.partial(metadata.config, template, { | ||
return akasha.partial(this.array.options.config, template, { | ||
documents: documents2, | ||
@@ -289,7 +314,7 @@ feedUrl: _blogcfg.rssurl | ||
if (!blogtag) {// no blog tag, skip? error? | ||
error("NO BLOG TAG in blog-news-index"+ metadata.document.path); | ||
console.error("NO BLOG TAG in blog-news-index"+ metadata.document.path); | ||
throw new Error("NO BLOG TAG in blog-news-index "+ metadata.document.path); | ||
} | ||
var blogcfg = metadata.config.pluginData(pluginName).bloglist[blogtag]; | ||
var blogcfg = this.array.options.bloglist[blogtag]; | ||
if (!blogcfg) throw new Error('No blog configuration found for blogtag '+ blogtag); | ||
@@ -300,7 +325,6 @@ | ||
let indexDocuments = await findBlogIndexes(metadata.config, metadata, blogcfg); | ||
return akasha.partial(metadata.config, template, { indexDocuments }); | ||
let indexDocuments = await findBlogIndexes(this.array.options.config, metadata, blogcfg); | ||
return akasha.partial(this.array.options.config, template, { indexDocuments }); | ||
} | ||
} | ||
module.exports.mahabhuta.addMahafunc(new BlogNewsIndexElement()); | ||
@@ -315,7 +339,8 @@ class BlogRSSIconElement extends mahabhuta.CustomElement { | ||
if (!blogtag) {// no blog tag, skip? error? | ||
error("NO BLOG TAG in blog-rss-icon"+ metadata.document.path); | ||
console.error("NO BLOG TAG in blog-rss-icon"+ metadata.document.path); | ||
throw new Error("NO BLOG TAG in blog-rss-icon"+ metadata.document.path); | ||
} | ||
var title = $element.attr("title"); | ||
var blogcfg = metadata.config.pluginData(pluginName).bloglist[blogtag]; | ||
var blogcfg = this.array.options.bloglist[blogtag]; | ||
if (!blogcfg) throw new Error('No blog configuration found for blogtag '+ blogtag); | ||
@@ -326,3 +351,28 @@ | ||
return akasha.partial(metadata.config, template, { | ||
return akasha.partial(this.array.options.config, template, { | ||
feedUrl: blogcfg.rssurl, | ||
title: title | ||
}); | ||
} | ||
} | ||
class BlogRSSLinkElement extends mahabhuta.CustomElement { | ||
get elementName() { return "blog-rss-link"; } | ||
process($element, metadata, dirty) { | ||
var blogtag = $element.attr("blogtag"); | ||
if (!blogtag) { | ||
blogtag = metadata.blogtag; | ||
} | ||
if (!blogtag) {// no blog tag, skip? error? | ||
console.error("NO BLOG TAG in blog-rss-link"+ metadata.document.path); | ||
throw new Error("NO BLOG TAG in blog-rss-link"+ metadata.document.path); | ||
} | ||
var blogcfg = this.array.options.bloglist[blogtag]; | ||
if (!blogcfg) throw new Error('No blog configuration found for blogtag '+ blogtag); | ||
var template = $element.attr("template"); | ||
if (!template) template = "blog-rss-link.html.ejs"; | ||
return akasha.partial(this.array.options.config, template, { | ||
feedUrl: blogcfg.rssurl | ||
@@ -332,3 +382,2 @@ }); | ||
} | ||
module.exports.mahabhuta.addMahafunc(new BlogRSSIconElement()); | ||
@@ -339,7 +388,7 @@ class BlogNextPrevElement extends mahabhuta.CustomElement { | ||
if (! metadata.blogtag) { return; } | ||
let blogcfg = metadata.config.pluginData(pluginName).bloglist[metadata.blogtag]; | ||
let blogcfg = this.array.options.bloglist[metadata.blogtag]; | ||
if (!blogcfg) throw new Error(`No blog configuration found for blogtag ${metadata.blogtag} in ${metadata.document.path}`); | ||
let docpathNoSlash = metadata.document.path.startsWith('/') ? metadata.document.path.substring(1) : metadata.document.path; | ||
let documents = await findBlogDocs(metadata.config, metadata, blogcfg); | ||
let documents = await findBlogDocs(this.array.options.config, metadata, blogcfg); | ||
@@ -357,3 +406,3 @@ let docIndex = -1; | ||
let nextDoc = docIndex === documents.length - 1 ? documents[0] : documents[docIndex + 1]; | ||
let html = await akasha.partial(metadata.config, 'blog-next-prev.html.ejs', { | ||
let html = await akasha.partial(this.array.options.config, 'blog-next-prev.html.ejs', { | ||
prevDoc, nextDoc | ||
@@ -368,2 +417,1 @@ }); | ||
} | ||
module.exports.mahabhuta.addMahafunc(new BlogNextPrevElement()); |
@@ -14,10 +14,8 @@ { | ||
}, | ||
"version": "0.6.7", | ||
"version": "0.7.0", | ||
"engines": { | ||
"node": ">=8.4" | ||
"node": ">=12.2" | ||
}, | ||
"dependencies": { | ||
"async": "*", | ||
"debug": "^2.2.0" | ||
} | ||
} |
# akashacms-blog-podcast | ||
AkashaCMS plugin for blogging and podcasting | ||
[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/0)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/0)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/1)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/1)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/2)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/2)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/3)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/3)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/4)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/4)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/5)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/5)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/6)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/6)[![](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/images/7)](https://sourcerer.io/fame/robogeek/akashacms/akashacms-blog-podcast/links/7) | ||
See http://akashacms.com/new/plugins/blog-podcast/index.html for documentation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
32902
0
11
347
1
7
- Removedasync@*
- Removeddebug@^2.2.0
- Removedasync@3.2.6(transitive)
- Removeddebug@2.6.9(transitive)
- Removedms@2.0.0(transitive)