pict-docuserve 1.4.12 → 1.4.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-docuserve",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "description": "Pict Documentation Server - A single-page documentation viewer built on Pict",
5
5
  "main": "source/Pict-Application-Docuserve.js",
6
6
  "bin": {
@@ -236,6 +236,19 @@ class DocuserveApplication extends libPictApplication
236
236
  * #/doc/<group>/<module>/<path> -> navigateToModulePath(group, module, path)
237
237
  */
238
238
  resolveHash()
239
+ {
240
+ this._resolveHashRoute();
241
+ // Keep the topbar "view source" (octocat) link pointed at whatever
242
+ // module the current route resolves to (fixed on per-module sites,
243
+ // changes per navigation on the aggregate).
244
+ let tmpTopBarUser = this.pict.views['Docuserve-TopBar-User'];
245
+ if (tmpTopBarUser && (typeof tmpTopBarUser.render === 'function'))
246
+ {
247
+ tmpTopBarUser.render();
248
+ }
249
+ }
250
+
251
+ _resolveHashRoute()
239
252
  {
240
253
  let tmpHash = (window.location.hash || '').replace(/^#\/?/, '');
241
254
 
@@ -495,7 +495,7 @@ class DocuserveCommandStageExamples extends libCommandLineCommand
495
495
  // The launch link is a plain browser link the browser resolves against
496
496
  // the docs-root index.html — so it carries the full docs-root-relative
497
497
  // path and works from the writeup's folder or anywhere else.
498
- let tmpInner = `> **[&#9654; Launch the live app](${mdSafeUrl('examples/' + tmpName + '/index.html')})** runs in your browser, opens in a new tab.`;
498
+ let tmpInner = `> **[Launch the live app](${mdSafeUrl('examples/' + tmpName + '/index.html')})** - runs in your browser, opens in a new tab.`;
499
499
 
500
500
  let tmpText;
501
501
  if (libFS.existsSync(tmpReadmePath))
@@ -542,7 +542,7 @@ class DocuserveCommandStageExamples extends libCommandLineCommand
542
542
  // The writeup is a .md SPA route resolved relative to this index;
543
543
  // the launch link is a plain browser link carrying the full
544
544
  // docs-root-relative path.
545
- return `| [${escapeTableCell(pEx.Title)}](${mdSafeUrl(pEx.Name + '/README.md')}) | ${tmpComplexity} | ${escapeTableCell(pEx.Summary)} | [&#9654; Launch](${mdSafeUrl('examples/' + pEx.Name + '/index.html')}) |`;
545
+ return `| [${escapeTableCell(pEx.Title)}](${mdSafeUrl(pEx.Name + '/README.md')}) | ${tmpComplexity} | ${escapeTableCell(pEx.Summary)} | [Launch](${mdSafeUrl('examples/' + pEx.Name + '/index.html')}) |`;
546
546
  });
547
547
  let tmpInner = [
548
548
  '| Example | Complexity | Summary | Live |',
@@ -584,7 +584,7 @@ class DocuserveCommandStageExamples extends libCommandLineCommand
584
584
  let tmpRows = pStaged.map((pEx) =>
585
585
  {
586
586
  let tmpComplexity = escapeTableCell(pEx.Complexity) || '—';
587
- return `| [${escapeTableCell(pEx.Title)}](${mdSafeUrl('examples/' + pEx.Name + '/README.md')}) | ${tmpComplexity} | [&#9654; Launch](${mdSafeUrl('examples/' + pEx.Name + '/index.html')}) |`;
587
+ return `| [${escapeTableCell(pEx.Title)}](${mdSafeUrl('examples/' + pEx.Name + '/README.md')}) | ${tmpComplexity} | [Launch](${mdSafeUrl('examples/' + pEx.Name + '/index.html')}) |`;
588
588
  });
589
589
  let tmpInner = [
590
590
  '| Example | Complexity | Launch |',
@@ -26,6 +26,20 @@ class DocuserveDocumentationProvider extends libPictProvider
26
26
 
27
27
  // Create an instance of the content provider for markdown parsing
28
28
  this._ContentProvider = this.pict.addProvider('Pict-Content', libPictContentProvider.default_configuration, libPictContentProvider);
29
+
30
+ // Register the GitHub mark icon scoped to docuserve (NOT pict core --
31
+ // most pict apps don't need it). Powers the topbar "view source" link.
32
+ // Official GitHub mark, painted with currentColor so it follows the theme.
33
+ if (this.pict && this.pict.providers && this.pict.providers.Icon && (typeof this.pict.providers.Icon.registerSet === 'function'))
34
+ {
35
+ this.pict.providers.Icon.registerSet(
36
+ {
37
+ Outline:
38
+ {
39
+ GitHub: '<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>'
40
+ }
41
+ });
42
+ }
29
43
  }
30
44
 
31
45
  /**
@@ -62,12 +76,15 @@ class DocuserveDocumentationProvider extends libPictProvider
62
76
  let tmpRoute = this.convertDocLink(tmpHref, pCurrentGroup, pCurrentModule, pCurrentDocPath);
63
77
  return { href: tmpRoute };
64
78
  }
65
- // Check if this is a GitHub URL that matches a catalog module
66
- let tmpCatalogRoute = this.resolveGitHubURLToRoute(tmpHref);
67
- if (tmpCatalogRoute)
68
- {
69
- return { href: tmpCatalogRoute };
70
- }
79
+ // GitHub URLs (github.com/org/repo, /blob/..., /issues, "Source"
80
+ // links, etc.) are intentionally left as external links and open on
81
+ // GitHub exactly as written. Earlier versions auto-rewrote any
82
+ // github.com URL that matched a catalog module into an internal #/doc/
83
+ // route, which "hijacked" Source / View-on-GitHub links and links to
84
+ // specific files or issues. Cross-module documentation references
85
+ // should instead use docuserve routes (e.g. /pict/pict-view/), which
86
+ // the rule above resolves through the catalog. resolveGitHubURLToRoute()
87
+ // remains available as an explicit utility for code that wants it.
71
88
  // Module mode: a remaining relative link (a directory, a media
72
89
  // file, a .json) is resolved against the current document's
73
90
  // directory too, so it shares the one base every other link uses
@@ -1579,6 +1596,49 @@ class DocuserveDocumentationProvider extends libPictProvider
1579
1596
  return null;
1580
1597
  }
1581
1598
 
1599
+ /**
1600
+ * Resolve the GitHub source-repository URL for a module.
1601
+ *
1602
+ * Returns a URL like https://github.com/fable-retold/pict-view. Used by
1603
+ * the docuserve topbar "view source" (octocat) link so every docs site
1604
+ * links back to the repo it documents. Honours a per-module Org field
1605
+ * when the catalog carries one (manifest-driven), else the catalog org.
1606
+ *
1607
+ * @param {string} pGroup - The group key
1608
+ * @param {string} pModule - The module name
1609
+ * @returns {string|null} The GitHub repository URL or null
1610
+ */
1611
+ resolveGitHubRepoURL(pGroup, pModule)
1612
+ {
1613
+ if (!this._Catalog || !this._Catalog.Groups)
1614
+ {
1615
+ return null;
1616
+ }
1617
+
1618
+ for (let i = 0; i < this._Catalog.Groups.length; i++)
1619
+ {
1620
+ let tmpGroup = this._Catalog.Groups[i];
1621
+ if (tmpGroup.Key !== pGroup)
1622
+ {
1623
+ continue;
1624
+ }
1625
+
1626
+ for (let j = 0; j < tmpGroup.Modules.length; j++)
1627
+ {
1628
+ let tmpModule = tmpGroup.Modules[j];
1629
+ if (tmpModule.Name !== pModule)
1630
+ {
1631
+ continue;
1632
+ }
1633
+
1634
+ let tmpOrg = tmpModule.Org || this._Catalog.GitHubOrg || 'stevenvelozo';
1635
+ return 'https://github.com/' + tmpOrg + '/' + tmpModule.Repo;
1636
+ }
1637
+ }
1638
+
1639
+ return null;
1640
+ }
1641
+
1582
1642
  /**
1583
1643
  * Get the module-specific sidebar entries for a given group/module.
1584
1644
  *
@@ -46,6 +46,17 @@ const _ViewConfiguration =
46
46
  background-color: var(--theme-color-background-hover, rgba(255, 255, 255, 0.06));
47
47
  color: var(--theme-color-text-on-brand, var(--theme-color-text-primary, #E8E0D4));
48
48
  }
49
+ .docuserve-user a.docuserve-repo-link
50
+ {
51
+ display: inline-flex;
52
+ align-items: center;
53
+ font-size: 1.15em;
54
+ padding: 0.35em 0.5em;
55
+ }
56
+ .docuserve-user a.docuserve-repo-link .docuserve-octocat
57
+ {
58
+ line-height: 0;
59
+ }
49
60
  `,
50
61
 
51
62
  Templates:
@@ -105,6 +116,26 @@ class DocuserveTopBarUserView extends libPictView
105
116
  tmpHTML += '<a href="' + tmpHref + '"' + (tmpIsExternal ? ' target="_blank" rel="noopener"' : '') + '>' + tmpText + '</a>';
106
117
  }
107
118
  }
119
+ // "View source" — octocat link to the current module's GitHub repo, so
120
+ // every docs site links back to the source it documents (fixed on a
121
+ // per-module site, follows the current module on the aggregate).
122
+ let tmpGroup = tmpDocuserve.CurrentGroup;
123
+ let tmpModule = tmpDocuserve.CurrentModule;
124
+ if (tmpGroup && tmpModule)
125
+ {
126
+ let tmpDocProvider = this.pict.providers['Docuserve-Documentation'];
127
+ let tmpRepoURL = (tmpDocProvider && (typeof tmpDocProvider.resolveGitHubRepoURL === 'function'))
128
+ ? tmpDocProvider.resolveGitHubRepoURL(tmpGroup, tmpModule)
129
+ : null;
130
+ if (tmpRepoURL)
131
+ {
132
+ let tmpIcon = this.pict.icon('GitHub', { class: 'docuserve-octocat', ariaLabel: 'View source on GitHub' });
133
+ tmpHTML += '<a class="docuserve-repo-link" href="' + this._escapeHTML(tmpRepoURL) + '"'
134
+ + ' target="_blank" rel="noopener"'
135
+ + ' title="View ' + this._escapeHTML(tmpModule) + ' source on GitHub">'
136
+ + tmpIcon + '</a>';
137
+ }
138
+ }
108
139
  tmpEl.innerHTML = tmpHTML;
109
140
  }
110
141