hdoc-tools 0.13.0 → 0.14.1
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/hdoc-build.js +23 -19
- package/hdoc-serve.js +34 -7
- package/package.json +1 -1
- package/ui/index.html +206 -191
- package/ui/js/doc.hornbill.js +229 -315
package/hdoc-build.js
CHANGED
@@ -268,15 +268,17 @@
|
|
268
268
|
else
|
269
269
|
html_txt = `${fm_header_content}\n${doc_header}\n${html_txt}`;
|
270
270
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
271
|
+
if (!inline_content) {
|
272
|
+
index_records.push({
|
273
|
+
relative_path: file_path.relativePath,
|
274
|
+
index_html: hdoc_index.transform_html_for_index(html_txt),
|
275
|
+
metadata: metadata,
|
276
|
+
contributors: contribs,
|
277
|
+
pdf_size: pdf_size,
|
278
|
+
md5: file_path.hash,
|
279
|
+
lastmod: last_commit !== null ? last_commit : file_path.hb_lastmod
|
280
|
+
});
|
281
|
+
}
|
280
282
|
// Save HTML into HTML file
|
281
283
|
try {
|
282
284
|
fs.writeFileSync(file_path.path, html_txt);
|
@@ -508,16 +510,18 @@
|
|
508
510
|
console.log('Error writing:', target_file, '\n', err);
|
509
511
|
}
|
510
512
|
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
513
|
+
if (!inline_content) {
|
514
|
+
const index_details = hdoc_index.transform_html_for_index(html_txt);
|
515
|
+
index_records.push({
|
516
|
+
relative_path: relative_path,
|
517
|
+
index_html: index_details,
|
518
|
+
metadata: metadata,
|
519
|
+
contributors: contribs,
|
520
|
+
pdf_size: pdf_size,
|
521
|
+
md5: file_path.hash,
|
522
|
+
lastmod: last_commit !== null ? last_commit : file_path.hb_lastmod
|
523
|
+
});
|
524
|
+
}
|
521
525
|
|
522
526
|
// Add MD file to delete queue
|
523
527
|
md_files_delete.push(file_path.path)
|
package/hdoc-serve.js
CHANGED
@@ -13,9 +13,10 @@
|
|
13
13
|
let port = 3000;
|
14
14
|
let docId;
|
15
15
|
let hdocbook_config,
|
16
|
-
hdocbook_project
|
16
|
+
hdocbook_project,
|
17
|
+
inline_content = {};
|
17
18
|
|
18
|
-
exports.run = async function (ui_path, source_path
|
19
|
+
exports.run = async function (ui_path, source_path) {
|
19
20
|
|
20
21
|
for (let x = 0; x < process.argv.length; x++) {
|
21
22
|
// First two arguments are command, and script
|
@@ -40,9 +41,6 @@
|
|
40
41
|
return -1;
|
41
42
|
}
|
42
43
|
|
43
|
-
// Get an express server instance
|
44
|
-
var app = express();
|
45
|
-
|
46
44
|
// In the root of the project there is a hdocbook.json file which includes
|
47
45
|
// the id of the hdocbook we are working with
|
48
46
|
const hdocbook_project_config_path = path.join(source_path, 'hdocbook-project.json');
|
@@ -53,6 +51,27 @@
|
|
53
51
|
// Get the ID of the hdocbook we are serving
|
54
52
|
docId = hdocbook_project.docId;
|
55
53
|
|
54
|
+
// Get inline content for nav
|
55
|
+
const inline_path = path.join(source_path, docId, '_inline');
|
56
|
+
let nav_inline = {};
|
57
|
+
if (fs.existsSync(inline_path)) {
|
58
|
+
const inline_files = fs.readdirSync(inline_path);
|
59
|
+
nav_inline = {
|
60
|
+
text: 'Inline Help Items',
|
61
|
+
expand: true,
|
62
|
+
inline: true,
|
63
|
+
items: []
|
64
|
+
};
|
65
|
+
inline_files.forEach(file => {
|
66
|
+
nav_inline.items.push({
|
67
|
+
text: file.replace(path.extname(file), ''),
|
68
|
+
link: `${docId}/_inline/${file.replace(path.extname(file), '')}`
|
69
|
+
});
|
70
|
+
});
|
71
|
+
}
|
72
|
+
// Get an express server instance
|
73
|
+
var app = express();
|
74
|
+
|
56
75
|
// Get the path of the book.json file
|
57
76
|
const hdocbook_path = path.join(source_path, docId, 'hdocbook.json');
|
58
77
|
|
@@ -63,7 +82,8 @@
|
|
63
82
|
let library = {
|
64
83
|
books: [{
|
65
84
|
docId: hdocbook_config.docId,
|
66
|
-
title: hdocbook_config.title
|
85
|
+
title: hdocbook_config.title,
|
86
|
+
nav_inline: nav_inline
|
67
87
|
}]
|
68
88
|
};
|
69
89
|
res.setHeader('Content-Type', 'application/json');
|
@@ -222,7 +242,6 @@
|
|
222
242
|
send_file(req, res, file_path);
|
223
243
|
return true;
|
224
244
|
}
|
225
|
-
|
226
245
|
if (fs.existsSync(file_path.replace('.html', '.md'))) {
|
227
246
|
if (transform_markdown_and_send_html(req, res, file_path.replace('.html', '.md'))) {
|
228
247
|
return;
|
@@ -258,6 +277,14 @@
|
|
258
277
|
res.setHeader('Content-Type', 'text/html');
|
259
278
|
send_content_file(req, res, path.join(file_path + '/index.html'));
|
260
279
|
return;
|
280
|
+
} else if (fs.existsSync(path.join(file_path + '.html'))) {
|
281
|
+
res.setHeader('Content-Type', 'text/html');
|
282
|
+
send_content_file(req, res, path.join(file_path + '.html'));
|
283
|
+
return;
|
284
|
+
} else if (fs.existsSync(path.join(file_path + '.htm'))) {
|
285
|
+
res.setHeader('Content-Type', 'text/html');
|
286
|
+
send_content_file(req, res, path.join(file_path + '.htm'));
|
287
|
+
return;
|
261
288
|
}
|
262
289
|
} else if (fs.existsSync(file_path)) {
|
263
290
|
send_file(req, res, file_path);
|