hdoc-tools 0.15.1 → 0.15.3
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 +31 -17
- package/hdoc-serve.js +3 -2
- package/package.json +1 -1
- package/ui/index.html +48 -6
- package/ui/js/doc.hornbill.js +83 -28
package/hdoc-build.js
CHANGED
@@ -24,7 +24,8 @@
|
|
24
24
|
non_git_pdf_header_template_path = path.join(__dirname, 'templates', 'pdf-header-non-git.html'),
|
25
25
|
pdf_template_path = path.join(__dirname, 'templates', 'pdf'),
|
26
26
|
pdf_template_file_path = path.join(pdf_template_path, 'template.html'),
|
27
|
-
regex_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,6}
|
27
|
+
regex_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,6}$/,
|
28
|
+
h1_pattern = /(<h1.*?>)\s*.*\s*(.*<\/h1>)/;
|
28
29
|
|
29
30
|
let bc = {}, // Breadcrumbs map
|
30
31
|
built_file_hashes = [],
|
@@ -126,7 +127,7 @@
|
|
126
127
|
}
|
127
128
|
}
|
128
129
|
|
129
|
-
if (!fm_title_found) {
|
130
|
+
if (!fm_title_found && file_path.name !== 'description_ext.md' && file_path.name !== 'article_ext.md') {
|
130
131
|
// No frontmatter title found in properties
|
131
132
|
// Go get title from h tags in html
|
132
133
|
const html_heading = hdoc.getFirstHTMLHeading(html_txt, h_tags_to_search);
|
@@ -153,7 +154,7 @@
|
|
153
154
|
id: 'title',
|
154
155
|
value: html_heading[0].children[0].data
|
155
156
|
});
|
156
|
-
} else {
|
157
|
+
} else if (file_path.name !== 'description_ext.md' && file_path.name !== 'article_ext.md') {
|
157
158
|
// No header tag, no frontmatter title, output a warning
|
158
159
|
console.log(`[WARNING] No frontmatter title property, or ${h_tags_to_search.join(', ')} tags detected in ${file_path.path}`);
|
159
160
|
}
|
@@ -176,7 +177,11 @@
|
|
176
177
|
let metadata = {};
|
177
178
|
|
178
179
|
// Remove the first <h1>title</h1> from the HTML as we'll add that in the document header
|
179
|
-
|
180
|
+
let html_h1 = h1_pattern.exec(html_txt);
|
181
|
+
if (html_h1 && html_h1[0])
|
182
|
+
html_h1 = html_h1[0].replace(/(<h1.*?>)/, '').replace(/(<\/h1>)/, '');
|
183
|
+
|
184
|
+
html_txt = html_txt.replace(h1_pattern, '');
|
180
185
|
|
181
186
|
// Get contributor data from Github, if exists
|
182
187
|
let contribs = [];
|
@@ -240,16 +245,16 @@
|
|
240
245
|
if (hdocbook_config.publicSource && hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
241
246
|
// Build doc header from template and frontmatter tags
|
242
247
|
if (!inline_content)
|
243
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
|
248
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template, html_h1);
|
244
249
|
|
245
250
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
246
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
|
251
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template, html_h1);
|
247
252
|
} else {
|
248
253
|
if (!inline_content)
|
249
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
|
254
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git, html_h1);
|
250
255
|
|
251
256
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
252
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
|
257
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git, html_h1);
|
253
258
|
}
|
254
259
|
|
255
260
|
let pdf_size = 0;
|
@@ -388,7 +393,7 @@
|
|
388
393
|
value: html_heading[0].children[0].data.trim()
|
389
394
|
});
|
390
395
|
doc_title = html_heading[0].children[0].data.trim();
|
391
|
-
} else {
|
396
|
+
} else if (file_path.name !== 'description_ext.md' && file_path.name !== 'article_ext.md') {
|
392
397
|
// No header tag, no frontmatter title, output a warning
|
393
398
|
console.log(`[WARNING] No frontmatter title property, or h1, h2 or h3 header tags detected in ${file_path.path}`);
|
394
399
|
}
|
@@ -406,7 +411,11 @@
|
|
406
411
|
let metadata = {};
|
407
412
|
|
408
413
|
// Remove the first <h1>title</h1> from the HTML as we'll add that in the document header
|
409
|
-
|
414
|
+
let html_h1 = h1_pattern.exec(html_txt);
|
415
|
+
if (html_h1 && html_h1[0])
|
416
|
+
html_h1 = html_h1[0].replace(/(<h1.*?>)/, '').replace(/(<\/h1>)/, '');
|
417
|
+
|
418
|
+
html_txt = html_txt.replace(h1_pattern, '');
|
410
419
|
|
411
420
|
// Get contributor data from Github, if exists
|
412
421
|
let contribs = [];
|
@@ -472,17 +481,17 @@
|
|
472
481
|
if (hdocbook_config.publicSource && hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
473
482
|
// Build doc header from template and frontmatter tags
|
474
483
|
if (!inline_content)
|
475
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
|
484
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template, html_h1);
|
476
485
|
|
477
486
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
478
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
|
487
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template, html_h1);
|
479
488
|
} else {
|
480
489
|
// Build doc header from template and frontmatter tags
|
481
490
|
if (!inline_content)
|
482
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
|
491
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git, html_h1);
|
483
492
|
|
484
493
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
485
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
|
494
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git, html_h1);
|
486
495
|
}
|
487
496
|
|
488
497
|
let pdf_size = 0;
|
@@ -532,14 +541,19 @@
|
|
532
541
|
return false;
|
533
542
|
};
|
534
543
|
|
535
|
-
const process_doc_header = function (fm_headers, doc_path, template) {
|
544
|
+
const process_doc_header = function (fm_headers, doc_path, template, h1) {
|
536
545
|
let wip_doc_header = template;
|
537
|
-
|
546
|
+
let used_h1 = false;
|
547
|
+
if (h1 && h1 !== '') {
|
548
|
+
wip_doc_header = wip_doc_header.replaceAll('{{title}}', h1);
|
549
|
+
used_h1 = true;
|
550
|
+
}
|
538
551
|
// Process fm_headers properties first
|
539
552
|
for (let i = 0; i < fm_headers.length; i++) {
|
540
553
|
switch (fm_headers[i].id) {
|
541
554
|
case 'title':
|
542
|
-
|
555
|
+
if (!used_h1)
|
556
|
+
wip_doc_header = wip_doc_header.replaceAll('{{title}}', fm_headers[i].value);
|
543
557
|
break;
|
544
558
|
case 'reading-time':
|
545
559
|
wip_doc_header = wip_doc_header.replaceAll('{{reading-time}}', fm_headers[i].value);
|
package/hdoc-serve.js
CHANGED
@@ -223,10 +223,11 @@
|
|
223
223
|
|
224
224
|
// Process redirect
|
225
225
|
if (hdocbook_project.redirects && hdocbook_project.redirects instanceof Array && hdocbook_project.redirects.length > 0) {
|
226
|
-
const source_url = url.indexOf('/') === 0 ? url
|
226
|
+
const source_url = url.indexOf('/') === 0 ? url : `/${url}`;
|
227
227
|
hdocbook_project.redirects.forEach(function (redir) {
|
228
|
+
redir.url = redir.url.indexOf('/') === 0 ? redir.url : `/${redir.url}`
|
228
229
|
if (redir.url === source_url && redir.location && redir.location !== '') {
|
229
|
-
url =
|
230
|
+
url = `${redir.location}`;
|
230
231
|
console.log(`Redirecting to ${url}`);
|
231
232
|
}
|
232
233
|
});
|
package/package.json
CHANGED
package/ui/index.html
CHANGED
@@ -203,8 +203,7 @@
|
|
203
203
|
|
204
204
|
<nav class="hdoc-nav hb-container-expand" id="DocSidebarNav" aria-labelledby="sidebar-aria-label"
|
205
205
|
tabindex="-1">
|
206
|
-
<div v-for="(navSection,index) in docApp.navSections"
|
207
|
-
v-bind:class="{'group':navSection.items, 'nogrouplink':!navSection.items}">
|
206
|
+
<div v-for="(navSection,index) in docApp.navSections" v-bind:class="{'group':navSection.items, 'nogrouplink':!navSection.items}">
|
208
207
|
|
209
208
|
<div v-show="!navSection.items">
|
210
209
|
<a class="DocLink link noitems" v-bind:href="navSection.link"
|
@@ -219,6 +218,17 @@
|
|
219
218
|
v-bind:asection="navSection"></nav-section-component>
|
220
219
|
</div>
|
221
220
|
</div>
|
221
|
+
|
222
|
+
<div v-if="docApp.hasInlinePopupDocuments" class="nogrouplink">
|
223
|
+
<div>
|
224
|
+
<a class="DocLink link noitems" v-on:click="showInlineDocumentList($event)">
|
225
|
+
<span class="link-text">
|
226
|
+
Inline Help Documents
|
227
|
+
</span>
|
228
|
+
</a>
|
229
|
+
</div>
|
230
|
+
</div>
|
231
|
+
|
222
232
|
</nav>
|
223
233
|
|
224
234
|
</aside>
|
@@ -226,7 +236,8 @@
|
|
226
236
|
<!-- the right hand content col -->
|
227
237
|
<div class="DocContent hb-container-expand hb-container-vertical" id="DocContent">
|
228
238
|
<div class="HTL-doc content-wrapper hb-container-expand">
|
229
|
-
|
239
|
+
|
240
|
+
<div v-show="!docApp.showInlineDocumentsMarkup" class="injected-document-container hb-container-horizontal">
|
230
241
|
|
231
242
|
<div class="injected-document-content">
|
232
243
|
<div class="document-header">
|
@@ -286,9 +297,6 @@
|
|
286
297
|
</div>
|
287
298
|
|
288
299
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
300
|
<!-- table of contents -->
|
293
301
|
<div v-if="docApp.keepTocLayout" class="injected-document-toc">
|
294
302
|
<div v-if="docApp.tableOfContents.length" class="panel-header">
|
@@ -307,6 +315,38 @@
|
|
307
315
|
|
308
316
|
</div>
|
309
317
|
|
318
|
+
<!-- show inline document links -->
|
319
|
+
<div v-if="docApp.showInlineDocumentsMarkup" class="hb-container-vertical">
|
320
|
+
|
321
|
+
<!-- the problem is the test server doesn't serve inline documents like the live/proper one ?? -->
|
322
|
+
<div class="modal fade" id="inlineModal" tabindex="-1" role="dialog" aria-hidden="true">
|
323
|
+
<div class="modal-dialog" role="document">
|
324
|
+
<div class="modal-content">
|
325
|
+
<iframe v-if="docApp.inlinePopupDocumentHref" v-bind:src="docApp.inlinePopupDocumentHref"></iframe>
|
326
|
+
</div>
|
327
|
+
</div>
|
328
|
+
</div>
|
329
|
+
|
330
|
+
|
331
|
+
<div class="p-4">
|
332
|
+
|
333
|
+
<div class="document-header">
|
334
|
+
<div class="document-title"><h1>Inline Help Documents (DOES NOT WORK) - NOTE DEV SERVER NEEDS _inline.html PROCESSING - NEED TO SPEAK TO GERRY</h1></div>
|
335
|
+
</div>
|
336
|
+
|
337
|
+
<div class="p-2">
|
338
|
+
<div v-for="(navSectionItem,index) in docApp.inlineDocumentItems">
|
339
|
+
|
340
|
+
<a class="DocLink link noitems" href="#" v-on:click="popupInlineDocument($event,navSectionItem)" style="padding-left: 0px;">
|
341
|
+
<span class="link-text"><i v-if="navSectionItem.draft" class="bi bi-exclamation-triangle-fill text-danger" title="This page is set to draft."></i><i class="bi bi-files-alt text-warning"></i> {{navSectionItem.text}}</span>
|
342
|
+
</a>
|
343
|
+
|
344
|
+
</div>
|
345
|
+
</div>
|
346
|
+
</div>
|
347
|
+
</div>
|
348
|
+
|
349
|
+
|
310
350
|
</div>
|
311
351
|
</div>
|
312
352
|
|
@@ -314,6 +354,8 @@
|
|
314
354
|
|
315
355
|
</div> <!-- <div class="main hb-vertical-expand"> -->
|
316
356
|
|
357
|
+
|
358
|
+
|
317
359
|
</body>
|
318
360
|
<script>
|
319
361
|
|
package/ui/js/doc.hornbill.js
CHANGED
@@ -12,6 +12,31 @@ var docAppMethods = {
|
|
12
12
|
let self = this;
|
13
13
|
self.docApp.userSession = info;
|
14
14
|
},
|
15
|
+
|
16
|
+
showInlineDocumentList:function(ev)
|
17
|
+
{
|
18
|
+
if(ev)
|
19
|
+
{
|
20
|
+
ev.stopImmediatePropagation();
|
21
|
+
ev.preventDefault();
|
22
|
+
}
|
23
|
+
|
24
|
+
let self = this;
|
25
|
+
self.docApp.showInlineDocumentsMarkup = true;
|
26
|
+
self.$forceUpdate();
|
27
|
+
},
|
28
|
+
popupInlineDocument:function(ev,navSectionItem)
|
29
|
+
{
|
30
|
+
if(ev)
|
31
|
+
{
|
32
|
+
ev.stopImmediatePropagation();
|
33
|
+
ev.preventDefault();
|
34
|
+
}
|
35
|
+
|
36
|
+
$('#inlineModal').modal("show");
|
37
|
+
let self = this;
|
38
|
+
self.docApp.inlinePopupDocumentHref = navSectionItem.link;
|
39
|
+
},
|
15
40
|
switchViewTheme: function () {
|
16
41
|
if (ThemePreference) document.documentElement.classList.remove(ThemePreference);
|
17
42
|
|
@@ -456,33 +481,56 @@ function old_expandNavParentSectionBySelectedLinkHref(findByLinkRef, currentNavS
|
|
456
481
|
|
457
482
|
}
|
458
483
|
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
484
|
+
var lastUrlDynamicallySet = "";
|
485
|
+
function setBrowserViewUrl(strHrefToLoad,viewData,fromPageRefresh,fromPopState)
|
486
|
+
{
|
487
|
+
|
488
|
+
let urlToSet = window.location.origin + "/" + strHrefToLoad;
|
489
|
+
const url = new URL(urlToSet);
|
490
|
+
|
491
|
+
//-- remove any old params
|
492
|
+
for(let strKey in global.stateParams)
|
493
|
+
{
|
494
|
+
url.searchParams.delete(strKey);
|
495
|
+
}
|
496
|
+
|
497
|
+
//-- now set new data params in url
|
498
|
+
for(let strKey in viewData)
|
499
|
+
{
|
500
|
+
url.searchParams.set(strKey,viewData[strKey]);
|
501
|
+
}
|
502
|
+
|
503
|
+
//-- store global params
|
504
|
+
global.stateParams = viewData;
|
505
|
+
|
506
|
+
if(!fromPageRefresh)
|
507
|
+
{
|
508
|
+
if(fromPopState)
|
509
|
+
{
|
510
|
+
//-- so user has clicked on a link - always add entry
|
511
|
+
window.history.pushState(null, null, url); //-- add entry
|
472
512
|
}
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
513
|
+
else
|
514
|
+
{
|
515
|
+
if(lastUrlDynamicallySet)
|
516
|
+
{
|
517
|
+
if(lastUrlDynamicallySet!==strHrefToLoad)
|
518
|
+
{
|
519
|
+
window.history.pushState(null, null, url); //-- add entry
|
520
|
+
}
|
521
|
+
else
|
522
|
+
{
|
523
|
+
window.history.replaceState(null, null, url); //-- user has refreshed page or jsut visited page
|
524
|
+
|
525
|
+
}
|
526
|
+
}
|
527
|
+
else
|
528
|
+
{
|
529
|
+
window.history.replaceState(null, null, url); //-- user has clicked a link so we want to add state to history so we can click back
|
530
|
+
}
|
483
531
|
}
|
484
532
|
}
|
485
|
-
|
533
|
+
lastUrlDynamicallySet=strHrefToLoad;
|
486
534
|
}
|
487
535
|
|
488
536
|
async function fetchContentFile(strFilePath) {
|
@@ -503,7 +551,7 @@ $(".document-body").attr("v-pre", "");
|
|
503
551
|
|
504
552
|
var view = new Vue({
|
505
553
|
el: '#vDocDevApp',
|
506
|
-
data: { userSession: {}, updateCounter: 0, bookId: "", docApp: { keepTocLayout: false, book: {}, navSections: [], tableOfContents: [], bookBreadCrumb: [] } },
|
554
|
+
data: { userSession: {}, updateCounter: 0, bookId: "", docApp: {inlinePopupDocumentHref:"",showInlineDocumentsMarkup:false, keepTocLayout: false, book: {}, navSections: [], inlineDocumentItems:[], tableOfContents: [], bookBreadCrumb: [] } },
|
507
555
|
methods: docAppMethods,
|
508
556
|
directives: {
|
509
557
|
somedirectivename: {
|
@@ -582,7 +630,6 @@ async function intialiseApp() {
|
|
582
630
|
});
|
583
631
|
|
584
632
|
//-- eof session stuff
|
585
|
-
|
586
633
|
await fetchJsonFile("_books/library.json").then(function (data) {
|
587
634
|
|
588
635
|
// Get docbook library list
|
@@ -592,14 +639,22 @@ async function intialiseApp() {
|
|
592
639
|
}).then(function () {
|
593
640
|
// Get hdocbook.json
|
594
641
|
fetchJsonFile("_books/" + view.docId + "/hdocbook.json").then(function (data) {
|
595
|
-
console.log(view.docApp.library.books[0].nav_inline)
|
642
|
+
//console.log(view.docApp.library.books[0].nav_inline)
|
596
643
|
view.docApp.book = data;
|
597
644
|
view.bookId = data.docId;
|
598
645
|
view.docApp.title = data.title || "";
|
599
646
|
view.docApp.description = data.description || "";
|
600
647
|
|
601
|
-
|
648
|
+
|
649
|
+
view.docApp.inlineDocumentItems = [];
|
650
|
+
view.docApp.inlinePopupDocumentHref = "";
|
651
|
+
view.docApp.showInlineDocumentsMarkup = false;
|
652
|
+
view.docApp.hasInlinePopupDocuments = (view.docApp.library.books[0].nav_inline && view.docApp.library.books[0].nav_inline.items && view.docApp.library.books[0].nav_inline.items.length)?true:false
|
653
|
+
if(view.docApp.hasInlinePopupDocuments)
|
654
|
+
{
|
655
|
+
view.docApp.inlineDocumentItems = view.docApp.library.books[0].nav_inline.items;
|
602
656
|
view.docApp.book.navigation.items.push(view.docApp.library.books[0].nav_inline);
|
657
|
+
}
|
603
658
|
|
604
659
|
//-- now render out the nav menu
|
605
660
|
view.renderNavigation();
|