hdoc-tools 0.8.30 → 0.8.32

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 CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  const db_schema = {
9
9
  hdoc_index: [
10
- 'relative_url UNINDEXED',
10
+ 'resource_url UNINDEXED',
11
11
  'book_id',
12
12
  'book_audience UNINDEXED',
13
13
  'book_tags',
@@ -17,14 +17,15 @@
17
17
  'doc_family_id'
18
18
  ],
19
19
  hdoc_meta: [
20
- 'relative_url',
20
+ 'resource_url',
21
21
  'book_id',
22
22
  'contributor_count INTEGER UNINDEXED',
23
23
  'edit_url UNINDEXED',
24
- 'last_commit UNINDEXED'
24
+ 'last_commit UNINDEXED',
25
+ 'pdf_size INTEGER UNINDEXED'
25
26
  ],
26
27
  hdoc_contributors: [
27
- 'relative_url',
28
+ 'resource_url',
28
29
  'book_id',
29
30
  'login',
30
31
  'name',
@@ -78,8 +79,8 @@
78
79
  if (!book_config.tags) book_config.tags = [];
79
80
 
80
81
  for (let i = 0; i < index_records.length; i++) {
81
- let index_path_name = index_records[i].relative_path.replace('\\', '/').replace(`${doc_id}/`, '');
82
- index_path_name = index_path_name.replace(path.extname(index_records[i].relative_path), '');
82
+ let index_path_name = index_records[i].relative_path.replace('\\', '/');
83
+ index_path_name = '/' + index_path_name.replace(path.extname(index_records[i].relative_path), '');
83
84
  const index_vals = [
84
85
  index_path_name,
85
86
  doc_id,
@@ -102,7 +103,8 @@
102
103
  doc_id,
103
104
  index_records[i].metadata.contributor_count,
104
105
  index_records[i].metadata.edit_url,
105
- index_records[i].metadata.last_commit
106
+ index_records[i].metadata.last_commit,
107
+ index_records[i].pdf_size
106
108
  ];
107
109
  const meta_response = hdoc_index.insert_record(db, 'hdoc_meta', db_schema.hdoc_meta, meta_vals);
108
110
  if (!meta_response.success) {
package/hdoc-build-pdf.js CHANGED
@@ -17,7 +17,6 @@
17
17
 
18
18
  let css_files = [],
19
19
  hb_logo = '',
20
- header = '',
21
20
  footer = '';
22
21
 
23
22
  const file_callback = function (element) {
@@ -98,7 +97,7 @@
98
97
 
99
98
  exports.generate_pdf = async function (pdf_template_path, pdf_template_content, book_config, html_source, target_file, verbose = false) {
100
99
  if (verbose) console.log(`Generating PDF: ${target_file}`);
101
-
100
+ let pdf_size = 0;
102
101
  // Cache footer
103
102
  if (footer === '') footer = get_footer(pdf_template_path);
104
103
 
@@ -111,7 +110,7 @@
111
110
  hb_logo = `data:image/svg+xml;base64,${hb_logo}`;
112
111
  } catch (err) {
113
112
  console.log('Error reading logo from template:', err);
114
- return;
113
+ return pdf_size;
115
114
  }
116
115
  }
117
116
 
@@ -143,7 +142,7 @@
143
142
  }
144
143
 
145
144
  try {
146
- await page.pdf({
145
+ const pdf_gen = await page.pdf({
147
146
  path: target_file,
148
147
  margin: {
149
148
  top: '30px',
@@ -159,11 +158,13 @@
159
158
  });
160
159
  if (verbose) console.log('PDF generation success.');
161
160
 
161
+ pdf_size = pdf_gen.byteLength;
162
162
  } catch (err) {
163
163
  console.log(`Error generating PDF ${target_file} - ${err}`);
164
164
  }
165
165
 
166
166
  // Close the browser instance
167
167
  await browser.close();
168
+ return pdf_size;
168
169
  };
169
170
  })();
package/hdoc-build.js CHANGED
@@ -227,13 +227,14 @@
227
227
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
228
228
  }
229
229
 
230
+ let pdf_size = 0;
230
231
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) {
231
232
  let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
232
233
  pdf_txt = `${pdf_header}\n${pdf_txt}`;
233
234
 
234
235
  // Generate PDF file from HTML
235
236
  const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
236
- await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
237
+ pdf_size = await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
237
238
  }
238
239
 
239
240
  html_txt = `${fm_header_content}\n${doc_header}\n${html_txt}`;
@@ -242,7 +243,8 @@
242
243
  relative_path: file_path.relativePath,
243
244
  index_html: hdoc_index.transform_html_for_index(html_txt),
244
245
  metadata: metadata,
245
- contributors: contribs
246
+ contributors: contribs,
247
+ pdf_size: pdf_size
246
248
  });
247
249
  // Save HTML into HTML file
248
250
  try {
@@ -425,14 +427,15 @@
425
427
  doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
426
428
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
427
429
  }
428
-
430
+
431
+ let pdf_size = 0;
429
432
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) {
430
433
  let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
431
434
  pdf_txt = `${pdf_header}\n${pdf_txt}`;
432
435
 
433
436
  // Generate PDF file from HTML
434
437
  const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
435
- await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
438
+ pdf_size = await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
436
439
  }
437
440
 
438
441
  html_txt = `${fm_header}\n${doc_header}\n${html_txt}`;
@@ -452,7 +455,8 @@
452
455
  relative_path: relative_path,
453
456
  index_html: index_details,
454
457
  metadata: metadata,
455
- contributors: contribs
458
+ contributors: contribs,
459
+ pdf_size: pdf_size
456
460
  });
457
461
 
458
462
  // Delete MD file from _work path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.8.30",
3
+ "version": "0.8.32",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {