hdoc-tools 0.7.13 → 0.7.15

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 CHANGED
@@ -123,7 +123,7 @@
123
123
  console.log(` Failed to convert: ${conversion_failed}`);
124
124
 
125
125
  console.log(`\r\nValidating paths in generated HTML files`);
126
- const validation_success = validate.run(work_path, verbose);
126
+ const validation_success = validate.run(work_path, docId, verbose);
127
127
  if (!validation_success) {
128
128
  process.exit(1);
129
129
  }
package/hdoc-serve.js CHANGED
@@ -112,6 +112,7 @@
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);
115
116
  text = text.replaceAll('{{DOC_ID}}', docId);
116
117
  text = text.replaceAll('{{BUILD_NUMBER}}', '0');
117
118
 
@@ -324,14 +325,31 @@
324
325
 
325
326
  // Return a 404 error here
326
327
  send_content_resource_404(req, res);
327
- });
328
+ });
328
329
 
329
330
  // Catch all
330
331
  app.get('/*', function (req, res) {
331
332
 
332
- let ui_file_path = path.join(ui_path, req.url);
333
+ 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
+ }
333
346
 
334
- console.log('URL Root:', req.url);
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
+
352
+ let ui_file_path = path.join(ui_path, req.url);
335
353
 
336
354
  // To support the SPA application behavior, if there is no file extension present, then
337
355
  // we simply return the /index.html file content to the client
package/hdoc-validate.js CHANGED
@@ -12,7 +12,8 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
12
12
  let errors = {},
13
13
  messages = {},
14
14
  errorcount = 0,
15
- filecount = 0;
15
+ filecount = 0,
16
+ htmlFiles = [];
16
17
 
17
18
  const stringIsAValidUrl = (s) => {
18
19
  try {
@@ -52,8 +53,6 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
52
53
  symbolicLinks: false
53
54
  };
54
55
 
55
- let htmlFiles = [];
56
-
57
56
  // File callbacks for html file scan
58
57
  const fileCallback = function (element) {
59
58
  filecount++;
@@ -91,10 +90,11 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
91
90
  };
92
91
 
93
92
 
94
- exports.run = function (source_path, verbose) {
93
+ exports.run = function (source_path, doc_id, verbose) {
95
94
  // Get a list of HTML files in source_path
96
95
  dree.scan(source_path, dreeOptions, fileCallback);
97
96
 
97
+ let listContent = '';
98
98
  for (let i = 0; i < htmlFiles.length; i++) {
99
99
 
100
100
  // Initiate maps for errors and verbose messages for HTML file
@@ -108,6 +108,19 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
108
108
  checkLinks(source_path, htmlFiles[i], links);
109
109
  }
110
110
 
111
+ // Build list content for Google
112
+ listContent += `/${htmlFiles[i].relativePath}`;
113
+ if (i < htmlFiles.length - 1) {
114
+ listContent += '\r\n';
115
+ }
116
+ }
117
+ try {
118
+ // Write list
119
+ const listFile = path.join(source_path, doc_id, 'list.txt');
120
+ fs.writeFileSync(listFile, listContent);
121
+ console.log(`${listFile} created successfully`);
122
+ } catch (err) {
123
+ console.error(err);
111
124
  }
112
125
  if (errorcount === 0) {
113
126
  console.log('\r\n---------------');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.7.13",
3
+ "version": "0.7.15",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {