/*
* さわるなきけん!
* 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());
};
function fromUTF8Octets(octets){
return decodeURIComponent(octets.replace(/[%\x80-\xFF]/g, function(c){
return '%' + c.charCodeAt(0).toString(16);
}));
}
function concatXML (xmls) {
let result = <>>;
xmls.forEach(function (xml) result += xml);
return result;
}
function langList (info, name) {
let result = <>>;
let i = info.length();
while (i-- > 0) {
if (info[i].@lang.toString()) {
result += <{name} lang={info[i].@lang.toString()}>{fromUTF8Octets(info[i].toString())}{name}>;
} else {
result += <{name}>{fromUTF8Octets(info[i].toString())}{name}>;
}
}
return result;
}
function chooseByLang(info, lang) {
let result;
let i = info.length();
while (i-- > 0) {
let it = info[i];
if (!it.@lang)
result = it;
if (it.@lang.toString() == lang) {
result = it;
break;
}
}
return result;
}
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 = <>>;
let pminfos = [];
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;
}
}
// infoXML
{
pminfos.push(
Name | Description | Author |
---|