Skip to content

Commit 2cbfc00

Browse files
author
ganapatib
committed
Adjust Spring Antora UI to SAYA Platform
Use Lunr for client side search * Remove related projects * Adjust brand colors
1 parent db31255 commit 2cbfc00

36 files changed

+862
-758
lines changed

README.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22
<p align="center">
3-
<a href="https://www.spring.io/">
4-
<img alt="Spring" src="https://spring.io/img/spring-2.svg" width="250" />
3+
<a href="https://www.sayaplatform.com/">
4+
<img alt="SAYA Platform" src="https://www.sayaplatform.com/wp-content/uploads/2021/12/saya-logo-4.png" width="250" />
55
</a>
66
</p>
77

8-
[![On Push](https://github.com/spring-io/antora-ui-spring/actions/workflows/push.yml/badge.svg?branch=main)](https://github.com/spring-io/antora-ui-spring/actions/workflows/push.yml)
8+
[![On Push](https://github.com/3cortextechnologies/saya-antora-ui/actions/workflows/push.yml/badge.svg?branch=main)](https://github.com/3cortextechnologies/saya-antora-ui/actions/workflows/push.yml)
99

1010

11-
This project generates and packages the static resources that Spring uses for document production.
11+
This project generates and packages the static resources that SAYA uses for document production.
1212

13-
This project is based on [Antora](https://antora.org).
13+
This project is based on [Spring Antora UI](https://github.com/spring-io/antora-ui-spring).
1414

1515

1616
## Development Quickstart
@@ -20,15 +20,15 @@ A more comprehensive tutorial can be found in the documentation at [docs.antora.
2020

2121
### Prerequisites
2222

23-
To preview and bundle the Antora Spring UI, you need the following software on your computer:
23+
To preview and bundle the SAYA Antora UI, you need the following software on your computer:
2424

2525
* [git](https://git-scm.com/) (command: `git`)
2626
* [Node.js](https://nodejs.org/) (commands: `node` and `npm`)
2727
* [Gulp CLI](http://gulpjs.com/) (command: `gulp`)
2828

2929
### Preview the UI
3030

31-
The Spring Antora UI project is configured to preview offline.
31+
The SAYA Antora UI project is configured to preview offline.
3232
The files in the `preview-src/` folder provide the sample content that allow you to see the UI in action.
3333
In this folder, you'll primarily find pages written in AsciiDoc.
3434
These pages provide a representative sample and kitchen sink of content from the real site.
@@ -76,31 +76,6 @@ gulp bundle:pack
7676

7777
The UI bundle will again be available at `build/ui-bundle.zip`.
7878

79-
## Extensions to the UI
80-
81-
### Related Documentation
82-
83-
The UI presents a list of related documentation and that documentation can be filtered using two attributes:
84-
85-
* page-related-doc-categories - The categories to be included in the related documentation
86-
* page-related-doc-projects - The project ids to be included in the related documentation
87-
88-
For a complete listing of valid categories and ids view [related_projects.js](https://github.com/spring-io/antora-ui-spring/blob/main/src/helpers/related_projects.js)
89-
90-
The configuration is typically specified in asciidoc attributes section of the `antora-playbook.yml`:
91-
92-
```
93-
asciidoc:
94-
attributes:
95-
# Include the projects with the security category
96-
page-related-doc-categories: security
97-
# Include the projects with ids framework and graphql
98-
page-related-doc-projects: framework,graphql
99-
```
100-
101-
The Related Documentation links to the `All Docs...` page.
102-
To include this resource, ensure that the [antora-extensions](https://github.com/spring-io/antora-extensions/blob/main/README.adoc) is using 1.7.0+ and the [Static Page Extension](https://github.com/spring-io/antora-extensions/blob/main/README.adoc#static-page) is included.
103-
10479
## Authors
10580

10681
Development of Antora is led and sponsored by [OpenDevise Inc](https://opendevise.com/).
@@ -110,4 +85,3 @@ Development of Antora is led and sponsored by [OpenDevise Inc](https://opendevis
11085
Copyright (C) 2017-present OpenDevise Inc. and the Antora Project.
11186

11287
Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).
113-
See [LICENSE](https://github.com/spring-io/antora-ui-spring/blob/feat/gh-226/LICENSE) to find the full license text.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
'use strict'
2+
3+
const Asciidoctor = require('@asciidoctor/core')()
4+
const fs = require('fs')
5+
const { promises: fsp } = fs
6+
const ospath = require('path')
7+
const yaml = require('js-yaml')
8+
9+
module.exports = (src, previewSrc, previewDest) => async function buildPreviewSearchIndex () {
10+
const adocFiles = await collectAdocFiles(previewSrc)
11+
const docs = []
12+
13+
for (const adocPath of adocFiles) {
14+
const adocContents = await fsp.readFile(adocPath, 'utf8')
15+
const doc = Asciidoctor.load(adocContents, { safe: 'safe' })
16+
const title = doc.getDocumentTitle() || ospath.basename(adocPath, '.adoc')
17+
const html = doc.convert()
18+
const text = html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim()
19+
20+
const pageModel = await loadPageModel(adocPath)
21+
let url = (pageModel && pageModel.url) || ''
22+
23+
if (!url) {
24+
const rel = ospath.relative(previewSrc, adocPath).replace(/\\/g, '/')
25+
url = '/' + rel.replace(/\.adoc$/, '.html')
26+
}
27+
28+
const titles = extractSectionTitles(doc, text, title)
29+
30+
docs.push({ url, title, text, titles })
31+
}
32+
33+
const jsDir = previewDest
34+
await fsp.mkdir(jsDir, { recursive: true })
35+
36+
const indexJs = [
37+
'window.antoraLunr = window.antoraLunr || {};',
38+
'window.antoraLunr.docs = ' + JSON.stringify(docs, null, 2) + ';',
39+
'',
40+
].join('\n')
41+
42+
await fsp.writeFile(ospath.join(jsDir, 'search-index.js'), indexJs, 'utf8')
43+
}
44+
45+
function extractSectionTitles (doc, fullText, defaultTitle) {
46+
const titles = []
47+
48+
const sections = doc.findBy({ context: 'section' }) || []
49+
50+
sections.forEach((sect) => {
51+
const title = sect.getTitle && sect.getTitle()
52+
const id = sect.getId && sect.getId()
53+
const html = sect.convert()
54+
const text = html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim()
55+
56+
if (title || text) {
57+
titles.push({ id: id || null, title: title || defaultTitle, text })
58+
}
59+
})
60+
61+
if (!titles.length) {
62+
titles.push({ id: null, title: defaultTitle, text: fullText })
63+
}
64+
65+
return titles
66+
}
67+
68+
async function collectAdocFiles (dir) {
69+
const entries = await fsp.readdir(dir, { withFileTypes: true })
70+
const files = []
71+
72+
for (const entry of entries) {
73+
const fullPath = ospath.join(dir, entry.name)
74+
if (entry.isDirectory()) {
75+
files.push(...(await collectAdocFiles(fullPath)))
76+
} else if (entry.isFile() && entry.name.endsWith('.adoc')) {
77+
files.push(fullPath)
78+
}
79+
}
80+
81+
return files
82+
}
83+
84+
async function loadPageModel (adocPath) {
85+
const ymlPath = adocPath + '.yml'
86+
try {
87+
const contents = await fsp.readFile(ymlPath, 'utf8')
88+
return yaml.load(contents)
89+
} catch (e) {
90+
return undefined
91+
}
92+
}

gulpfile.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,15 @@ const buildPreviewPagesTask = createTask({
113113
call: task.buildPreviewPages(srcDir, previewSrcDir, previewDestDir, livereload),
114114
})
115115

116+
const buildPreviewSearchIndexTask = createTask({
117+
name: 'preview:build-search-index',
118+
call: task.buildPreviewSearchIndex(srcDir, previewSrcDir, previewDestDir),
119+
})
120+
116121
const previewBuildTask = createTask({
117122
name: 'preview:build',
118123
desc: 'Process and stage the UI assets and generate pages for the preview',
119-
call: parallel(buildTask, buildPreviewPagesTask),
124+
call: parallel(buildTask, buildPreviewPagesTask, buildPreviewSearchIndexTask),
120125
})
121126

122127
const previewServeTask = createTask({

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
2-
"name": "antora-ui-spring",
3-
"description": "Produces the UI bundle for projects on docs.spring.io that are built with Antora",
4-
"homepage": "https://docs.spring.io",
5-
"license": "MPL-2.0",
2+
"name": "saya-antora-ui",
3+
"description": "Produces the UI bundle for projects on sayadev.3cortex.com/docs that are built with Antora",
4+
"homepage": "https://sayaplatform.com",
65
"repository": {
76
"type": "git",
8-
"url": "https://github.com/spring-io/antora-ui-spring"
7+
"url": "https://github.com/3cortextechnologies/saya-antora-ui"
98
},
109
"scripts": {
1110
"start": "gulp preview",

preview-src/samples/content/index.adoc

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Content after
6767

6868
=== URLs
6969

70-
The homepage for the Asciidoctor Project is https://asciidoctor.org.
70+
The homepage for the Asciidoctor Project is https://asciidoctor.org.
7171

7272
Ask questions on the http://discuss.asciidoctor.org/[*mailing list*].
7373

@@ -82,10 +82,10 @@ The hail-and-rainbow protocol can be initiated at five levels:
8282
double, tertiary, supernumerary, supermassive, and apocalyptic party.
8383
A bold statement!
8484

85-
Another outrageous statement.footnote:disclaimer[]
85+
Another outrageous statement.footnote:disclaimer[]
8686

87-
footnote:[The double hail-and-rainbow level makes my toes tingle.]
88-
footnote:disclaimer[Opinions are my own.]
87+
footnote:[The double hail-and-rainbow level makes my toes tingle.]
88+
footnote:disclaimer[Opinions are my own.]
8989

9090

9191
[.impact]
@@ -95,10 +95,10 @@ footnote:disclaimer[Opinions are my own.]
9595

9696
==== Alone
9797

98-
[#img-sunset]
99-
.A mountain sunset
100-
[link=https://www.flickr.com/photos/javh/5448336655]
101-
image::/_/img/spring-logo.svg[Spring,300,200]
98+
[#img-sunset]
99+
.A mountain sunset
100+
[link=https://www.flickr.com/photos/javh/5448336655]
101+
image::/_/images/saya-logo.png[Spring,300,200]
102102

103103
==== Inline
104104

@@ -115,32 +115,32 @@ You can find image:https://upload.wikimedia.org/wikipedia/commons/3/35/Tux.svg[L
115115
--
116116
[.left]
117117
.Image A
118-
image::/_/img/spring-logo.svg[A,240,180]
118+
image::/_/images/saya-logo.png[A,240,180]
119119

120120
[.left]
121121
.Image B
122-
image::/_/img/spring-logo.svg[B,240,180]
122+
image::/_/images/saya-logo.png[B,240,180]
123123
--
124124

125125
Text below images.
126126

127127

128128
=== Sizing images (1)
129129

130-
image::/_/img/spring-logo.svg[Spring,640,480]
130+
image::/_/images/saya-logo.png[Spring,640,480]
131131

132132
=== Sizing images (2)
133133

134-
image::/_/img/spring-logo.svg[Spring,50%]
134+
image::/_/images/saya-logo.png[Spring,50%]
135135

136136

137137
=== Taming SVGs
138138

139-
image::/_/img/spring-logo.svg[Static,300]
139+
image::/_/images/saya-logo.png[Static,300]
140140

141-
image::/_/img/spring-logo.svg[Interactive,300,opts=interactive]
141+
image::/_/images/saya-logo.png[Interactive,300,opts=interactive]
142142

143-
image::/_/img/spring-logo.svg[Embedded,300,opts=inline]
143+
image::/_/images/saya-logo.png[Embedded,300,opts=inline]
144144

145145
=== Image invert dark mode
146146

@@ -158,9 +158,9 @@ But **u**ltimate victory could only be won if we divined the *_true name_* of th
158158

159159
=== Quotation Marks and Apostrophes
160160

161-
"`What kind of charm?`" Lazarus asked. "`An odoriferous one or a mineral one?`"
161+
"`What kind of charm?`" Lazarus asked. "`An odoriferous one or a mineral one?`"
162162

163-
Kizmet shrugged. "`The note from Olaf's desk says '`wormwood and licorice,`' but these could be normal groceries for werewolves.`"
163+
Kizmet shrugged. "`The note from Olaf's desk says '`wormwood and licorice,`' but these could be normal groceries for werewolves.`"
164164

165165
=== Subscript and Superscript
166166

@@ -460,7 +460,7 @@ fun doFilter(request: ServletRequest, response: ServletResponse, chain: FilterCh
460460

461461
==== Multi-lines
462462

463-
[IMPORTANT]
463+
[IMPORTANT]
464464
.title
465465
====
466466
This is an important admonition
@@ -599,8 +599,8 @@ This is a stem block.
599599

600600
==== Multi-lines
601601

602-
.Gettysburg Address
603-
[quote, Abraham Lincoln, Address delivered at the dedication of the Cemetery at Gettysburg]
602+
.Gettysburg Address
603+
[quote, Abraham Lincoln, Address delivered at the dedication of the Cemetery at Gettysburg]
604604
____
605605
Four score and seven years ago our fathers brought forth
606606
on this continent a new nation...
@@ -643,8 +643,8 @@ But nothing can be changed until it is faced.
643643

644644
==== Multi-lines
645645

646-
.AsciiDoc history
647-
****
646+
.AsciiDoc history
647+
****
648648
AsciiDoc was first released in Nov 2002 by Stuart Rackham.
649649
It was designed from the start to be a shorthand syntax
650650
for producing professional documents like DocBook and LaTeX.
@@ -686,15 +686,15 @@ on little cat feet.
686686

687687
=== Simple table
688688

689-
|====
689+
|====
690690

691-
| Cell in column 1, row 1 | Cell in column 2, row 1
691+
| Cell in column 1, row 1 | Cell in column 2, row 1
692692

693693
| Cell in column 1, row 2 | Cell in column 2, row 2
694694

695695
| Cell in column 1, row 3 | Cell in column 2, row 3
696696

697-
|====
697+
|====
698698

699699

700700
=== Number of columns

src/css/main.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
margin: 0 auto;
4848
}
4949

50-
#springlogo,
51-
#springlogo-foot {
50+
#sayalogo,
51+
#sayalogo-foot {
5252
height: 45px;
5353
max-width: 250px;
5454
}
@@ -280,7 +280,7 @@ html.dark-theme #modal-versions .version-toggle span {
280280
}
281281

282282
#modal-versions .current {
283-
background-color: #80ea6e;
283+
background-color: #df3d80;
284284
color: #111;
285285
align-items: center;
286286
border-radius: 4px;

src/css/modal.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
padding: 3rem;
126126
}
127127
.modal__container {
128-
max-width: 600px;
128+
max-width: 720px;
129129
min-width: 50%;
130130
width: auto;
131131
}

0 commit comments

Comments
 (0)