var PLUGIN_INFO =
{NAME}
Manage Vimperator Plugin
Vimpeatorプラグインの管理
0.1a
;
liberator.plugins.pluginManager = (function(){
var lang = window.navigator.language;
var tags = {
name: function(info) info.name ? fromUTF8Octets(info.name.toString()) : null,
author: function(info) info.author || null,
description: function(info){
if (!info.description) return null;
var desc = "";
var length = info.description.length();
if (length > 1){
desc = info.description[0].toString();
for (let i=0; i>;
var ite = Iterator(lines);
var num, line;
try {
while ([num, line] = ite.next()){
if (!line) continue;
if (/^\s*==(.*)==\s*$/.test(line)){
line = RegExp.$1;
xml += {line}
;
continue;
}
let reg = /^\s*(.*)\s*:\s*$/;
if (reg.test(line)){
let dl = - {RegExp.$1}
;
while ([num, line] = ite.next()){
if (!line) break;
if (reg.test(line)){
dl.* += {RegExp.$1};
} else {
dl.* += {line.replace(/^\s+|\s+$/g, "")};
}
}
xml += dl;
continue;
}
xml += <>{line}
>;
}
} catch (e){}
return xml;
}
};
function fromUTF8Octets(octets){
return decodeURIComponent(octets.replace(/[%\x80-\xFF]/g, function(c){
return "%" + c.charCodeAt(0).toString(16);
}));
}
function getPlugins(){
var list = [];
var contexts = liberator.plugins.contexts;
for (let path in contexts){
let context = contexts[path];
let info = context.PLUGIN_INFO || null;
let plugin = [
["path", path]
];
plugin["name"] = context.NAME;
if (info){
for (let tag in tags){
let value = tags[tag](info);
if (value.toString().length > 0)
plugin.push([tag, value]);
}
}
list.push(plugin);
}
return list;
}
function itemFormater(plugin, showDetail){
if (showDetail)
return template.table(plugin.name, plugin);
var data = plugin.filter(function($_) $_[0] != 'detail');
return template.table(plugin.name, data);
}
commands.addUserCommand(['plugin[help]'], 'list Vimperator plugin ',
function(args){
liberator.plugins.pluginManager.list(args[0], args['-verbose']);
}, {
argCount: "*",
options: [
[['-verbose', '-v'], commands.OPTION_NOARG],
],
completer: function(context){
var all = getPlugins().map(function(plugin){
let desc = '-';
for (let i=0; i= 0);
}
}, true);
var public = {
list: function(name, showDetail){
var xml = <>>;
var plugins = getPlugins();
if (name){
let plugin = plugins.filter(function(plugin) plugin.name == name)[0];
if (plugin){
xml = itemFormater(plugin, showDetail);
}
} else {
plugins.forEach(function(plugin) xml += itemFormater(plugin, showDetail));
}
liberator.echo(xml, true);
}
};
return public;
})();