Skip to content

Commit 79c8d2f

Browse files
authored
Merge pull request #50 from openapi-processor/master-merge
merge update from original
2 parents 1d0d582 + 898050f commit 79c8d2f

64 files changed

Lines changed: 5825 additions & 15488 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
"imports": "always-multiline",
99
"exports": "always-multiline"
1010
}],
11+
"no-restricted-properties": ["error", {
12+
"property": "substr",
13+
"message": "Use String#slice instead."
14+
}],
1115
"max-len": [1, 120, 2],
12-
"spaced-comment": "off"
16+
"spaced-comment": "off",
17+
"radix": ["error", "always"]
1318
}
1419
}

README.adoc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ You can see a preview of the default UI at {url-preview}.
2727
While the default UI is ready to be used with Antora, the intent is that you'll fork it and customize it for your own needs.
2828
It's intentionally minimalistic so as to give you a good starting point without requiring too much effort to customize.
2929

30+
== Code of Conduct
31+
32+
The Antora project and its project spaces are governed by our https://gitlab.com/antora/antora/-/blob/HEAD/CODE-OF-CONDUCT.adoc[Code of Conduct].
33+
By participating, you're agreeing to honor this code.
34+
Let's work together to make this a welcoming, professional, inclusive, and safe environment for everyone.
35+
3036
== Use the Default UI
3137

3238
If you want to simply use the default UI for your Antora-generated site, add the following UI configuration to your playbook:
@@ -35,7 +41,7 @@ If you want to simply use the default UI for your Antora-generated site, add the
3541
----
3642
ui:
3743
bundle:
38-
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/master/raw/build/ui-bundle.zip?job=bundle-stable
44+
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable
3945
snapshot: true
4046
----
4147

@@ -112,7 +118,7 @@ If you prefer to install global packages using Yarn, run this command instead:
112118

113119
Alternately, you can use the `gulp` command that is installed by the project's dependencies.
114120

115-
$ $(npm bin)/gulp --version
121+
$ npx --offline gulp --version
116122

117123
Now that you have the prerequisites installed, you can fetch and build the UI project.
118124

@@ -195,15 +201,15 @@ These map files sit adjacent to the combined files in the build folder.
195201
The mapping they provide allows the debugger to present the original source rather than the obfuscated file, an essential tool for debugging.
196202

197203
In preview mode, source maps are enabled automatically, so there's nothing you have to do to make use of them.
198-
If you need to include source maps in the bundle, you can do so by setting the `SOURCEMAPS` environment varible to `true` when you run the bundle command:
204+
If you need to include source maps in the bundle, you can do so by setting the `SOURCEMAPS` environment variable to `true` when you run the bundle command:
199205

200206
$ SOURCEMAPS=true gulp bundle
201207

202-
In this case, the bundle will include the source maps, which can be used for debuggging your production site.
208+
In this case, the bundle will include the source maps, which can be used for debugging your production site.
203209

204210
== Copyright and License
205211

206-
Copyright (C) 2017-2019 OpenDevise Inc. and the Antora Project.
212+
Copyright (C) 2017-present OpenDevise Inc. and the Antora Project.
207213

208214
Use of this software is granted under the terms of the https://www.mozilla.org/en-US/MPL/2.0/[Mozilla Public License Version 2.0] (MPL-2.0).
209215
See link:LICENSE[] to find the full license text.

docs/antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: antora-ui-default
22
title: Antora Default UI
3-
version: master
3+
version: ~
44
nav:
55
- modules/ROOT/nav.adoc
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
'use strict'
2+
3+
module.exports = (numOfItems, { data }) => {
4+
const { contentCatalog, site } = data.root
5+
if (!contentCatalog) return
6+
const rawPages = getDatedReleaseNotesRawPages(contentCatalog)
7+
const pageUiModels = turnRawPagesIntoPageUiModels(site, rawPages, contentCatalog)
8+
return getMostRecentlyUpdatedPages(pageUiModels, numOfItems)
9+
}
10+
11+
let buildPageUiModel
12+
13+
function getDatedReleaseNotesRawPages (contentCatalog) {
14+
return contentCatalog.getPages(({ asciidoc, out }) => {
15+
if (!asciidoc || !out) return
16+
return getReleaseNotesWithRevdate(asciidoc)
17+
})
18+
}
19+
20+
function getReleaseNotesWithRevdate (asciidoc) {
21+
const attributes = asciidoc.attributes
22+
return asciidoc.attributes && isReleaseNotes(attributes) && hasRevDate(attributes)
23+
}
24+
25+
function isReleaseNotes (attributes) {
26+
return attributes['page-component-name'] === 'release-notes'
27+
}
28+
29+
function hasRevDate (attributes) {
30+
return 'page-revdate' in attributes
31+
}
32+
33+
function turnRawPagesIntoPageUiModels (site, pages, contentCatalog) {
34+
buildPageUiModel ??= module.parent.require('@antora/page-composer/build-ui-model').buildPageUiModel
35+
return pages
36+
.map((page) => buildPageUiModel(site, page, contentCatalog))
37+
.filter((page) => isValidDate(page.attributes?.revdate))
38+
.sort(sortByRevDate)
39+
}
40+
41+
function isValidDate (dateStr) {
42+
return !isNaN(Date.parse(dateStr))
43+
}
44+
45+
function sortByRevDate (a, b) {
46+
return new Date(b.attributes.revdate) - new Date(a.attributes.revdate)
47+
}
48+
49+
function getMostRecentlyUpdatedPages (pageUiModels, numOfItems) {
50+
return getResultList(pageUiModels, Math.min(pageUiModels.length, numOfItems))
51+
}
52+
53+
function getResultList (pageUiModels, maxNumberOfPages) {
54+
const resultList = []
55+
for (let i = 0; i < maxNumberOfPages; i++) {
56+
const page = pageUiModels[i]
57+
if (page.attributes?.revdate) resultList.push(getSelectedAttributes(page))
58+
}
59+
return resultList
60+
}
61+
62+
function getSelectedAttributes (page) {
63+
const latestVersion = getLatestVersion(page.contents.toString())
64+
return {
65+
latestVersionAnchor: latestVersion?.anchor,
66+
latestVersionName: latestVersion?.innerText,
67+
revdateWithoutYear: removeYear(page.attributes?.revdate),
68+
title: cleanTitle(page.title),
69+
url: page.url,
70+
}
71+
}
72+
73+
function getLatestVersion (contentsStr) {
74+
const firstVersion = contentsStr.match(/<h2 id="([^"]+)">(.+?)<\/h2>/)
75+
if (!firstVersion) return
76+
const result = { anchor: firstVersion[1] }
77+
if (isVersion(firstVersion[2])) result.innerText = firstVersion[2]
78+
return result
79+
}
80+
81+
function isVersion (versionText) {
82+
return /^[0-9]+\.[0-9]+(?:\.[0-9]+)?/.test(versionText)
83+
}
84+
85+
function removeYear (dateStr) {
86+
if (!isValidDate(dateStr)) return
87+
const dateObj = new Date(dateStr)
88+
return `${dateObj.toLocaleString('default', { month: 'short' })} ${dateObj.getDate()}`
89+
}
90+
91+
function cleanTitle (title) {
92+
return title.split('Release Notes')[0].trim()
93+
}

docs/modules/ROOT/nav.adoc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
* xref:prerequisites.adoc[UI Development Prerequisites]
2-
* xref:set-up-project.adoc[Set up a UI Project]
3-
* xref:build-preview-ui.adoc[Build and Preview the UI]
4-
* xref:development-workflow.adoc[UI Development Workflow]
5-
* xref:templates.adoc[Work with the Handlebars Templates]
6-
* xref:stylesheets.adoc[Work with the CSS Stylesheets]
7-
** xref:add-fonts.adoc[Add Fonts]
8-
* xref:style-guide.adoc[UI Element Styles]
9-
** xref:inline-text-styles.adoc[Inline Text]
10-
** xref:admonition-styles.adoc[Admonitions]
11-
** xref:list-styles.adoc[Lists]
12-
** xref:sidebar-styles.adoc[Sidebars]
13-
** xref:ui-macro-styles.adoc[UI Macros]
1+
* xref:prerequisites.adoc[]
2+
* xref:set-up-project.adoc[]
3+
* xref:build-preview-ui.adoc[]
4+
* xref:development-workflow.adoc[]
5+
* xref:templates.adoc[]
6+
** xref:template-customization.adoc[]
7+
** xref:create-helper.adoc[]
8+
* xref:add-static-files.adoc[]
9+
* xref:stylesheets.adoc[]
10+
** xref:add-fonts.adoc[]
11+
* xref:style-guide.adoc[]
12+
** xref:inline-text-styles.adoc[]
13+
** xref:image-styles.adoc[]
14+
** xref:admonition-styles.adoc[]
15+
** xref:code-blocks.adoc[]
16+
** xref:list-styles.adoc[]
17+
** xref:sidebar-styles.adoc[]
18+
** xref:ui-macro-styles.adoc[]

docs/modules/ROOT/pages/add-fonts.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Here are the steps involved.
2121

2222
. Use npm (or Yarn) to install the font files from a package (e.g., https://www.npmjs.com/package/typeface-open-sans[typeface-open-sans])
2323

24-
$ npm install --save typeface-open-sans
24+
$ npm i --save typeface-open-sans
2525

2626
. In [.path]_src/css_, add a corresponding CSS file (e.g., [.path]_typeface-open-sans.css_)
2727
. In that file, declare the font face:
@@ -64,7 +64,7 @@ TIP: If you're building on the default UI, you may instead want to define or upd
6464

6565
. Test the new font by previewing your UI:
6666

67-
$ gulp preview
67+
$ npx gulp preview
6868

6969
If you see the new font, you've now successfully added it to your UI.
7070
If you aren't sure, look for the https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Edit_fonts[All fonts on page] section in your browser's developer tools to see whether the font was loaded.
@@ -117,7 +117,7 @@ TIP: If you're building on the default UI, you may instead want to define or upd
117117

118118
. Test the new font by previewing your UI:
119119

120-
$ gulp preview
120+
$ npx gulp preview
121121

122122
If you see the new font, you've now successfully added it to your UI.
123123
If you aren't sure, look for the https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Edit_fonts[All fonts on page] section in your browser's developer tools to see whether the font was loaded.

0 commit comments

Comments
 (0)