hdoc-tools 0.7.16 → 0.7.18
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 +1 -3
- package/hdoc-serve.js +10 -26
- package/hdoc-validate.js +3 -1
- package/package.json +1 -1
- package/ui/js/doc.hornbill.js +3 -3
package/hdoc-build.js
CHANGED
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
md_files = [];
|
|
15
15
|
|
|
16
16
|
function expand_variables(text) {
|
|
17
|
-
// For debug mode our base path is our root??
|
|
18
|
-
text = text.replaceAll('{{BASE_PATH}}', '/' + docId);
|
|
19
17
|
text = text.replaceAll('{{BUILD_NUMBER}}', '0');
|
|
20
18
|
|
|
21
19
|
let build_date = new Date().toISOString();
|
|
@@ -70,7 +68,7 @@
|
|
|
70
68
|
// * Create a _work folder
|
|
71
69
|
// * copy the hdocbook content to the work folder
|
|
72
70
|
// * Render all markdown into side-by-side HTML file
|
|
73
|
-
// * Replace SERVER_VARS embedded in documents with the right
|
|
71
|
+
// * Replace SERVER_VARS embedded in documents with the right version information etc.
|
|
74
72
|
// * Build an index (sqlite FTS5) by extracting text from all HTML content in the work
|
|
75
73
|
// folder, conceptually we are making a little mini website crawler to index all of the content
|
|
76
74
|
// within the book.
|
package/hdoc-serve.js
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
var hdocbook_config = require(hdocbook_path);
|
|
54
54
|
var hdocbook_mtime = fs.statSync(hdocbook_path).mtime;
|
|
55
55
|
|
|
56
|
-
app.get('/
|
|
56
|
+
app.get('/_books/library.json', function (req, res) {
|
|
57
57
|
let library = {
|
|
58
58
|
books: [{
|
|
59
59
|
docId: hdocbook_config.docId,
|
|
@@ -112,7 +112,6 @@
|
|
|
112
112
|
|
|
113
113
|
function expand_variables(text) {
|
|
114
114
|
// For debug mode our base path is our root??
|
|
115
|
-
text = text.replaceAll('{{BASE_PATH}}', '/' + docId);
|
|
116
115
|
text = text.replaceAll('{{DOC_ID}}', docId);
|
|
117
116
|
text = text.replaceAll('{{BUILD_NUMBER}}', '0');
|
|
118
117
|
|
|
@@ -213,13 +212,12 @@
|
|
|
213
212
|
//
|
|
214
213
|
// Anything else in this handler will return a 404 error
|
|
215
214
|
|
|
216
|
-
app.get('/
|
|
215
|
+
app.get('/_books/*', function (req, res) {
|
|
217
216
|
|
|
218
217
|
let url = req.url;
|
|
219
218
|
|
|
220
219
|
let segs = url.split('/');
|
|
221
|
-
|
|
222
|
-
if (segs.length == 4 && segs[1] == 'content' && segs[3] == 'book.json') {
|
|
220
|
+
if (segs.length == 4 && segs[1] == '_books' && segs[3] == 'book.json') {
|
|
223
221
|
// Special case of a virtual file here, we need to check the book ID and
|
|
224
222
|
// if its our book, send the json
|
|
225
223
|
if (hdocbook_config.docId == segs[2]) {
|
|
@@ -231,7 +229,7 @@
|
|
|
231
229
|
res.status(404).send('Specified bookId ' + segs[2] + ' not found');
|
|
232
230
|
}
|
|
233
231
|
return;
|
|
234
|
-
} else if (segs.length == 3 && segs[1] == '
|
|
232
|
+
} else if (segs.length == 3 && segs[1] == '_books' && segs[2] == 'index.json') {
|
|
235
233
|
// For development mode, we always have an index with one book in it, the one being developed
|
|
236
234
|
if (hdocbook_config) {
|
|
237
235
|
let index = {
|
|
@@ -252,8 +250,11 @@
|
|
|
252
250
|
return;
|
|
253
251
|
}
|
|
254
252
|
|
|
255
|
-
url =
|
|
256
|
-
|
|
253
|
+
url = '';
|
|
254
|
+
segs.forEach(function(urlSeg){
|
|
255
|
+
if (urlSeg !== '' && urlSeg !== '_books') url += '/' + urlSeg;
|
|
256
|
+
});
|
|
257
|
+
|
|
257
258
|
console.log('URL Requested:', url);
|
|
258
259
|
|
|
259
260
|
let file_path = path.join(source_path, url);
|
|
@@ -331,23 +332,6 @@
|
|
|
331
332
|
app.get('/*', function (req, res) {
|
|
332
333
|
|
|
333
334
|
let segs = req.url.split('/');
|
|
334
|
-
if (segs.length > 2 && segs[1] === docId) {
|
|
335
|
-
// In this case we are looking for static content within the book
|
|
336
|
-
// Create the file path
|
|
337
|
-
let url = req.url.replace('/content/', '/');
|
|
338
|
-
console.log('URL Requested:', url);
|
|
339
|
-
let file_path = path.join(source_path, url);
|
|
340
|
-
|
|
341
|
-
// If the file exists, send it.
|
|
342
|
-
if (fs.existsSync(file_path) == true) {
|
|
343
|
-
send_file(req, res, file_path);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// All else fails, we have not file to return, so return a 404 error here
|
|
348
|
-
send_content_resource_404(req, res);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
335
|
|
|
352
336
|
let ui_file_path = path.join(ui_path, req.url);
|
|
353
337
|
|
|
@@ -375,7 +359,7 @@
|
|
|
375
359
|
console.log('Server listening at http://127.0.0.1:%s', port);
|
|
376
360
|
console.log('Document source path is: ' + source_path);
|
|
377
361
|
|
|
378
|
-
let _vars = ['{{DOC_ID}}', '{{
|
|
362
|
+
let _vars = ['{{DOC_ID}}', '{{BUILD_NUMBER}}', '{{BUILD_DATE}}'];
|
|
379
363
|
console.log("Server Vars:");
|
|
380
364
|
for(let x = 0; x < _vars.length; x++) {
|
|
381
365
|
let name = _vars[x];
|
package/hdoc-validate.js
CHANGED
|
@@ -63,6 +63,8 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
|
|
|
63
63
|
// Remove explicit anchor links
|
|
64
64
|
let file_path = path.join(source_path, relative_path.split('#')[0]);
|
|
65
65
|
|
|
66
|
+
// Replace /_books/ with /
|
|
67
|
+
file_path = file_path.replace(path.sep + '_books' + path.sep, path.sep);
|
|
66
68
|
if (!fs.existsSync(file_path) && !fs.existsSync(file_path + '.htm') && !fs.existsSync(file_path + '.html')) {
|
|
67
69
|
errors[html_path.relativePath].push(`Book resource does not exist: ${file_path}`);
|
|
68
70
|
return false;
|
|
@@ -118,7 +120,7 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
|
|
|
118
120
|
// Write list
|
|
119
121
|
const listFile = path.join(source_path, doc_id, 'list.txt');
|
|
120
122
|
fs.writeFileSync(listFile, listContent);
|
|
121
|
-
console.log(
|
|
123
|
+
console.log(`\r\nLink list text file created successfully: ${listFile}`);
|
|
122
124
|
} catch (err) {
|
|
123
125
|
console.error(err);
|
|
124
126
|
}
|
package/package.json
CHANGED
package/ui/js/doc.hornbill.js
CHANGED
|
@@ -233,7 +233,7 @@ function loadContentUrl(linkRef,fromPageRefresh,fromPopState)
|
|
|
233
233
|
|
|
234
234
|
//-- for now just load whatever the href prop is (we can add actions to perform specific processing and then load content based on element atts etc)
|
|
235
235
|
let frontmatterData = {};
|
|
236
|
-
fetch("
|
|
236
|
+
fetch("_books/"+linkRef).then(response =>
|
|
237
237
|
{
|
|
238
238
|
if(response.headers.has("X-frontmatter"))
|
|
239
239
|
{
|
|
@@ -474,7 +474,7 @@ async function intialiseApp() {
|
|
|
474
474
|
jqContentContainer = $(".injected-document-content");
|
|
475
475
|
jqLeftNav = $("#DocSidebarNav");
|
|
476
476
|
|
|
477
|
-
await fetchJsonFile("
|
|
477
|
+
await fetchJsonFile("_books/library.json").then(function(data){
|
|
478
478
|
|
|
479
479
|
// Get docbook library list
|
|
480
480
|
view.docApp.library = data;
|
|
@@ -482,7 +482,7 @@ async function intialiseApp() {
|
|
|
482
482
|
|
|
483
483
|
}).then(function(){
|
|
484
484
|
// Get hdocbook.json
|
|
485
|
-
fetchJsonFile("
|
|
485
|
+
fetchJsonFile("_books/" + view.docId + "/hdocbook.json").then(function(data)
|
|
486
486
|
{
|
|
487
487
|
view.docApp.book = data;
|
|
488
488
|
view.bookId = data.docId;
|