Skip to content

Commit 42d85f6

Browse files
authored
Add tabset and update dependencies (#16)
* Use asciidoctor/tabs and update other packages
1 parent be47b15 commit 42d85f6

File tree

17 files changed

+4323
-2758
lines changed

17 files changed

+4323
-2758
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v3
2323
- uses: actions/setup-node@v3
2424
with:
25-
node-version: 10
25+
node-version: 14
2626
cache: npm
2727
- run: |
2828
npm install
@@ -35,7 +35,7 @@ jobs:
3535
- uses: actions/checkout@v3
3636
- uses: actions/setup-node@v3
3737
with:
38-
node-version: 10
38+
node-version: 14
3939
cache: npm
4040
- run: |
4141
npm install
@@ -51,7 +51,7 @@ jobs:
5151
- uses: actions/checkout@v3
5252
- uses: actions/setup-node@v3
5353
with:
54-
node-version: 10
54+
node-version: 14
5555
cache: npm
5656
- run: |
5757
npm install

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/build/
2-
/node_modules/
2+
**/node_modules/**
33
/public/

antora-ui.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
sources:
3-
- path: '@djencks/tabset-block-ui'
43
- path: ./
54
css:
65
- site.css
6+
- target: vendor/tabs
7+
require: '@asciidoctor/tabs/dist/css/tabs.css'
78
js:
89
- target: site
910
contents: '+([0-9])-*.js'
@@ -13,6 +14,9 @@ js:
1314
require: bootstrap/dist/js/bootstrap.bundle.js
1415
- target: vendor/tippy
1516
require: tippy.js/dist/tippy.umd.min.js
17+
- target: vendor/tabs
18+
require: '@asciidoctor/tabs/dist/js/tabs.js'
19+
1620
bundle-name: ui
1721
preview: true
1822
...

asciinema-macro/.eslintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "standard",
3+
"rules": {
4+
"arrow-parens": ["error", "always"],
5+
"comma-dangle": ["error", {
6+
"arrays": "always-multiline",
7+
"objects": "always-multiline",
8+
"imports": "always-multiline",
9+
"exports": "always-multiline"
10+
}],
11+
"max-len": ["error", {
12+
"code": 120,
13+
"ignoreStrings": true,
14+
"ignoreUrls": true,
15+
"ignoreTemplateLiterals": true
16+
}],
17+
"spaced-comment": "off"
18+
}
19+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
const createDiv = function (target, attrs) {
3+
const theme = attrs.theme ? attrs.theme : 'solarized-light'
4+
const autoplay = attrs.autoplay ? attrs.autoplay : 'true'
5+
const loop = attrs.loop ? attrs.loop : 'true'
6+
const asciiDiv = `<div id="${target}" class="openblock"></div>`
7+
const props = `{loop: ${loop}, theme: '${theme}', autoplay: ${autoplay}, controls: false}`
8+
const asciiScript = `AsciinemaPlayer.create('./_images/${target}.cast', document.getElementById('${target}'), ${props});`
9+
return `${asciiDiv}<script>${asciiScript}</script>`
10+
}
11+
12+
const asciinemaMacro = function () {
13+
const self = this
14+
15+
self.named('asciinema')
16+
self.positionalAttributes(['theme', 'autoplay', 'loop'])
17+
18+
self.process(function (parent, target, attrs) {
19+
const html = createDiv(target, attrs)
20+
return self.createBlock(parent, 'pass', html, attrs, {})
21+
})
22+
}
23+
24+
module.exports.register = function (registry) {
25+
function doRegister (registry) {
26+
if (typeof registry.blockMacro === 'function') {
27+
registry.blockMacro(asciinemaMacro)
28+
} else {
29+
console.warn('no \'blockMacro\' method on alleged registry')
30+
}
31+
}
32+
33+
if (typeof registry.register === 'function') {
34+
registry.register(function () {
35+
registry = this
36+
doRegister(registry)
37+
})
38+
} else {
39+
doRegister(registry)
40+
}
41+
return registry
42+
}

asciinema-macro/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@simonhkswan/asciinema-macro",
3+
"version": "0.2.0",
4+
"description": "Asciidoctor asciinema macro extension",
5+
"main": "lib/asciinema-macro.js",
6+
"files": [
7+
"lib/*.js"
8+
],
9+
"scripts": {
10+
"lint": "eslint lib/*.js",
11+
"lint-fix": "eslint lib/*.js --fix"
12+
},
13+
"devDependencies": {
14+
"@antora/content-classifier": "^3.0.3",
15+
"@asciidoctor/core": "^2.2.0",
16+
"chai": "~4.2",
17+
"chai-cheerio": "~1.0",
18+
"chai-fs": "~2.0",
19+
"chai-spies": "~1.0",
20+
"cheerio": "1.0.0-rc.3",
21+
"dirty-chai": "~2.0",
22+
"eslint": "~6.7",
23+
"eslint-config-standard": "~14.1",
24+
"eslint-plugin-import": "~2.19",
25+
"eslint-plugin-node": "~10.0",
26+
"eslint-plugin-promise": "~4.2",
27+
"eslint-plugin-standard": "~4.0",
28+
"prettier-eslint-cli": "~5.0"
29+
},
30+
"keywords": [
31+
"asciidoctor",
32+
"asciinema",
33+
"javascript",
34+
"extension"
35+
],
36+
"author": "Simon Swan (https://github.com/simonhkswan)",
37+
"license": "MIT"
38+
}

gulp.d/tasks/build-preview-pages.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Error.call = (self, ...args) => {
66
return Object.assign(self, { message: err.message, stack: err.stack })
77
}
88

9-
const asciidoctor = require('asciidoctor.js')()
9+
const Asciidoctor = require('@asciidoctor/core')()
1010
const fs = require('fs-extra')
1111
const handlebars = require('handlebars')
1212
const merge = require('merge-stream')
@@ -27,7 +27,21 @@ module.exports = (src, previewSrc, previewDest, sink = () => map()) => (done) =>
2727
merge(compileLayouts(src), registerPartials(src), registerHelpers(src), copyImages(previewSrc, previewDest))
2828
),
2929
])
30-
.then(([baseUiModel, { layouts }]) => [{ ...baseUiModel, env: process.env }, layouts])
30+
.then(([baseUiModel, { layouts }]) => {
31+
const extensions = ((baseUiModel.asciidoc || {}).extensions || []).map((request) => {
32+
ASCIIDOC_ATTRIBUTES[request.replace(/^@|\.js$/, '').replace(/[/]/g, '-') + '-loaded'] = ''
33+
const extension = require(request)
34+
extension.register(Asciidoctor.Extensions)
35+
return extension
36+
})
37+
const asciidoc = { extensions }
38+
for (const component of baseUiModel.site.components) {
39+
for (const version of component.versions || []) version.asciidoc = asciidoc
40+
}
41+
baseUiModel = { ...baseUiModel, env: process.env }
42+
delete baseUiModel.asciidoc
43+
return [baseUiModel, layouts]
44+
})
3145
.then(([baseUiModel, layouts]) =>
3246
vfs
3347
.src('**/*.adoc', { base: previewSrc, cwd: previewSrc })
@@ -42,7 +56,7 @@ module.exports = (src, previewSrc, previewDest, sink = () => map()) => (done) =>
4256
if (file.stem === '404') {
4357
uiModel.page = { layout: '404', title: 'Page Not Found' }
4458
} else {
45-
const doc = asciidoctor.load(file.contents, { safe: 'safe', attributes: ASCIIDOC_ATTRIBUTES })
59+
const doc = Asciidoctor.load(file.contents, { safe: 'safe', attributes: ASCIIDOC_ATTRIBUTES })
4660
uiModel.page.attributes = Object.entries(doc.getAttributes())
4761
.filter(([name, val]) => name.startsWith('page-'))
4862
.reduce((accum, [name, val]) => {
@@ -110,7 +124,7 @@ function compileLayouts (src) {
110124

111125
function copyImages (src, dest) {
112126
return vfs
113-
.src('**/*.{png,svg}', { base: src, cwd: src })
127+
.src('**/*.{png,svg,cast}', { base: src, cwd: src })
114128
.pipe(vfs.dest(dest))
115129
.pipe(map((file, enc, next) => next()))
116130
}

0 commit comments

Comments
 (0)