@kobalab/liulian 1.0.2 → 1.1.2
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 +14 -0
- package/README.md +1 -0
- package/css/liulian.css +66 -2
- package/lib/module/core.js +87 -4
- package/lib/resource/folder.js +2 -1
- package/lib/resource/index.js +1 -1
- package/package.json +2 -2
package/ChangeLog.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
### v1.1.2 / 2022-06-29
|
|
2
|
+
|
|
3
|
+
- 脆弱性警告に対処(multer 1.4.2 → 1.4.5-lts.1)
|
|
4
|
+
|
|
5
|
+
### v1.1.1 / 2022-04-21
|
|
6
|
+
|
|
7
|
+
- contents モジュールに目次の範囲と表示方法を変更する機能を追加
|
|
8
|
+
- nav モジュールが参照する目次ページでコメントアウトが使えるよう修正
|
|
9
|
+
- nav モジュールにパラメータが指定されていない場合に異常終了するバグを修正
|
|
10
|
+
|
|
11
|
+
## v1.1.0 / 2022-04-15
|
|
12
|
+
|
|
13
|
+
- #7 nav モジュール(ナビゲーション用のリンクを生成する)を追加
|
|
14
|
+
|
|
1
15
|
### v1.0.2 / 2022-04-11
|
|
2
16
|
|
|
3
17
|
- iPhone で form がリサイズしないよう修正
|
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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
@charset "UTF-8";
|
|
2
2
|
|
|
3
3
|
html {
|
|
4
|
-
margin: 0 10px
|
|
4
|
+
margin: 0 10px;
|
|
5
5
|
}
|
|
6
6
|
body {
|
|
7
7
|
font-family: "Century Gothic", sans-serif;
|
|
8
8
|
font-size: 14px;
|
|
9
9
|
color: #333;
|
|
10
10
|
-webkit-text-size-adjust: 100%;
|
|
11
|
-
margin: 0 auto;
|
|
11
|
+
margin: 0 auto 10px;
|
|
12
12
|
overflow-wrap: break-word;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -55,9 +55,11 @@ h4 {
|
|
|
55
55
|
}
|
|
56
56
|
h5 {
|
|
57
57
|
font-size: 110%;
|
|
58
|
+
margin: 1em auto;
|
|
58
59
|
}
|
|
59
60
|
h6 {
|
|
60
61
|
font-size: 100%;
|
|
62
|
+
margin: 1em auto;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
@media screen and (max-width: 480px) {
|
|
@@ -343,6 +345,68 @@ input[type="submit"] {
|
|
|
343
345
|
color: red;
|
|
344
346
|
}
|
|
345
347
|
|
|
348
|
+
.l-nav {
|
|
349
|
+
margin: 1.5em auto 0.5em;
|
|
350
|
+
}
|
|
351
|
+
.l-nav a {
|
|
352
|
+
text-decoration: none;
|
|
353
|
+
}
|
|
354
|
+
.l-nav::after {
|
|
355
|
+
display: block;
|
|
356
|
+
content: '';
|
|
357
|
+
clear: both;
|
|
358
|
+
}
|
|
359
|
+
.l-nav-prev {
|
|
360
|
+
text-align: left;
|
|
361
|
+
float: left;
|
|
362
|
+
width: 35%;
|
|
363
|
+
}
|
|
364
|
+
.l-nav-prev::before {
|
|
365
|
+
content: '≪ ';
|
|
366
|
+
}
|
|
367
|
+
.l-nav-next {
|
|
368
|
+
text-align: right;
|
|
369
|
+
float: right;
|
|
370
|
+
width: 35%;
|
|
371
|
+
}
|
|
372
|
+
.l-nav-next::after {
|
|
373
|
+
content: ' ≫';
|
|
374
|
+
}
|
|
375
|
+
.l-nav-top {
|
|
376
|
+
text-align: center;
|
|
377
|
+
margin: 0 35%;
|
|
378
|
+
}
|
|
379
|
+
@media screen and (max-width: 480px) {
|
|
380
|
+
.l-nav-prev {
|
|
381
|
+
text-align: left;
|
|
382
|
+
float: none;
|
|
383
|
+
width: auto;
|
|
384
|
+
overflow: hidden;
|
|
385
|
+
white-space: nowrap;
|
|
386
|
+
text-overflow: ellipsis;
|
|
387
|
+
}
|
|
388
|
+
.l-nav-next {
|
|
389
|
+
text-align: left;
|
|
390
|
+
float: none;
|
|
391
|
+
width: auto;
|
|
392
|
+
overflow: hidden;
|
|
393
|
+
white-space: nowrap;
|
|
394
|
+
text-overflow: ellipsis;
|
|
395
|
+
}
|
|
396
|
+
.l-nav-top {
|
|
397
|
+
margin: auto;
|
|
398
|
+
overflow: hidden;
|
|
399
|
+
white-space: nowrap;
|
|
400
|
+
text-overflow: ellipsis;
|
|
401
|
+
}
|
|
402
|
+
.l-nav-next::before {
|
|
403
|
+
content: '≫ ';
|
|
404
|
+
}
|
|
405
|
+
.l-nav-next::after {
|
|
406
|
+
content: none;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
346
410
|
.footnotes {
|
|
347
411
|
font-size: 90%;
|
|
348
412
|
}
|
package/lib/module/core.js
CHANGED
|
@@ -5,6 +5,23 @@
|
|
|
5
5
|
|
|
6
6
|
const { cdata, cref, fixpath } = require('../util/html-escape');
|
|
7
7
|
|
|
8
|
+
function stripComment(text) {
|
|
9
|
+
let rv = '', comment;
|
|
10
|
+
for (let line of text.replace(/\r?\n$/,'').split(/\r?\n/)) {
|
|
11
|
+
if (comment) {
|
|
12
|
+
if (line == '*/') comment = false;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (line.match(/^\/\//)) continue;
|
|
16
|
+
if (line.match(/^\/\*/)) {
|
|
17
|
+
comment = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
rv += line + '\n';
|
|
21
|
+
}
|
|
22
|
+
return rv;
|
|
23
|
+
}
|
|
24
|
+
|
|
8
25
|
module.exports = class Core {
|
|
9
26
|
|
|
10
27
|
constructor(parser) {
|
|
@@ -12,8 +29,9 @@ module.exports = class Core {
|
|
|
12
29
|
this._r = parser._r;
|
|
13
30
|
this._req = parser._r._req;
|
|
14
31
|
this._inline = ['img','color','size','br','clear','class','lang'];
|
|
15
|
-
this._block = ['title','contents','footnote','include','img',
|
|
16
|
-
'class','style','icon','lang','redirect',
|
|
32
|
+
this._block = ['title','contents','nav','footnote','include','img',
|
|
33
|
+
'clear','class','style','icon','lang','redirect',
|
|
34
|
+
'script'];
|
|
17
35
|
this._np = ['style','script'];
|
|
18
36
|
}
|
|
19
37
|
|
|
@@ -24,19 +42,84 @@ module.exports = class Core {
|
|
|
24
42
|
return value;
|
|
25
43
|
}
|
|
26
44
|
|
|
27
|
-
async contents(type, param) {
|
|
45
|
+
async contents(type, param = '') {
|
|
46
|
+
let [ s, e, c ] = param.split(/,\s*/);
|
|
47
|
+
s = s || 1;
|
|
48
|
+
let style;
|
|
49
|
+
if (c && e) {
|
|
50
|
+
c = c.replace(/\\/g,'\\\\');
|
|
51
|
+
style = '.l-contents' + ' li'.repeat(e-s+1)
|
|
52
|
+
+ ' { display: inline-block; }\n'
|
|
53
|
+
+ '.l-contents' + ' li'.repeat(e-s+1) + ' + li:before'
|
|
54
|
+
+ ` { content: ' ${c} '; }\n`;
|
|
55
|
+
}
|
|
56
|
+
s = new RegExp(`^\-{${+s-1}}`);
|
|
57
|
+
e = new RegExp(`^\-{${+e+1}}`);
|
|
28
58
|
const base = this._parser.get('toc').length;
|
|
29
59
|
const value = await this._parser.block();
|
|
30
60
|
this._parser.insertText(
|
|
31
|
-
this._parser.get('toc').slice(base)
|
|
61
|
+
this._parser.get('toc').slice(base)
|
|
62
|
+
.filter(line=>! line.match(e))
|
|
63
|
+
.map(line=>line.replace(s,''))
|
|
64
|
+
.filter(line=>line.match(/^\-/))
|
|
65
|
+
.join('\n'),
|
|
32
66
|
true
|
|
33
67
|
);
|
|
68
|
+
if (style) this._r.style(style);
|
|
34
69
|
return '<div class="l-contents">\n'
|
|
35
70
|
+ (await this._parser.block()).replace(/\n$/,'')
|
|
36
71
|
+ '</div>\n\n'
|
|
37
72
|
+ value;
|
|
38
73
|
}
|
|
39
74
|
|
|
75
|
+
async nav(type, param) {
|
|
76
|
+
const location = async(href)=>{
|
|
77
|
+
try {
|
|
78
|
+
let r = await this._r.openFile(this._req, href);
|
|
79
|
+
r = await r.open();
|
|
80
|
+
return r.location;
|
|
81
|
+
}
|
|
82
|
+
catch(code) { return '' }
|
|
83
|
+
};
|
|
84
|
+
if (! param) return '<div style="color:red">#nav()</div>\n\n';
|
|
85
|
+
const err = `<div style="color:red">#nav(${cdata(param)})</div>\n\n`;
|
|
86
|
+
let [ url, title, top ] = param.split(/,\s*/);
|
|
87
|
+
try {
|
|
88
|
+
let r = await this._r.openFile(this._req, url);
|
|
89
|
+
r = await r.open();
|
|
90
|
+
if (r.type != 'text/x-liulian') return err;
|
|
91
|
+
let toc = stripComment(r.text).match(/\[\[.*?\]\]/g) || [];
|
|
92
|
+
let index = -1;
|
|
93
|
+
for (let i = 0; i < toc.length; i++) {
|
|
94
|
+
let loc = await location(
|
|
95
|
+
toc[i].replace(/^\[\[(.*)\]\]$/, '$1')
|
|
96
|
+
.match(/[^|]*$/)[0]);
|
|
97
|
+
if (loc == this._r.location) index = i;
|
|
98
|
+
}
|
|
99
|
+
if (index < 0) return '';
|
|
100
|
+
let html = '<div class="l-nav">\n'
|
|
101
|
+
if (index > 0) {
|
|
102
|
+
html += '<div class="l-nav-prev">'
|
|
103
|
+
+ this._parser.inline(toc[index - 1])
|
|
104
|
+
+ '</div>\n';
|
|
105
|
+
}
|
|
106
|
+
if (index < toc.length - 1) {
|
|
107
|
+
html += '<div class="l-nav-next">'
|
|
108
|
+
+ this._parser.inline(toc[index + 1])
|
|
109
|
+
+ '</div>\n';
|
|
110
|
+
}
|
|
111
|
+
if (title) {
|
|
112
|
+
html += '<div class="l-nav-top">'
|
|
113
|
+
+ this._parser.inline(`[[${title}|${top||url}]]`)
|
|
114
|
+
+ '</div>\n';
|
|
115
|
+
}
|
|
116
|
+
return html + '</div>\n\n';
|
|
117
|
+
}
|
|
118
|
+
catch(code) {
|
|
119
|
+
return err;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
40
123
|
footnote(type, param) {
|
|
41
124
|
const html = this._parser.footnote();
|
|
42
125
|
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kobalab/liulian",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Node.jsで動作するWebサイト作成ツール",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"markdown-it": "^12.3.2",
|
|
38
38
|
"markdown-it-footnote": "^3.0.3",
|
|
39
39
|
"mime": "^2.4.6",
|
|
40
|
-
"multer": "^1.4.
|
|
40
|
+
"multer": "^1.4.5-lts.1",
|
|
41
41
|
"passport": "^0.4.1",
|
|
42
42
|
"passport-local": "^1.0.0",
|
|
43
43
|
"session-file-store": "^1.4.0",
|