1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*
* さわるなきけん!
* DO NOT USE!
* */
(function(){
let pluginDirPath = liberator.globalVariables.pmwriter_plugin_dir;
let outputDir = liberator.globalVariables.pmwriter_output_dir;
if (!(pluginDirPath && outputDir))
return;
let AUTHORS = {
Trapezoid: 'http://unsigned.g.hatena.ne.jp/Trapezoid/',
anekos: 'http://d.hatena.ne.jp/nokturnalmortum/',
"halt feits": 'http://project-p.jp/halt/',
hogelog: 'http://d.hatena.ne.jp/hogelog/',
janus_wel: 'http://d.hatena.ne.jp/janus_wel/',
mattn: 'http://mattn.kaoriya.net',
pekepeke: 'http://d.hatena.ne.jp/pekepekesamurai/',
pekepekesamurai: 'http://d.hatena.ne.jp/pekepekesamurai/',
suVene: 'http://d.zeromemory.info/',
teramako: 'http://d.hatena.ne.jp/teramako/',
};
function action () {
liberator.plugins.pmwriter = {};
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 を無理矢理修正
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_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';
if (context.NAME == myname)
return;
context.watch('PLUGIN_INFO', function (n,N,O) { PLUGIN_INFO = O; throw 'STOP';});
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;
}
}
let xml = <html>
<head>
<title>{detailFilename}</title>
<link rel="stylesheet" href="voqn.css" type="text/css" />
</head>
<body>
{template.table(plugin.name, plugin)}
</body>
</html>;
liberator.log(xml)
io.writeFile(io.getFile(outputDir + detailFilename), xml.toString());
let link = 'http://vimperator.kurinton.net/' + detailFilename;
let alink = AUTHORS[info.author];
let data = plugin.filter(function($_) /name|description|author/.test($_[0]));
xml_index += <tr class="plugin">
<td class="name"><a href={link} class="link">{plugin.name}</a></td>
<td class="description">{plugin.info.description}</td>
<td class="author"><a href={alink}>{info.author}</a></td>
</tr>
//xml_index += template.table(plugin.name, data);
});
let title = "Vimperator Plugins in CodeRepos";
xml_index = <html>
<head>
<title>{title}</title>
<link rel="stylesheet" href="voqn.css" type="text/css" />
<script type="text/javascript" src="http://s.hatena.ne.jp/js/HatenaStar.js"></script>
<script type="text/javascript">
Hatena.Star.Token = '48e8f4c633307a76a4dd923111e22a25e80b6e8a';
</script>
<script type="text/javascript"><![CDATA[
Hatena.Star.SiteConfig = {
entryNodes: {
'tr': {
uri: "a.link",
title: 'td.name',
container: 'td.name'
}
}
};
]]></script>
</head>
<body>
<h1>{title}</h1>
<table>
<tr class="header">
<th class="name">Name</th>
<th class="description">Description</th>
<th class="author">Author</th>
</tr>
{xml_index}
</table>
</body>
</html>;
io.writeFile(io.getFile(outputDir + 'index.html'), xml_index.toString());
}
commands.addUserCommand(
['pmwrite'],
'PMWriter',
action,
{},
true
);
})();
// vim: sw=2 ts=2 et fdm=marker:
|