spec-up-t 1.1.49 → 1.1.51

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.
@@ -95,7 +95,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95
95
  * @license MIT
96
96
  * @since 2024-06-09
97
97
  */
98
- function editTermButtons(){const t=((e=specConfig.spec_directory).startsWith("./")?e=e.substring(2):e.startsWith("/")&&(e=e.substring(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e);var e;document.querySelectorAll('dt:has(> span[id^="term:"])').forEach(e=>{const n=function(t){let e=t;for(;e.querySelector('span[id^="term:"]');)e=e.querySelector('span[id^="term:"]');return e}(e),s=n.getAttribute("id").split(":")[1];n.innerHTML+=`<span class="edit-term-buttons"><a title="Link to the term file in the Github repo in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/main/${t}/${specConfig.spec_terms_directory}/${s}.md" class="p-1 edit-term-button btn">🖊️</a><a title="Link to a GitHub page that shows a history of the edits in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/main/${t}/${specConfig.spec_terms_directory}/${s}.md" class="p-1 history-term-button btn">📅</a></span>`})}document.addEventListener("DOMContentLoaded",(function(){editTermButtons()}));
98
+ function editTermButtons(){const t=((e=specConfig.spec_directory).startsWith("./")?e=e.substring(2):e.startsWith("/")&&(e=e.substring(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e);var e;document.querySelectorAll('dt:has(> span[id^="term:"])').forEach(e=>{const n=function(t){let e=t;for(;e.querySelector('span[id^="term:"]');)e=e.querySelector('span[id^="term:"]');return e}(e),s=n.getAttribute("id").split(":")[1],o=specConfig.source.branch||"main";n.innerHTML+=`<span class="edit-term-buttons"><a title="Link to the term file in the Github repo in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/${o}/${t}/${specConfig.spec_terms_directory}/${s}.md" class="p-1 edit-term-button btn">🖊️</a><a title="Link to a GitHub page that shows a history of the edits in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/${o}/${t}/${specConfig.spec_terms_directory}/${s}.md" class="p-1 history-term-button btn">📅</a></span>`})}document.addEventListener("DOMContentLoaded",(function(){editTermButtons()}));
99
99
  function createAlphabetIndex(){const e=document.getElementById("terminology-section-utility-container"),t=document.querySelector(".terms-and-definitions-list").querySelectorAll("dt"),n={};t.forEach(e=>{const t=e.querySelector("span");if(t&&t.id){const e=t.id,o=e.charAt(e.indexOf("term:")+5).toUpperCase();n[o]||(n[o]=t.id)}});const o=document.createElement("div");o.className="alphabet-index-container";const c=document.createElement("p");c.className="number-of-terms",c.textContent=`– There are ${t.length} terms –`,e.appendChild(c),Object.keys(n).sort().forEach(e=>{const t=document.createElement("a");t.href="#"+n[e],t.textContent=e,o.appendChild(t)}),e.appendChild(o)}document.addEventListener("DOMContentLoaded",(function(){createAlphabetIndex()}));
100
100
  function inPageSearch(){const t=document.getElementById("terminology-section-utility-container"),e=specConfig.searchHighlightStyle||"ssi",n="search-h7vc6omi2hr2880",i=document.querySelector(".terms-and-definitions-list"),o=document.createElement("div");o.setAttribute("id","container-"+n),o.classList.add("input-group","mb-3","d-flex","align-items-center"),o.setAttribute("role","search"),t.appendChild(o);const s=document.createElement("input");s.setAttribute("type","text"),s.setAttribute("id",n),s.classList.add("form-control"),s.setAttribute("placeholder","🔍"),s.setAttribute("aria-label","Search terms"),s.setAttribute("autocomplete","off"),o.appendChild(s);const c=document.createElement("div");c.classList.add("input-group-append");const a=document.createElement("button");a.setAttribute("id","one-match-backward-"+n),a.classList.add("btn","btn-outline-secondary"),a.setAttribute("type","button"),a.setAttribute("disabled","true"),a.setAttribute("title","Go to previous match (Left Arrow)"),a.setAttribute("aria-label","Go to previous match"),a.innerHTML='<span aria-hidden="true">▲</span>',c.appendChild(a);const r=document.createElement("button");r.setAttribute("id","one-match-forward-"+n),r.classList.add("btn","btn-outline-secondary"),r.setAttribute("type","button"),r.setAttribute("disabled","true"),r.setAttribute("title","Go to next match (Right Arrow)"),r.setAttribute("aria-label","Go to next match"),r.innerHTML='<span aria-hidden="true">▼</span>',c.appendChild(r);const d=document.createElement("span");d.setAttribute("id","total-matches-"+n),d.classList.add("input-group-text"),d.innerHTML="0 matches",d.setAttribute("aria-live","polite"),d.setAttribute("role","status"),o.appendChild(d),o.appendChild(c),s.addEventListener("input",(function(){f(s.value)})),document.addEventListener("click",t=>{t.target.classList.contains("collapse-all-defs-button")&&f(s.value)});const l="highlight-matches-"+n,u={dif:"highlight-matches-DIF-search-h7vc6omi2hr2880",toip:"highlight-matches-ToIP-search-h7vc6omi2hr2880",btc:"highlight-matches-BTC-search-h7vc6omi2hr2880",keri:"highlight-matches-KERI-search-h7vc6omi2hr2880",ssi:"highlight-matches-SSI-search-h7vc6omi2hr2880",gleif:"highlight-matches-GLEIF-search-h7vc6omi2hr2880"}[e.toLowerCase()];let h=0,m=-1;function p(t){t.scrollIntoView({behavior:"smooth",block:"start"});const e=t.getBoundingClientRect(),n=e.top+window.pageYOffset-(window.innerHeight-e.height)/2;window.scrollTo({top:n,behavior:"smooth"})}function b(){m<=0?document.getElementById("one-match-backward-"+n).setAttribute("disabled","disabled"):document.getElementById("one-match-backward-"+n).removeAttribute("disabled"),m>=h-1?document.getElementById("one-match-forward-"+n).setAttribute("disabled","disabled"):document.getElementById("one-match-forward-"+n).removeAttribute("disabled")}function g(){d.innerHTML=h+" matches"}const f=function(t,e){let n;return function(){const i=this,o=arguments;clearTimeout(n),n=setTimeout(()=>t.apply(i,o),e)}}((function(t){void document.querySelectorAll("span."+l).forEach(t=>{Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&t.removeChild(e)}),t.classList.contains(l)&&(t.outerHTML=t.innerHTML)}),h=0,m=-1,t.length>=2&&('"'===t[0]&&'"'===t[t.length-1]||"'"===t[0]&&"'"===t[t.length-1])&&(t=t.substring(1,t.length-1));if(""===t)return void g();let e=0;!function i(o){if(3!==o.nodeType||function(t){for(;t;){if(t.classList&&t.classList.contains("hidden"))return!0;t=t.parentNode}return!1}(o))1===o.nodeType&&Array.from(o.childNodes).forEach(i);else{const i=function(i){const o=i.nodeValue,s=new RegExp(t,"gi");let c,a=0,r=document.createDocumentFragment();for(;null!==(c=s.exec(o));){r.appendChild(document.createTextNode(o.substring(a,c.index)));const t=document.createElement("span");t.textContent=c[0],t.classList.add(l),t.classList.add(u),t.setAttribute("id",n+"-"+e),r.appendChild(t),h=e+1,e++,a=c.index+c[0].length}return r.appendChild(document.createTextNode(o.substring(a))),r}(o);i.childNodes.length>1&&o.parentNode.replaceChild(i,o)}}(i);let o=document.querySelector("."+u);null!==o&&p(o);g(),b(),m=-1}),600);a.addEventListener("click",(function(){m--;const t=document.querySelector("#"+n+"-"+m);t&&p(t),t.classList.add("active"),setTimeout(()=>{t.classList.remove("active")},3e3),b()})),r.addEventListener("click",(function(){m++;const t=document.querySelector("#"+n+"-"+m);t&&p(t),t.classList.add("active"),setTimeout(()=>{t.classList.remove("active")},3e3),b()})),document.addEventListener("keyup",t=>{switch(t.key){case"ArrowRight":r.click();break;case"ArrowLeft":a.click()}})}document.addEventListener("DOMContentLoaded",(function(){inPageSearch()}));
101
101
  function highlightMenuItems(){let t=null;function e(t){document.querySelectorAll("#toc_list a").forEach(t=>{t.classList.remove("highlight-cfib41dyhcd99sm")});const e=document.querySelector(`#toc_list a[href="#${t.id}"]`);e&&(e.classList.add("highlight-cfib41dyhcd99sm"),e.scrollIntoView({behavior:"smooth",block:"center"}))}const o=new IntersectionObserver((o,n)=>{const c=o.filter(t=>t.isIntersecting).map(t=>t.target);c.length>0?(t=c[0],e(t)):t&&e(t)},{root:null,rootMargin:"0px",threshold:.1});document.querySelectorAll("h2, h3, h4, h5, h6").forEach(t=>o.observe(t))}document.addEventListener("DOMContentLoaded",(function(){highlightMenuItems()}));
@@ -46,9 +46,10 @@ function editTermButtons() {
46
46
 
47
47
  // cut “url” on the “:” and keep the second part
48
48
  const fileName = url.split(":")[1];
49
+ const branch = specConfig.source.branch || "main";
49
50
 
50
51
  // add edit and history buttons to term
51
- term.innerHTML += `<span class="edit-term-buttons"><a title="Link to the term file in the Github repo in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/main/${cleanedSpecDir}/${specConfig.spec_terms_directory}/${fileName}.md" class="p-1 edit-term-button btn">🖊️</a><a title="Link to a GitHub page that shows a history of the edits in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/main/${cleanedSpecDir}/${specConfig.spec_terms_directory}/${fileName}.md" class="p-1 history-term-button btn">📅</a></span>`;
52
+ term.innerHTML += `<span class="edit-term-buttons"><a title="Link to the term file in the Github repo in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/${branch}/${cleanedSpecDir}/${specConfig.spec_terms_directory}/${fileName}.md" class="p-1 edit-term-button btn">🖊️</a><a title="Link to a GitHub page that shows a history of the edits in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/${branch}/${cleanedSpecDir}/${specConfig.spec_terms_directory}/${fileName}.md" class="p-1 history-term-button btn">📅</a></span>`;
52
53
  });
53
54
  }
54
55
 
package/index.js CHANGED
@@ -30,6 +30,10 @@ module.exports = async function (options = {}) {
30
30
  const modulePath = findPkgDir(__dirname);
31
31
  let config = fs.readJsonSync('./output/specs-generated.json');
32
32
 
33
+ const createExternalSpecsList = require('./src/create-external-specs-list.js');
34
+
35
+ const externalSpecsList = createExternalSpecsList(config);
36
+
33
37
  const createVersionsIndex = require('./src/create-versions-index.js');
34
38
  createVersionsIndex(config.specs[0].output_path);
35
39
 
@@ -307,7 +311,8 @@ module.exports = async function (options = {}) {
307
311
  specLogo: spec.logo,
308
312
  specFavicon: spec.favicon,
309
313
  specLogoLink: spec.logo_link,
310
- spec: JSON.stringify(spec)
314
+ spec: JSON.stringify(spec),
315
+ externalSpecsList: externalSpecsList,
311
316
  });
312
317
 
313
318
  const outputPath = path.join(spec.destination, 'index.html');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.1.49",
3
+ "version": "1.1.51",
4
4
  "description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
5
5
  "main": "./index",
6
6
  "repository": {
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Creates an HTML list of external specifications based on the provided configuration.
3
+ *
4
+ * @param {object} config - The configuration object containing specification details.
5
+ * @param {Array<object>} config.specs - An array of specification objects.
6
+ * @param {Array<object>} config.specs[].external_specs - An array of external specification objects.
7
+ * @param {string} config.specs[].external_specs[].external_spec - The name of the external specification.
8
+ * @param {string} config.specs[].external_specs[].url - The URL of the external specification.
9
+ * @param {string} config.specs[].external_specs[].gh_page - The GitHub page of the external specification.
10
+ *
11
+ * @returns {string} An HTML string representing the list of external specifications.
12
+ * Returns a message indicating no specifications were found if the configuration is invalid or empty.
13
+ */
14
+
15
+ module.exports = function createExternalSpecsList(config) {
16
+ if (!config || !config.specs || !Array.isArray(config.specs)) {
17
+ console.warn('❌ Invalid config format. Expected an object with a specs array.');
18
+ return '<p>No external specifications found.</p>';
19
+ }
20
+
21
+ let externalSpecs = [];
22
+ config.specs.forEach(spec => {
23
+ if (spec.external_specs && Array.isArray(spec.external_specs)) {
24
+ externalSpecs = externalSpecs.concat(spec.external_specs);
25
+ }
26
+ });
27
+
28
+ if (externalSpecs.length === 0) {
29
+ return '<p>No external specifications found.</p>';
30
+ }
31
+
32
+ let html = '<ul class="list-group">';
33
+
34
+ externalSpecs.forEach(spec => {
35
+ html += `
36
+ <li class="list-group-item border-0 p-0 ps-3">
37
+ <p>
38
+ ${spec.external_spec}:
39
+ <a href="${spec.url}" target="_blank" class="">
40
+ <i class="fa fa-link"></i> URL
41
+ </a>
42
+ <a href="${spec.gh_page}" target="_blank" class="">
43
+ <i class="fa fa-github"></i> GitHub Page
44
+ </a>
45
+ </p>
46
+ </li>
47
+ `;
48
+ });
49
+
50
+ html += '</ul>';
51
+ return html;
52
+ };
@@ -247,7 +247,9 @@
247
247
  </button>
248
248
  <!-- href added via JS -->
249
249
  <a id="snapshotLink" class="btn btn-menu-item m-0 mb-1 border-start-0 border-end-0" href="#">Snapshots</a>
250
-
250
+ <hr>
251
+ <p class="ps-3 pe-3">External specifications:</p>
252
+ ${externalSpecsList}
251
253
  </div>
252
254
  </div>
253
255