/* * さわるなきけん! * DO NOT USE! * */ (function(){ const U = liberator.plugins.libly.$U; let pluginDirPath = liberator.globalVariables.pmwriter_plugin_dir; let outputDir = liberator.globalVariables.pmwriter_output_dir; if (!(pluginDirPath && outputDir)) return; if (!liberator.plugins.pmwriter) liberator.plugins.pmwriter = {}; // make を改造 { let makeLink = liberator.eval('makeLink', liberator.plugins.pluginManager.list); if (!liberator.plugins.pmwriter.makeLink) { liberator.plugins.pmwriter.makeLink = function (str) makeLink(str, true); liberator.eval('makeLink = liberator.plugins.pmwriter.makeLink ', liberator.plugins.pluginManager.list); } //let WikiParser = liberator.eval('WikiParser', liberator.plugins.pluginManager.list); //WikiParser.prototype.inlineParse = function (str) { // function replacer(_, s) // ({ '<': '<', '>': '>', '&': '&' })[s] || // '' + s + ''; // try { // return XMLList(str.replace(/(>|<|&|(?:https?:\/\/|mailto:)\S+)/g, replacer)); // } catch (e) { // return XMLList(str); // } //}; } function action () { const IOService = services.get('io'); const DOCUMENT_TITLE = 'Vimperator Plugins in CodeRepos'; const CodeRepos = 'http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/'; const CodeReposFile = 'http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/'; function Context (file) { this.NAME = file.leafName.replace(/\..*/, '') .replace(/-([a-z])/g, function (m, n1) n1.toUpperCase()); }; let myname = __context__.NAME; let otags = liberator.eval('tags', liberator.plugins.pluginManager.list); let template = liberator.eval('template', liberator.plugins.pluginManager.list); let linkTo; let tags = { __proto__: otags, name: function () {otags.name.apply(otags, arguments)} }; let files = io.readDirectory(pluginDirPath); let indexHtml = <>; let allHtml = <>; files.forEach(function (file) { if (!/\.js$/.test(file.path)) return; if (!/PLUGIN_INFO/.test(io.readFile(file.path))) return; try { let context = new Context(file); let pluginName = file.leafName.replace(/\..*$/, ''); let pluginFilename = file.leafName; if (context.NAME == myname) return; let pluginInfo; let htmlFilename = pluginName + '.html'; context.watch('PLUGIN_INFO', function (n, O, N) { pluginInfo = N; throw 'STOP';}); try { services.get("subscriptLoader").loadSubScript(IOService.newFileURI(file).spec, context); } catch (e) { /* DO NOTHING */ } tags.name = function () {otags.name.apply(otags, arguments)}; let plugin = []; let (info = pluginInfo) { plugin['name'] = pluginName; plugin['info'] = {}; plugin['orgInfo'] = {}; for (let tag in tags){ plugin.orgInfo[tag] = info[tag]; let value = tags[tag](info); if (value && value.toString().length > 0){ plugin.push([tag, value]); plugin.info[tag] = value; } } } let authors; { for each (let a in pluginInfo.author) { let hp = a.@homepage.toString(); let xml = hp ? {a.toString()} : {a.toString()} if (authors) authors += , + xml; else authors = xml; } } // プラグイン毎のドキュメント { let src = pluginInfo.detail.toString(); //let detailBody = liberator.plugins.PMWikiParser(src.split(/\n/)); let detailBody = plugin.info.detail let body =

{plugin.info.name.toString()}

Description
{plugin.info.description || '---'}
Latest version
{plugin.info.version || '???'}
Vimperator version
{(plugin.info.minVersion || '?') + ' - ' + (plugin.info.maxVersion || '?')}
URL
{CodeRepos + pluginFilename}
File URL
{CodeReposFile + pluginFilename}
Author
{authors}
License
{plugin.info.license || '--'}
{detailBody}
; io.writeFile( io.getFile(outputDir + htmlFilename), {plugin.info.name.toString()} {body} .toString() ); allHtml += body; } // index.html { indexHtml += {"\u2606"} {plugin.name} {plugin.info.description} {authors} } } catch (e) { liberator.log({filename: file.path}) liberator.log(e.stack) liberator.log(e) } }); indexHtml = {DOCUMENT_TITLE}

{DOCUMENT_TITLE}

{indexHtml}
Name Description Author
Last updated {new Date().toLocaleFormat('%Y/%m/%d %H:%M:%S')}
; allHtml = All Plugins {allHtml} .toString(); io.writeFile(io.getFile(outputDir + 'index.html'), indexHtml.toString()); io.writeFile(io.getFile(outputDir + 'all.html'), allHtml.toString()); } commands.addUserCommand( ['pmwrite'], 'PMWriter', action, {}, true ); })(); // vim: sw=2 ts=2 et fdm=marker: