From 2c6f1c899cb2ce2e47a0f74f2164e2a2947c8c5b Mon Sep 17 00:00:00 2001 From: anekos Date: Sun, 8 Feb 2009 12:02:03 +0000 Subject: 出力 HTML を改良 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29707 d0d07461-0603-4401-acd4-de1884942a52 --- PMWriter.js | 216 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 113 insertions(+), 103 deletions(-) (limited to 'PMWriter.js') diff --git a/PMWriter.js b/PMWriter.js index 73d1d6a..6ff69c3 100644 --- a/PMWriter.js +++ b/PMWriter.js @@ -26,17 +26,17 @@ 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); - } - }; + //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 () { @@ -44,6 +44,7 @@ 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(/\..*/, '') @@ -72,112 +73,121 @@ if (!/PLUGIN_INFO/.test(io.readFile(file.path))) return; - let context = new Context(file); - let pluginName = file.leafName.replace(/\..*$/, ''); - let pluginFilename = file.leafName; + try { + let context = new Context(file); + let pluginName = file.leafName.replace(/\..*$/, ''); + let pluginFilename = file.leafName; - if (context.NAME == myname) - return; + if (context.NAME == myname) + return; - let pluginInfo; - let htmlFilename = pluginName + '.html'; + let pluginInfo; + let htmlFilename = pluginName + '.html'; - context.watch('PLUGIN_INFO', function (n, O, N) { pluginInfo = N; throw 'STOP';}); + 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 */ - } + try { + services.get("subscriptLoader").loadSubScript(IOService.newFileURI(file).spec, context); + } catch (e) { + /* DO NOTHING */ + } - tags.name = function () {otags.name.apply(otags, arguments)}; + tags.name = function () {otags.name.apply(otags, arguments)}; - let plugin = []; - let (info = pluginInfo) { - plugin['name'] = pluginName; - plugin['info'] = {}; - plugin['orgInfo'] = {}; + 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; + 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 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 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
-
{plugin.info.updateURL || '--'}
-
Author
-
{authors}
-
License
-
{plugin.info.license || '--'}
-
+ // プラグイン毎のドキュメント + { + 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 || '--'}
+
+
-
-
{plugin.info.detail}
-
; - - io.writeFile( - io.getFile(outputDir + htmlFilename), - - - {plugin.info.name.toString()} - - - - - {body} - - .toString() - ); - allHtml += body; - } +
{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} - - + // index.html + { + indexHtml += + + {"\u2606"} + {plugin.name} + + + {plugin.info.description} + + + {authors} + + + } + } catch (e) { + liberator.log({filename: file.path}) + liberator.log(e.stack) + liberator.log(e) } }); -- cgit v1.2.3