Skip to content

Commit a535c94

Browse files
authored
upgrade site to Antora 3 and leverage latest version segment feature to manage current URL (PR #287)
1 parent 512f7a8 commit a535c94

16 files changed

+455
-1498
lines changed

Dockerfile.jenkins

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# This image extends the official Antora image to add bash, ca-certificates, and the aws command. It's used by the CI job.
2-
FROM antora/antora:2.3.4
2+
FROM antora/antora:3.0.0-alpha.1
33

44
ARG GROUP_ID=1000
55
ARG USER_ID=1000
66
RUN addgroup -g $GROUP_ID jenkins && \
77
adduser -D -u $USER_ID -G jenkins jenkins && \
88
apk add --no-cache --quiet bash ca-certificates git openssh-client python && \
9-
yarn global add --ignore-optional --silent git+https://gitlab.com/opendevise/oss/antora-site-generator-ms#v2.3.4 && \
10-
yarn global add --ignore-optional --silent git+https://gitlab.com/antora/xref-validator#v1.0.0-alpha.12 && \
9+
yarn global add --ignore-optional --silent git+https://gitlab.com/opendevise/oss/antora-site-generator-ms#v3.0.0-alpha.1 && \
10+
yarn global add --ignore-optional --silent git+https://gitlab.com/antora/xref-validator#v1.0.0-alpha.13 && \
1111
apk add --no-cache --quiet --virtual .build-deps py2-pip && \
1212
pip install --no-cache-dir --quiet --disable-pip-version-check awscli && \
1313
apk del --no-cache --quiet --purge .build-deps

Jenkinsfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pipeline {
5151
OPTANON_SCRIPT_DATA_DOMAIN_SCRIPT = "748511ff-10bf-44bf-88b8-36382e5b5fd9"
5252
NODE_PATH='/usr/local/share/.config/yarn/global/node_modules'
5353
SHOW_FEEDBACK_BUTTON='true'
54-
SUPPORTS_CURRENT_URL='true'
5554
}
5655
triggers {
5756
githubPush()

antora-playbook.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ site:
88
google_analytics: GTM-MVPNN2
99
git:
1010
ensure_git_suffix: false
11+
urls:
12+
latest_version_segment: current
13+
latest_version_segment_strategy: redirect:to
1114
content:
1215
branches: master
1316
# NOTE the git@ segment in the URL indicates which repositories are private
@@ -116,6 +119,6 @@ asciidoc:
116119
- ./lib/tabs-block.js
117120
ui:
118121
bundle:
119-
url: https://github.com/couchbase/docs-ui-sandbox/releases/download/prod-82/ui-bundle.zip
122+
url: https://github.com/couchbase/docs-ui-sandbox/releases/download/prod-83/ui-bundle.zip
120123
output:
121124
dir: ./public

etc/nginx/snippets/rewrites.conf

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,8 @@ set $current_version_sdk_ruby_api '3.0.0';
2727
set $current_version_sdk_scala '1.0';
2828
set $current_version_sdk_scala_api '1.0.8';
2929
set $current_version_txns_java_api '1.1.0';
30-
31-
# current URL cloaks
32-
location ^~ /server/current/ { rewrite ^/(server)/current/(.*)$ /$1/$current_version_server/$2 last; }
33-
location ^~ /operator/current/ { rewrite ^/(operator)/current/(.*)$ /$1/$current_version_operator/$2 last; }
34-
location ^~ /couchbase-lite/current/ { rewrite ^/(couchbase-lite)/current/(.*)$ /$1/$current_version_couchbase_lite/$2 last; }
35-
location ^~ /sync-gateway/current/ { rewrite ^/(sync-gateway)/current/(.*)$ /$1/$current_version_sync_gateway/$2 last; }
36-
location ^~ /c-sdk/current/ { rewrite ^/(c-sdk)/current/(.*)$ /$1/$current_version_sdk_c/$2 last; }
37-
location ^~ /dotnet-sdk/current/ { rewrite ^/(dotnet-sdk)/current/(.*)$ /$1/$current_version_sdk_dotnet/$2 last; }
38-
location ^~ /go-sdk/current/ { rewrite ^/(go-sdk)/current/(.*)$ /$1/$current_version_sdk_go/$2 last; }
39-
location ^~ /java-sdk/current/ { rewrite ^/(java-sdk)/current/(.*)$ /$1/$current_version_sdk_java/$2 last; }
40-
location ^~ /nodejs-sdk/current/ { rewrite ^/(nodejs-sdk)/current/(.*)$ /$1/$current_version_sdk_nodejs/$2 last; }
41-
location ^~ /php-sdk/current/ { rewrite ^/(php-sdk)/current/(.*)$ /$1/$current_version_sdk_php/$2 last; }
42-
location ^~ /python-sdk/current/ { rewrite ^/(python-sdk)/current/(.*)$ /$1/$current_version_sdk_python/$2 last; }
43-
location ^~ /scala-sdk/current/ { rewrite ^/(scala-sdk)/current/(.*)$ /$1/$current_version_sdk_scala/$2 last; }
44-
location ^~ /elasticsearch-connector/current/ { rewrite ^/(elasticsearch-connector)/current/(.*)$ /$1/$current_version_connector_elasticsearch/$2 last; }
45-
location ^~ /kafka-connector/current/ { rewrite ^/(kafka-connector)/current/(.*)$ /$1/$current_version_connector_kafka/$2 last; }
46-
location ^~ /spark-connector/current/ { rewrite ^/(spark-connector)/current/(.*)$ /$1/$current_version_connector_spark/$2 last; }
30+
# current URL cloaks are now handled by Antora
31+
# -
4732
# archived version redirects (must use longest prefix since nginx executes regexp locations out of order)
4833
location ^~ /server/4.0/ { rewrite ^/([^/]+)/[^/]+/(.*)$ /$1/current/$2 redirect; }
4934
location ^~ /server/4.1/ { rewrite ^/([^/]+)/[^/]+/(.*)$ /$1/current/$2 redirect; }

lib/inline-man-macro.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
*/
2020
const { posix: path } = require('path')
2121

22-
function initInlineManMacro (context) {
22+
function initInlineManMacro ({ file }) {
2323
return function () {
2424
this.process((parent, target, attrs) => {
2525
const text = target.startsWith('couchbase-cli-') ? target.substr(14) : target
26-
const refid = path.join(path.dirname(context.file.src.relative), target)
26+
const refid = path.join(path.dirname(file.src.relative), target)
2727
const attributes = Opal.hash2(['refid', 'path'], { refid, path: refid + '.adoc' })
2828
return this.createInline(parent, 'anchor', text, { type: 'xref', target: refid + '.adoc', attributes })
2929
})

lib/json-config-ui-block-macro.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ function blockJsonConfigUiMacro ({ file }) {
1919
configUrl = doc.$sub_attributes(configUrl, Opal.hash({ attribute_missing: 'drop-line' }))
2020
if (!configUrl) return
2121
}
22-
const version = attrs.$$is_hash ? Opal.hash_get(attrs, 'version') : attrs.version
23-
const contentScripts = buildJsonConfigUi({ configUrl, version, bundleBaseUrl: BUNDLE_BASE_URL })
24-
if ((file.asciidoc || {}).attributes) file.asciidoc.attributes['page-content-scripts'] = contentScripts
25-
Opal.hash_put(doc.header_attributes, 'page-content-scripts', contentScripts) // Antora 2.2
22+
const contentScripts = buildJsonConfigUi({ configUrl, version: attrs.version, bundleBaseUrl: BUNDLE_BASE_URL })
23+
file.asciidoc.attributes['page-content-scripts'] = contentScripts
2624
return this.createBlock(parent, 'pass', '<div id="swagger-ui"></div>')
2725
})
2826
}

lib/multirow-table-head-tree-processor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function multirowTableHeadTreeProcessor () {
22
this.process((doc) => {
3-
for (let table of doc.findBy({ context: 'table' })) {
3+
for (const table of doc.findBy({ context: 'table' })) {
44
const hrows = table.getAttribute('hrows')
55
if (hrows) {
66
const rows = table.rows
@@ -11,8 +11,8 @@ function multirowTableHeadTreeProcessor () {
1111
})
1212
}
1313

14-
function register (registry, context) {
15-
if (context.file.contents.includes('hrows=')) {
14+
function register (registry, { file }) {
15+
if (file.contents.includes('hrows=')) {
1616
registry.treeProcessor(multirowTableHeadTreeProcessor)
1717
}
1818
}

lib/source-url-include-processor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function initSourceUrlIncludeProcessor ({ file, contentCatalog }) {
2323
const includeFileSrc = includeFile.context
2424
let sourceUrl = includeFileSrc.editUrl.replace(`/edit/${includeFileSrc.origin.branch}`, `/blob/${includeFileSrc.origin.refhash}`) + resolveLineRangeFragment(includeFile.contents, attrs)
2525
reader.pushInclude(`[data-source-url=${sourceUrl}]\n`, target, target, 1, attrs)
26+
// NOTE: this assignment works since the attribute is only used internally by this extension
2627
Opal.hash_put(doc.header_attributes, 'promote-data-source-url', '')
2728
})
2829
}

lib/swagger-ui-block-macro.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ function blockSwaggerUiMacro ({ file }) {
6565
? 'https://cb-docs-swagger.s3.amazonaws.com/dist3'
6666
: 'https://couchbase-docs.s3.amazonaws.com/assets/swagger-ui-3.7'
6767
const contentScripts = buildSwaggerUi({ specUrl, bundleUrl })
68-
if ((file.asciidoc || {}).attributes) file.asciidoc.attributes['page-content-scripts'] = contentScripts
69-
Opal.hash_put(doc.header_attributes, 'page-content-scripts', contentScripts) // Antora 2.2
68+
file.asciidoc.attributes['page-content-scripts'] = contentScripts
7069
return this.createBlock(parent, 'pass', '<div id="swagger-ui"></div>')
7170
})
7271
}

lib/tabs-block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function tabsBlock () {
7373
})
7474
}
7575

76-
function register (registry, context) {
76+
function register (registry) {
7777
registry.block('tabs', tabsBlock)
7878
}
7979

netlify/netlify.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ ignore = "false"
44

55
[build.environment]
66
CI = "true"
7-
NODE_VERSION = "12"
7+
NODE_VERSION = "10"
8+
NODE_OPTIONS = "--max-old-space-size=4096"
89
NPM_FLAGS = "--no-optional"
910
ANTORA_CACHE_DIR = "node_modules/.cache/antora"
10-
SUPPORTS_CURRENT_URL="true"
1111

1212
# NOTE branch-deploy refers to the master branch
1313

@@ -22,9 +22,8 @@ command = """\
2222
if [ -v FONTAWESOME_NPM_TOKEN ]; then echo -e '@fortawesome:registry=https://npm.fontawesome.com/\\n//npm.fontawesome.com/:_authToken=$''{FONTAWESOME_NPM_TOKEN}\\n' > ../scripts/.npmrc; fi; \
2323
(cd ../scripts; npm --no-package-lock i || true) && \
2424
if [ -v GITHUB_TOKEN ]; then export GIT_CREDENTIALS=https://$GITHUB_TOKEN:@github.com; else node ../scripts/remove-private-content-sources.js ../antora-playbook.yml; fi; \
25-
node_modules/.bin/antora --fetch --generator=@antora/xref-validator ../antora-playbook.yml || true; \
26-
node_modules/.bin/antora --redirect-facility=netlify --to-dir=public --url $DEPLOY_PRIME_URL ../antora-playbook.yml && \
27-
node ../scripts/add-current-url-redirects.js ../etc/nginx/snippets/rewrites.conf && \
25+
time node_modules/.bin/antora --fetch --generator=@antora/xref-validator ../antora-playbook.yml || true; \
26+
time node_modules/.bin/antora --redirect-facility=netlify --to-dir=public --url $DEPLOY_PRIME_URL ../antora-playbook.yml && \
2827
node ../scripts/populate-icon-defs.js public\
2928
"""
3029

0 commit comments

Comments
 (0)