hdoc-tools 0.9.45 → 0.9.47

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
@@ -637,7 +637,7 @@
637
637
  console.log(`Loading product families...`);
638
638
  const prods = await hdoc.load_product_families();
639
639
  if (!prods.success) {
640
- console.log(`ERROR: Failed to load product families: ${prods.errors}\n`);
640
+ console.log(`${prods.errors}\n`);
641
641
  process.exit(1);
642
642
  } else {
643
643
  prod_families = prods.prod_families;
@@ -655,7 +655,7 @@
655
655
  try {
656
656
  css_templates.push(fs.readFileSync(css_files[i], 'utf8'));
657
657
  } catch (e) {
658
- console.log(`Error reading file [${css_files[i]}]: ${e}`);
658
+ console.log(`Error reading file[${css_files[i]}]: ${e}`);
659
659
  }
660
660
  }
661
661
  }
package/hdoc-module.js CHANGED
@@ -358,23 +358,30 @@
358
358
  prods_supported: [],
359
359
  errors: ''
360
360
  };
361
-
362
- try {
363
- const prods = await axios.get('https://docs.hornbill.com/_books/products.json', {
364
- httpsAgent: agent
365
- });
366
- if (prods.status === 200) {
367
- response.prod_families = prods.data;
368
- response.prods_supported = [];
369
- for (let i = 0; i < response.prod_families.products.length; i++) {
370
- response.prods_supported.push(response.prod_families.products[i].id);
361
+ const prod_families_url = 'https://docs.hornbill.com/_books/products.json';
362
+ for (let i = 1; i < 4; i++) {
363
+ try {
364
+ const prods = await axios.get(prod_families_url, {
365
+ httpsAgent: agent,
366
+ timeout: 5000
367
+ });
368
+ if (prods.status === 200) {
369
+ response.prod_families = prods.data;
370
+ response.prods_supported = [];
371
+ for (let i = 0; i < response.prod_families.products.length; i++) {
372
+ response.prods_supported.push(response.prod_families.products[i].id);
373
+ }
374
+ response.success = true;
375
+ break;
376
+ } else {
377
+ throw `Unexpected status - ${prods.status} ${prods.statusText}`;
371
378
  }
372
- response.success = true;
373
- } else {
374
- throw `Unexpected Status ${prods.status}`;
379
+ } catch (e) {
380
+ if (response.errors === '') response.errors = `Request to ${prod_families_url} failed:`;
381
+ response.errors += `\nAttempt ${i} - Error returning product families: ${e}`;
382
+ // Wait 2 seconds and try again
383
+ await new Promise(r => setTimeout(r, 2000));
375
384
  }
376
- } catch (e) {
377
- response.errors = (`Error returning product families: ${e}`);
378
385
  }
379
386
  return response;
380
387
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.9.45",
3
+ "version": "0.9.47",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -34,6 +34,7 @@
34
34
  "dependencies": {
35
35
  "american-british-english-translator": "^0.2.1",
36
36
  "axios": "^1.3.2",
37
+ "axios-retry": "^3.5.0",
37
38
  "better-sqlite3": "^8.0.1",
38
39
  "body-parser": "^1.20.1",
39
40
  "cheerio": "^1.0.0-rc.12",
@@ -50,6 +51,7 @@
50
51
  "multer": "^1.4.5-lts.1",
51
52
  "prompt": "^1.3.0",
52
53
  "puppeteer": "^19.8.0",
54
+ "retry": "^0.13.1",
53
55
  "stream": "0.0.2",
54
56
  "true-case-path": "^2.2.1",
55
57
  "words-count": "^2.0.2",
@@ -133,6 +133,7 @@ function listenForHrefClicks()
133
133
 
134
134
  }
135
135
 
136
+ //-- based on content url highlight match navigation menu item
136
137
  //-- based on content url highlight match navigation menu item
137
138
  function highlightNavigationLinkFromUrl(matchLinkHref)
138
139
  {
@@ -140,32 +141,45 @@ function highlightNavigationLinkFromUrl(matchLinkHref)
140
141
  matchLinkHref = removeStartingSlash(matchLinkHref).split("#")[0]; //-- remvoe # link
141
142
  $('a.DocLink').removeClass("active");
142
143
 
143
- document.querySelectorAll('a.DocLink').forEach((el) => {
144
-
144
+ let arrItems = document.querySelectorAll('a.DocLink');
145
+
146
+ for(let x=0;x<arrItems.length;x++)
147
+ {
145
148
  let checkUrl = null;
146
149
  try{
147
150
  checkUrl = new URL(el.href);
148
151
  }
149
152
  catch(e)
150
153
  {
151
- console.log("BAD navigation menu item found",el.href);
154
+ //console.log("BAD navigation menu item found",el);
152
155
  }
153
156
 
154
157
  if(checkUrl)
155
158
  {
156
159
  //console.log(checkUrl.pathname,matchLinkHref)
157
- if(removeStartingSlash(checkUrl.pathname).indexOf(matchLinkHref)===0)
160
+ let testCurrPath = removeStartingSlash(checkUrl.pathname);
161
+ if(testCurrPath===matchLinkHref)
158
162
  {
159
- $(el).addClass("active");
163
+ //-- exact match
164
+ $(el).addClass("active")
165
+ el.scrollIntoView();
166
+ return false;//break out
167
+ }
168
+ else if(testCurrPath.indexOf(matchLinkHref)===0)
169
+ {
170
+ //--
171
+ $(el).addClass("active")
172
+ el.scrollIntoView();
160
173
  return false;//break out
161
174
  }
162
175
  else if(matchLinkHref.indexOf(removeStartingSlash(checkUrl.pathname) + "/")===0)
163
176
  {
164
177
  $(el).addClass("active");
178
+ el.scrollIntoView();
165
179
  return false;//break out
166
180
  }
167
181
  }
168
- });
182
+ }
169
183
  }
170
184
 
171
185
  function getAnchorFromHash(strHash,strHasClass)