diff options
author | anekos | 2009-01-12 15:46:53 +0000 |
---|---|---|
committer | anekos | 2009-01-12 15:46:53 +0000 |
commit | 7fb99742bc7a158525898ee79a3e708ebfd81375 (patch) | |
tree | 299bcb7798222a80cff8f4718d99e242f7721ca3 /PMWriter.js | |
parent | 39b590555ce0aaa110407d189221e1702bed20c2 (diff) | |
download | vimperator-plugins-7fb99742bc7a158525898ee79a3e708ebfd81375.tar.bz2 |
PLUGIN_INFO から html を生成するスクリプト
汚いの仕様です
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@28335 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'PMWriter.js')
-rw-r--r-- | PMWriter.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/PMWriter.js b/PMWriter.js new file mode 100644 index 0000000..99d3d8d --- /dev/null +++ b/PMWriter.js @@ -0,0 +1,90 @@ + +/* + * $B$5$o$k$J$-$1$s!*(B + * DO NOT USE! + * */ + +liberator.plugins.pmwriter = {}; +let pluginDirPath = liberator.globalVariables.pmwriter_plugin_dir; +let outputDir = liberator.globalVariables.pmwriter_output_dir; + +(function(){ + let U = liberator.plugins.libly.$U; + + let myname = __context__.NAME; + + let otags = liberator.eval('tags', liberator.plugins.pluginManager.list); + let template = liberator.eval('template', liberator.plugins.pluginManager.list); + + // makeLink $B$rL5M}LpM}=$@5(B + let makeLink = liberator.eval('makeLink', liberator.plugins.pluginManager.list); + liberator.plugins.pmwriter.makeLink = function (str) makeLink(str, true); + liberator.log(makeLink) + liberator.eval('makeLink = liberator.plugins.pmwriter.makeLink ', liberator.plugins.pluginManager.list); + + let linkTo; + let tags = { + __proto__: otags, + name: function () <a href={linkTo}>{otags.name.apply(otags, arguments)}</a> + }; + + let ioService = services.get("io"); + let files = io.readDirectory(pluginDirPath); + let i = 0; + let xml = <></>; + let xml_index = <></>; + + files.forEach(function (file) { + if (!/\.js$/.test(file.path)) + return; + let src = io.readFile(file.path); + if (!/PLUGIN_INFO/.test(src)) + return; + //if (i++ > 0) return; + + let uri = ioService.newFileURI(file); + + function Context (file) { + this.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase()); + }; + let context = new Context(file); + let PLUGIN_INFO; + let detailFilename = context.NAME + '.html'; + linkTo = detailFilename; + + if (context.NAME == myname) + return; + + context.watch('PLUGIN_INFO', function (n,N,O) { PLUGIN_INFO = O; throw 'STOP'; return O; }); + + try { services.get("subscriptLoader").loadSubScript(uri.spec, context); } catch (e) {} + + let info = PLUGIN_INFO; + tags.name = function () <a href={linkTo}>{otags.name.apply(otags, arguments)}</a>; + + let plugin = [ ]; + plugin['name'] = context.NAME; + 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; + } + } + + xml = template.table(plugin.name, plugin); + io.writeFile(io.getFile(outputDir + detailFilename), xml.toString()); + + let data = plugin.filter(function($_) /name|description|author/.test($_[0])); + xml_index += template.table(plugin.name, data); + }); + + io.writeFile(io.getFile(outputDir + 'index.html'), xml_index.toString()); + +})(); +// vim: sw=2 ts=2 et fdm=marker: + |