hdoc-tools 0.14.1 → 0.14.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-db.js +19 -13
- package/hdoc-build.js +21 -23
- package/hdoc-validate.js +14 -4
- package/package.json +1 -1
package/hdoc-build-db.js
CHANGED
@@ -117,19 +117,25 @@
|
|
117
117
|
await Promise.all(indexPromises.map(async (file) => {
|
118
118
|
let index_path_name = file.relative_path.replace('\\', '/');
|
119
119
|
index_path_name = '/' + index_path_name.replace(path.extname(file.relative_path), '');
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
120
|
+
let index_response = {
|
121
|
+
success: true,
|
122
|
+
row_id: 0
|
123
|
+
};
|
124
|
+
if (!file.inline) {
|
125
|
+
const index_vals = [
|
126
|
+
index_path_name,
|
127
|
+
doc_id,
|
128
|
+
book_config.audience.join(','),
|
129
|
+
book_config.tags.join(','),
|
130
|
+
file.index_html.fm_props.title,
|
131
|
+
file.index_html.text,
|
132
|
+
file.index_html.preview,
|
133
|
+
book_config.productFamily,
|
134
|
+
file.md5,
|
135
|
+
file.lastmod
|
136
|
+
];
|
137
|
+
index_response = hdoc_index.insert_record(db, 'hdoc_index', db_schema.hdoc_index, index_vals);
|
138
|
+
}
|
133
139
|
if (!index_response.success) {
|
134
140
|
console.log(`Index record creation failed - ${doc_id}/${file.index_html.fm_props.title}: ${index_response.error}`);
|
135
141
|
} else {
|
package/hdoc-build.js
CHANGED
@@ -268,17 +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
|
-
|
280
|
-
|
281
|
-
|
271
|
+
index_records.push({
|
272
|
+
relative_path: file_path.relativePath,
|
273
|
+
index_html: hdoc_index.transform_html_for_index(html_txt),
|
274
|
+
metadata: metadata,
|
275
|
+
contributors: contribs,
|
276
|
+
pdf_size: pdf_size,
|
277
|
+
md5: file_path.hash,
|
278
|
+
lastmod: last_commit !== null ? last_commit : file_path.hb_lastmod,
|
279
|
+
inline: inline_content
|
280
|
+
});
|
281
|
+
|
282
282
|
// Save HTML into HTML file
|
283
283
|
try {
|
284
284
|
fs.writeFileSync(file_path.path, html_txt);
|
@@ -510,18 +510,16 @@
|
|
510
510
|
console.log('Error writing:', target_file, '\n', err);
|
511
511
|
}
|
512
512
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
});
|
524
|
-
}
|
513
|
+
index_records.push({
|
514
|
+
relative_path: relative_path,
|
515
|
+
index_html: hdoc_index.transform_html_for_index(html_txt),
|
516
|
+
metadata: metadata,
|
517
|
+
contributors: contribs,
|
518
|
+
pdf_size: pdf_size,
|
519
|
+
md5: file_path.hash,
|
520
|
+
lastmod: last_commit !== null ? last_commit : file_path.hb_lastmod,
|
521
|
+
inline: inline_content
|
522
|
+
});
|
525
523
|
|
526
524
|
// Add MD file to delete queue
|
527
525
|
md_files_delete.push(file_path.path)
|
package/hdoc-validate.js
CHANGED
@@ -101,7 +101,8 @@
|
|
101
101
|
// See if there's a redirect in place
|
102
102
|
let redirected = false;
|
103
103
|
let redirect_errored = false;
|
104
|
-
const redir =
|
104
|
+
const redir = checkRedirect(source_path, key_no_hash);
|
105
|
+
|
105
106
|
if (redir.exists && redir.error !== null) {
|
106
107
|
nav_errors.push(redir.error);
|
107
108
|
redirect_errored = true;
|
@@ -193,7 +194,7 @@
|
|
193
194
|
return nav_errors;
|
194
195
|
};
|
195
196
|
|
196
|
-
const checkRedirect =
|
197
|
+
const checkRedirect = function (source_path, nav_path) {
|
197
198
|
let response = {
|
198
199
|
exists: false,
|
199
200
|
error: null
|
@@ -220,7 +221,7 @@
|
|
220
221
|
return response;
|
221
222
|
}
|
222
223
|
|
223
|
-
const checkLinks = async function (source_path, htmlFile, links, hdocbook_config) {
|
224
|
+
const checkLinks = async function (source_path, htmlFile, links, hdocbook_config, redirects) {
|
224
225
|
for (let i = 0; i < links.length; i++) {
|
225
226
|
|
226
227
|
// Validate that link is a valid URL first
|
@@ -376,7 +377,16 @@
|
|
376
377
|
if (response.is_rel_path) {
|
377
378
|
messages[html_path.relativePath].push(`Relative path exists: ${relative_path}`);
|
378
379
|
} else {
|
379
|
-
|
380
|
+
|
381
|
+
// See if there's a redirect in place
|
382
|
+
const relpath = relative_path.indexOf('/') == 0 ? relative_path.substring(1) : relative_path;
|
383
|
+
const redir = checkRedirect(source_path, relpath);
|
384
|
+
if (redir.exists) {
|
385
|
+
if (redir.error !== null)
|
386
|
+
errors[html_path.relativePath].push(redir.error);
|
387
|
+
} else {
|
388
|
+
errors[html_path.relativePath].push(`Link path does not exist: ${relative_path}`);
|
389
|
+
}
|
380
390
|
}
|
381
391
|
}
|
382
392
|
}
|