@kobalab/liulian 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +4 -0
- package/README.md +1 -0
- package/css/liulian.css +62 -0
- package/lib/module/core.js +50 -2
- package/lib/resource/folder.js +2 -1
- package/lib/resource/index.js +1 -1
- package/package.json +1 -1
package/ChangeLog.md
CHANGED
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ $ liulian ~/Documents/LiuLian
|
|
|
33
33
|
- [コンテンツ作成](https://kobalab.net/liulian/man/contents)
|
|
34
34
|
- [LiuLian記法](https://kobalab.net/liulian/man/text-liulian)
|
|
35
35
|
- [モジュール](https://kobalab.net/liulian/man/module)
|
|
36
|
+
- [外部モジュール](https://kobalab.net/liulian/man/modules/)
|
|
36
37
|
- [README と index](https://kobalab.net/liulian/man/readme&index)
|
|
37
38
|
- [HEAD と TAIL](https://kobalab.net/liulian/man/head&tail)
|
|
38
39
|
- [リバースプロキシを使う](https://kobalab.net/liulian/man/proxy-setting)
|
package/css/liulian.css
CHANGED
|
@@ -343,6 +343,68 @@ input[type="submit"] {
|
|
|
343
343
|
color: red;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
.l-nav {
|
|
347
|
+
margin: 1.5em auto 0.5em;
|
|
348
|
+
}
|
|
349
|
+
.l-nav a {
|
|
350
|
+
text-decoration: none;
|
|
351
|
+
}
|
|
352
|
+
.l-nav::after {
|
|
353
|
+
display: block;
|
|
354
|
+
content: '';
|
|
355
|
+
clear: both;
|
|
356
|
+
}
|
|
357
|
+
.l-nav-prev {
|
|
358
|
+
text-align: left;
|
|
359
|
+
float: left;
|
|
360
|
+
width: 35%;
|
|
361
|
+
}
|
|
362
|
+
.l-nav-prev::before {
|
|
363
|
+
content: '≪ ';
|
|
364
|
+
}
|
|
365
|
+
.l-nav-next {
|
|
366
|
+
text-align: right;
|
|
367
|
+
float: right;
|
|
368
|
+
width: 35%;
|
|
369
|
+
}
|
|
370
|
+
.l-nav-next::after {
|
|
371
|
+
content: ' ≫';
|
|
372
|
+
}
|
|
373
|
+
.l-nav-top {
|
|
374
|
+
text-align: center;
|
|
375
|
+
margin: 0 35%;
|
|
376
|
+
}
|
|
377
|
+
@media screen and (max-width: 480px) {
|
|
378
|
+
.l-nav-prev {
|
|
379
|
+
text-align: left;
|
|
380
|
+
float: none;
|
|
381
|
+
width: auto;
|
|
382
|
+
overflow: hidden;
|
|
383
|
+
white-space: nowrap;
|
|
384
|
+
text-overflow: ellipsis;
|
|
385
|
+
}
|
|
386
|
+
.l-nav-next {
|
|
387
|
+
text-align: left;
|
|
388
|
+
float: none;
|
|
389
|
+
width: auto;
|
|
390
|
+
overflow: hidden;
|
|
391
|
+
white-space: nowrap;
|
|
392
|
+
text-overflow: ellipsis;
|
|
393
|
+
}
|
|
394
|
+
.l-nav-top {
|
|
395
|
+
margin: auto;
|
|
396
|
+
overflow: hidden;
|
|
397
|
+
white-space: nowrap;
|
|
398
|
+
text-overflow: ellipsis;
|
|
399
|
+
}
|
|
400
|
+
.l-nav-next::before {
|
|
401
|
+
content: '≫ ';
|
|
402
|
+
}
|
|
403
|
+
.l-nav-next::after {
|
|
404
|
+
content: none;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
346
408
|
.footnotes {
|
|
347
409
|
font-size: 90%;
|
|
348
410
|
}
|
package/lib/module/core.js
CHANGED
|
@@ -12,8 +12,9 @@ module.exports = class Core {
|
|
|
12
12
|
this._r = parser._r;
|
|
13
13
|
this._req = parser._r._req;
|
|
14
14
|
this._inline = ['img','color','size','br','clear','class','lang'];
|
|
15
|
-
this._block = ['title','contents','footnote','include','img',
|
|
16
|
-
'class','style','icon','lang','redirect',
|
|
15
|
+
this._block = ['title','contents','nav','footnote','include','img',
|
|
16
|
+
'clear','class','style','icon','lang','redirect',
|
|
17
|
+
'script'];
|
|
17
18
|
this._np = ['style','script'];
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -37,6 +38,53 @@ module.exports = class Core {
|
|
|
37
38
|
+ value;
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
async nav(type, param) {
|
|
42
|
+
const location = async(href)=>{
|
|
43
|
+
try {
|
|
44
|
+
let r = await this._r.openFile(this._req, href);
|
|
45
|
+
r = await r.open();
|
|
46
|
+
return r.location;
|
|
47
|
+
}
|
|
48
|
+
catch(code) { return '' }
|
|
49
|
+
};
|
|
50
|
+
const err = `<div style="color:red">#nav(${cdata(param)})</div>\n\n`;
|
|
51
|
+
let [ url, title, top ] = param.split(/,\s*/);
|
|
52
|
+
try {
|
|
53
|
+
let r = await this._r.openFile(this._req, url);
|
|
54
|
+
r = await r.open();
|
|
55
|
+
if (r.type != 'text/x-liulian') return err;
|
|
56
|
+
let toc = r.text.match(/\[\[.*?\]\]/g) || [];
|
|
57
|
+
let index = -1;
|
|
58
|
+
for (let i = 0; i < toc.length; i++) {
|
|
59
|
+
let loc = await location(
|
|
60
|
+
toc[i].replace(/^\[\[(.*)\]\]$/, '$1')
|
|
61
|
+
.match(/[^|]*$/)[0]);
|
|
62
|
+
if (loc == this._r.location) index = i;
|
|
63
|
+
}
|
|
64
|
+
if (index < 0) return '';
|
|
65
|
+
let html = '<div class="l-nav">\n'
|
|
66
|
+
if (index > 0) {
|
|
67
|
+
html += '<div class="l-nav-prev">'
|
|
68
|
+
+ this._parser.inline(toc[index - 1])
|
|
69
|
+
+ '</div>\n';
|
|
70
|
+
}
|
|
71
|
+
if (index < toc.length - 1) {
|
|
72
|
+
html += '<div class="l-nav-next">'
|
|
73
|
+
+ this._parser.inline(toc[index + 1])
|
|
74
|
+
+ '</div>\n';
|
|
75
|
+
}
|
|
76
|
+
if (title) {
|
|
77
|
+
html += '<div class="l-nav-top">'
|
|
78
|
+
+ this._parser.inline(`[[${title}|${top||url}]]`)
|
|
79
|
+
+ '</div>\n';
|
|
80
|
+
}
|
|
81
|
+
return html + '</div>\n\n';
|
|
82
|
+
}
|
|
83
|
+
catch(code) {
|
|
84
|
+
return err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
40
88
|
footnote(type, param) {
|
|
41
89
|
const html = this._parser.footnote();
|
|
42
90
|
this._parser.nextNote();
|
package/lib/resource/folder.js
CHANGED
|
@@ -34,7 +34,8 @@ module.exports = class Folder extends File {
|
|
|
34
34
|
this._files = [];
|
|
35
35
|
for (let file of await fs.readdir(this._path)) {
|
|
36
36
|
try {
|
|
37
|
-
let r = await this.openFile(this._req,
|
|
37
|
+
let r = await this.openFile(this._req,
|
|
38
|
+
this._location + file);
|
|
38
39
|
this._files.push(r);
|
|
39
40
|
}
|
|
40
41
|
catch(err) {}
|
package/lib/resource/index.js
CHANGED
|
@@ -18,7 +18,7 @@ async function resource(req, file) {
|
|
|
18
18
|
if (file) {
|
|
19
19
|
if (file.match(/^\/\//)) throw 404;
|
|
20
20
|
if (file.match(/^\//))
|
|
21
|
-
location = file;
|
|
21
|
+
location = decodeURIComponent(file);
|
|
22
22
|
else location = decodeURIComponent(urljoin(req.pathDir, file));
|
|
23
23
|
}
|
|
24
24
|
else location = decodeURIComponent(req.path);
|