theme: wildspace and typos

This commit is contained in:
Sören Weber 2024-01-05 16:31:22 +01:00
parent 1a1f49ea59
commit 67e1f2567b
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
4 changed files with 115 additions and 115 deletions

View file

@ -25,7 +25,7 @@ import re
# the standard input in the form:
# <local ref> <local sha1> <remote ref> <remote sha1>
# This hook prevents the push of commits that belong to branches starting with
# an "#" (whiwork in progress).
# an "#" (which are work in progress).
def main():
local_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], universal_newlines=True).strip()

View file

@ -38,8 +38,8 @@ social.twitter = ""
# These options are specific to the Relearn theme.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Variants
# These options set your color variant.
# Branding
# These options set your overall visual apperance.
# Used color variants.
# Default: "auto"

View file

@ -292,10 +292,10 @@ function initMermaid( update, attrs ) {
initMermaid( true, {
'theme': variants.getColorValue( 'PRINT-MERMAID-theme' ),
});
}.bind( this ) );
window.addEventListener( 'afterprint', function(){
}.bind( this ) );
window.addEventListener( 'afterprint', function(){
initMermaid( true );
}.bind( this ) );
}.bind( this ) );
}
attrs = attrs || {
@ -398,7 +398,7 @@ function initOpenapi( update, attrs ){
var mod = window.relearn.themeVariantModifier;
var buster = window.themeUseOpenapi.assetsBuster ? '?' + window.themeUseOpenapi.assetsBuster : '';
var print = isPrint || attrs.isPrintPreview ? "PRINT-" : "";
var theme = print ? `${baseUri}/css/theme-relearn-light${mod}.css${buster}` : document.querySelector( '#R-variant-style' ).attributes.href.value
var theme = print ? `${baseUri}/css/theme-relearn-light${mod}.css${buster}` : document.querySelector( '#R-variant-style' ).attributes.href.value
var swagger_theme = variants.getColorValue( print + 'OPENAPI-theme' );
var swagger_code_theme = variants.getColorValue( print + 'OPENAPI-CODE-theme' );
@ -589,7 +589,7 @@ function initCodeClipboard(){
}
var codeElements = document.querySelectorAll( 'code' );
for( var i = 0; i < codeElements.length; i++ ){
for( var i = 0; i < codeElements.length; i++ ){
var code = codeElements[i];
var text = getCodeText( code );
var inPre = code.parentNode.tagName.toLowerCase() == 'pre';
@ -688,7 +688,7 @@ function initChroma( update ){
var chroma = variants.getColorValue( 'CODE-theme' );
var link = document.querySelector( '#R-variant-chroma-style' );
var old_path = link.getAttribute( 'href' );
var new_path = old_path.replace( /^(.*\/chroma-).*?(\.css.*)$/, '$1' + chroma + '$2' );
var new_path = old_path.replace( /^(.*\/chroma-).*?(\.css.*)$/, '$1' + chroma + '$2' );
link.setAttribute( 'href', new_path );
}
@ -1233,39 +1233,39 @@ function scrollToPositions() {
}
function mark() {
// mark some additional stuff as searchable
var bodyInnerLinks = document.querySelectorAll( '#R-body-inner a:not(.lightbox-link):not(.btn):not(.lightbox-back)' );
for( var i = 0; i < bodyInnerLinks.length; i++ ){
bodyInnerLinks[i].classList.add( 'highlight' );
}
// mark some additional stuff as searchable
var bodyInnerLinks = document.querySelectorAll( '#R-body-inner a:not(.lightbox-link):not(.btn):not(.lightbox-back)' );
for( var i = 0; i < bodyInnerLinks.length; i++ ){
bodyInnerLinks[i].classList.add( 'highlight' );
}
var value = sessionStorage.getItem( window.relearn.baseUriFull + 'search-value' );
var value = sessionStorage.getItem( window.relearn.baseUriFull + 'search-value' );
var highlightableElements = document.querySelectorAll( '.highlightable' );
highlight( highlightableElements, value, { element: 'mark' } );
var markedElements = document.querySelectorAll( 'mark' );
for( var i = 0; i < markedElements.length; i++ ){
var parent = markedElements[i].parentNode;
while( parent && parent.classList ){
if( parent.classList.contains( 'expand' ) ){
var expandInputs = parent.querySelectorAll( 'input:not(.expand-marked)' );
if( expandInputs.length ){
expandInputs[0].classList.add( 'expand-marked' );
expandInputs[0].dataset.checked = expandInputs[0].checked ? 'true' : 'false';
expandInputs[0].checked = true;
}
}
if( parent.tagName.toLowerCase() === 'li' && parent.parentNode && parent.parentNode.tagName.toLowerCase() === 'ul' && parent.parentNode.classList.contains( 'collapsible-menu' )){
var toggleInputs = parent.querySelectorAll( 'input:not(.menu-marked)' );
if( toggleInputs.length ){
toggleInputs[0].classList.add( 'menu-marked' );
toggleInputs[0].dataset.checked = toggleInputs[0].checked ? 'true' : 'false';
toggleInputs[0].checked = true;
}
}
parent = parent.parentNode;
}
}
var markedElements = document.querySelectorAll( 'mark' );
for( var i = 0; i < markedElements.length; i++ ){
var parent = markedElements[i].parentNode;
while( parent && parent.classList ){
if( parent.classList.contains( 'expand' ) ){
var expandInputs = parent.querySelectorAll( 'input:not(.expand-marked)' );
if( expandInputs.length ){
expandInputs[0].classList.add( 'expand-marked' );
expandInputs[0].dataset.checked = expandInputs[0].checked ? 'true' : 'false';
expandInputs[0].checked = true;
}
}
if( parent.tagName.toLowerCase() === 'li' && parent.parentNode && parent.parentNode.tagName.toLowerCase() === 'ul' && parent.parentNode.classList.contains( 'collapsible-menu' )){
var toggleInputs = parent.querySelectorAll( 'input:not(.menu-marked)' );
if( toggleInputs.length ){
toggleInputs[0].classList.add( 'menu-marked' );
toggleInputs[0].dataset.checked = toggleInputs[0].checked ? 'true' : 'false';
toggleInputs[0].checked = true;
}
}
parent = parent.parentNode;
}
}
psm && setTimeout( function(){ psm.update(); }, 10 );
}
window.relearn.markSearch = mark;
@ -1298,9 +1298,9 @@ function highlight( es, words, options ){
}
var re = new RegExp( pattern, flag );
for( var i = 0; i < es.length; i++ ){
for( var i = 0; i < es.length; i++ ){
highlightNode( es[i], re, settings.element, settings.className );
}
}
};
function highlightNode( node, re, nodeName, className ){
@ -1327,32 +1327,32 @@ function highlightNode( node, re, nodeName, className ){
};
function unmark() {
sessionStorage.removeItem( window.relearn.baseUriFull + 'search-value' );
var markedElements = document.querySelectorAll( 'mark' );
for( var i = 0; i < markedElements.length; i++ ){
var parent = markedElements[i].parentNode;
while( parent && parent.classList ){
if( parent.tagName.toLowerCase() === 'li' && parent.parentNode && parent.parentNode.tagName.toLowerCase() === 'ul' && parent.parentNode.classList.contains( 'collapsible-menu' )){
var toggleInputs = parent.querySelectorAll( 'input.menu-marked' );
if( toggleInputs.length ){
toggleInputs[0].checked = toggleInputs[0].dataset.checked === 'true';
toggleInputs[0].dataset.checked = null;
toggleInputs[0].classList.remove( 'menu-marked' );
}
}
if( parent.classList.contains( 'expand' ) ){
var expandInputs = parent.querySelectorAll( 'input.expand-marked' );
if( expandInputs.length ){
expandInputs[0].checked = expandInputs[0].dataset.checked === 'true';
expandInputs[0].dataset.checked = null;
expandInputs[0].classList.remove( 'expand-marked' );
}
}
parent = parent.parentNode;
}
}
sessionStorage.removeItem( window.relearn.baseUriFull + 'search-value' );
var markedElements = document.querySelectorAll( 'mark' );
for( var i = 0; i < markedElements.length; i++ ){
var parent = markedElements[i].parentNode;
while( parent && parent.classList ){
if( parent.tagName.toLowerCase() === 'li' && parent.parentNode && parent.parentNode.tagName.toLowerCase() === 'ul' && parent.parentNode.classList.contains( 'collapsible-menu' )){
var toggleInputs = parent.querySelectorAll( 'input.menu-marked' );
if( toggleInputs.length ){
toggleInputs[0].checked = toggleInputs[0].dataset.checked === 'true';
toggleInputs[0].dataset.checked = null;
toggleInputs[0].classList.remove( 'menu-marked' );
}
}
if( parent.classList.contains( 'expand' ) ){
var expandInputs = parent.querySelectorAll( 'input.expand-marked' );
if( expandInputs.length ){
expandInputs[0].checked = expandInputs[0].dataset.checked === 'true';
expandInputs[0].dataset.checked = null;
expandInputs[0].classList.remove( 'expand-marked' );
}
}
parent = parent.parentNode;
}
}
var highlighted = document.querySelectorAll( '.highlightable' );
var highlighted = document.querySelectorAll( '.highlightable' );
unhighlight( highlighted, { element: 'mark' } );
psm && setTimeout( function(){ psm.update(); }, 10 );
}
@ -1364,14 +1364,14 @@ function unhighlight( es, options ){
};
Object.assign( settings, options );
for( var i = 0; i < es.length; i++ ){
for( var i = 0; i < es.length; i++ ){
var highlightedElements = es[i].querySelectorAll( settings.element + '.' + settings.className );
for( var j = 0; j < highlightedElements.length; j++ ){
var parent = highlightedElements[j].parentNode;
parent.replaceChild( highlightedElements[j].firstChild, highlightedElements[j] );
parent.normalize();
}
}
}
};
// replace jQuery.createPseudo with https://stackoverflow.com/a/66318392

View file

@ -5,16 +5,16 @@ window.relearn = window.relearn || {};
// polyfill this rotten piece of sh...oftware
if( typeof NodeList !== "undefined" && NodeList.prototype && !NodeList.prototype.forEach ){
NodeList.prototype.forEach = Array.prototype.forEach;
NodeList.prototype.forEach = Array.prototype.forEach;
}
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
}
});
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
}
});
}
"function"!=typeof Object.assign&&(Object.assign=function(n,t){"use strict";if(null==n)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(n),e=1;e<arguments.length;e++){var o=arguments[e];if(null!=o)for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&(r[c]=o[c])}return r});
@ -89,7 +89,7 @@ var variants = {
},
generateVariantPath: function( variant, old_path ){
var mod = window.relearn.themeVariantModifier.replace( '.', '\\.' );
var mod = window.relearn.themeVariantModifier.replace( '.', '\\.' );
var new_path = old_path.replace( new RegExp(`^(.*\/theme-).*?(${mod}\.css.*)$`), '$1' + variant + '$2' );
return new_path;
},
@ -264,50 +264,50 @@ var variants = {
},
adjustCSSRules: function(selector, props, sheets) {
// get stylesheet(s)
if (!sheets) sheets = [].concat(Array.from(document.styleSheets));else if (sheets.sup) {
// sheets is a string
var absoluteURL = new URL(sheets, document.baseURI).href;
sheets = [].concat(document.styleSheets).filter(function (i) {
return i.href == absoluteURL;
});
} else sheets = [sheets]; // sheets is a stylesheet
// CSS (& HTML) reduce spaces in selector to one.
// get stylesheet(s)
if (!sheets) sheets = [].concat(Array.from(document.styleSheets));else if (sheets.sup) {
// sheets is a string
var absoluteURL = new URL(sheets, document.baseURI).href;
sheets = [].concat(document.styleSheets).filter(function (i) {
return i.href == absoluteURL;
});
} else sheets = [sheets]; // sheets is a stylesheet
// CSS (& HTML) reduce spaces in selector to one.
selector = selector.replace(/\s+/g, ' ');
selector = selector.replace(/\s+/g, ' ');
var findRule = function findRule(s) {
return [].concat(s.cssRules).reverse().find(function (i) {
return i.selectorText == selector;
});
};
var findRule = function findRule(s) {
return [].concat(s.cssRules).reverse().find(function (i) {
return i.selectorText == selector;
});
};
var rule = sheets.map(findRule).filter(function (i) {
return i;
}).pop();
var propsArr = props.sup ? props.split(/\s*;\s*/).map(function (i) {
return i.split(/\s*:\s*/);
}) // from string
: Object.entries(props); // from Object
var rule = sheets.map(findRule).filter(function (i) {
return i;
}).pop();
var propsArr = props.sup ? props.split(/\s*;\s*/).map(function (i) {
return i.split(/\s*:\s*/);
}) // from string
: Object.entries(props); // from Object
if (rule) {
for (var _iterator = _createForOfIteratorHelperLoose(propsArr), _step; !(_step = _iterator()).done;) {
var _rule$style;
var _step$value = _step.value,
prop = _step$value[0],
val = _step$value[1];
// rule.style[prop] = val; is against the spec, and does not support !important.
(_rule$style = rule.style).setProperty.apply(_rule$style, [prop].concat(val.split(/ *!(?=important)/)));
}
} else {
sheet = sheets.pop();
if (!props.sup) props = propsArr.reduce(function (str, _ref) {
var k = _ref[0],
v = _ref[1];
return str + "; " + k + ": " + v;
}, '');
sheet.insertRule(selector + " { " + props + " }", sheet.cssRules.length);
}
if (rule) {
for (var _iterator = _createForOfIteratorHelperLoose(propsArr), _step; !(_step = _iterator()).done;) {
var _rule$style;
var _step$value = _step.value,
prop = _step$value[0],
val = _step$value[1];
// rule.style[prop] = val; is against the spec, and does not support !important.
(_rule$style = rule.style).setProperty.apply(_rule$style, [prop].concat(val.split(/ *!(?=important)/)));
}
} else {
sheet = sheets.pop();
if (!props.sup) props = propsArr.reduce(function (str, _ref) {
var k = _ref[0],
v = _ref[1];
return str + "; " + k + ": " + v;
}, '');
sheet.insertRule(selector + " { " + props + " }", sheet.cssRules.length);
}
},
normalizeColor: function( c ){