Skip to content

Commit

Permalink
fix version handler for new mkdocs
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Jansen <[email protected]>
  • Loading branch information
farodin91 committed Nov 18, 2023
1 parent 2e7b5ee commit 020642a
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 119 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-backend-cql-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-backend-cql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-backend-hbase-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-backend-hbase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-backend-scylla-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-backend-scylla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- 'docs/**'
- '.github/workflows/ci-docs.yml'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-core-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
paths-ignore:
- 'docs/**'
- '.github/workflows/ci-docs.yml'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-index-es-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-index-es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-index-solr-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-index-solr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-release-dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
push:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/ci-docs.yml'
- '.github/ISSUE_TEMPLATE/**'
- 'requirements.txt'
- 'mkdocs.yml'
- 'docs.Dockerfile'
- '*.md'
branches-ignore:
Expand Down
Empty file added docs/theme/js/.gitkeep
Empty file.
10 changes: 0 additions & 10 deletions docs/theme/structor-menu.css

This file was deleted.

147 changes: 40 additions & 107 deletions docs/theme/structor-menu.js.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,117 +8,50 @@ const versions = [
{{- end}}
];


// Material theme

function addMaterialMenu(elt, versions) {
const current = versions.find(function (value) {
return value.selected
})

const rootLi = document.createElement('li');
rootLi.classList.add('md-nav__item');
rootLi.classList.add('md-nav__item--version');
rootLi.classList.add('md-nav__item--nested');

const input = document.createElement('input');
input.classList.add('md-toggle');
input.classList.add('md-nav__toggle');
input.setAttribute('data-md-toggle', 'nav-10000000');
input.id = "nav-10000000";
input.type = 'checkbox';

rootLi.appendChild(input);

const lbl01 = document.createElement('label')
lbl01.classList.add('md-nav__link');
lbl01.setAttribute('for', 'nav-10000000');
lbl01.textContent = current.text + " ";

rootLi.appendChild(lbl01);

const nav = document.createElement('nav')
nav.classList.add('md-nav');
nav.setAttribute('data-md-component','collapsible');
nav.setAttribute('data-md-level','1');

rootLi.appendChild(nav);

const lbl02 = document.createElement('label')
lbl02.classList.add('md-nav__title');
lbl02.setAttribute('for', 'nav-10000000');
lbl02.textContent = current.text + " ";

nav.appendChild(lbl02);

const ul = document.createElement('ul')
ul.classList.add('md-nav__list');
ul.setAttribute('data-md-scrollfix','');

nav.appendChild(ul);

for (let i = 0; i < versions.length; i++) {
const li = document.createElement('li');
li.classList.add('md-nav__item');

ul.appendChild(li);

const a = document.createElement('a');
a.classList.add('md-nav__link');
if (versions[i].selected) {
a.classList.add('md-nav__link--active');
}
a.href = window.location.protocol + "//" + window.location.host + "/";
if (window.location.host.includes(".github.io")) {
a.href = a.href + window.location.pathname.split("/")[1] + "/";
const current = versions.find(function (value) {
return value.selected
})
const rootDiv = document.createElement('div');
rootDiv.classList.add('md-version');

const rootLi = document.createElement('button');
rootLi.classList.add('md-version__current');
rootLi.textContent = current.text;
rootDiv.appendChild(rootLi)
const ul = document.createElement('ul')
ul.classList.add('md-version__list');


for (let i = 0; i < versions.length; i++) {
const li = document.createElement('li');
li.classList.add('md-version__item');

ul.appendChild(li);

const a = document.createElement('a');
a.classList.add('md-version__link');
if (versions[i].selected) {
a.classList.add('md-nav__link--active');
}
a.href = window.location.protocol + "//" + window.location.host + "/";
if (window.location.host.includes(".github.io")) {
a.href = a.href + window.location.pathname.split("/")[1] + "/";
}
if (versions[i].path) {
a.href = a.href + versions[i].path + "/"
}
a.title = versions[i].text;
a.text = versions[i].text;

li.appendChild(a);
}
if (versions[i].path) {
a.href = a.href + versions[i].path + "/"
}
a.title = versions[i].text;
a.text = versions[i].text;

li.appendChild(a);
}

elt.appendChild(rootLi);
rootDiv.appendChild(ul);
elt.appendChild(rootDiv);
}

// United theme

function addMenu(elt, versions){
const li = document.createElement('li');
li.classList.add('md-nav__item');
li.style.cssText = 'padding-top: 1em;';

const select = document.createElement('select');
select.classList.add('md-nav__link');
select.style.cssText = 'background: white;border: none;color: #00BCD4;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;overflow: hidden;padding: 0.1em;'
select.setAttribute('onchange', 'location = this.options[this.selectedIndex].value;');

for (let i = 0; i < versions.length; i++) {
let opt = document.createElement('option');
opt.value = window.location.protocol + "//" + window.location.host + "/";
if (versions[i].path) {
opt.value = opt.value + versions[i].path + "/"
}
opt.text = versions[i].text;
opt.selected = versions[i].selected;
select.appendChild(opt);
}

li.appendChild(select);
elt.appendChild(li);
}


const unitedSelector = 'div.navbar.navbar-default.navbar-fixed-top div.container div.navbar-collapse.collapse ul.nav.navbar-nav.navbar-right';
const materialSelector = 'div.md-container main.md-main div.md-main__inner.md-grid div.md-sidebar.md-sidebar--primary div.md-sidebar__scrollwrap div.md-sidebar__inner nav.md-nav.md-nav--primary ul.md-nav__list';
const materialSelector = 'header.md-header div.md-header__topic';

let elt = document.querySelector(materialSelector);
if (elt) {
addMaterialMenu(elt, versions);
} else {
const elt = document.querySelector(unitedSelector);
addMenu(elt, versions);
}
addMaterialMenu(elt, versions);
5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ theme:
name: 'material'
features:
- navigation.footer
- navigation.tabs
- navigation.sections
palette:
primary: 'green'
accent: 'teal'
Expand All @@ -76,8 +76,9 @@ theme:
favicon: 'favicon.ico'

extra_css:
- 'theme/structor-menu.css'
- 'theme/extra.css'
extra_javascript:
- 'theme/js/structor-menu.js'

extra:
social:
Expand Down

0 comments on commit 020642a

Please sign in to comment.