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: # the standard input in the form:
# <local ref> <local sha1> <remote ref> <remote sha1> # <local ref> <local sha1> <remote ref> <remote sha1>
# This hook prevents the push of commits that belong to branches starting with # 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(): def main():
local_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], universal_newlines=True).strip() 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. # These options are specific to the Relearn theme.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Variants # Branding
# These options set your color variant. # These options set your overall visual apperance.
# Used color variants. # Used color variants.
# Default: "auto" # Default: "auto"

View file

@ -292,10 +292,10 @@ function initMermaid( update, attrs ) {
initMermaid( true, { initMermaid( true, {
'theme': variants.getColorValue( 'PRINT-MERMAID-theme' ), 'theme': variants.getColorValue( 'PRINT-MERMAID-theme' ),
}); });
}.bind( this ) ); }.bind( this ) );
window.addEventListener( 'afterprint', function(){ window.addEventListener( 'afterprint', function(){
initMermaid( true ); initMermaid( true );
}.bind( this ) ); }.bind( this ) );
} }
attrs = attrs || { attrs = attrs || {
@ -398,7 +398,7 @@ function initOpenapi( update, attrs ){
var mod = window.relearn.themeVariantModifier; var mod = window.relearn.themeVariantModifier;
var buster = window.themeUseOpenapi.assetsBuster ? '?' + window.themeUseOpenapi.assetsBuster : ''; var buster = window.themeUseOpenapi.assetsBuster ? '?' + window.themeUseOpenapi.assetsBuster : '';
var print = isPrint || attrs.isPrintPreview ? "PRINT-" : ""; 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_theme = variants.getColorValue( print + 'OPENAPI-theme' );
var swagger_code_theme = variants.getColorValue( print + 'OPENAPI-CODE-theme' ); var swagger_code_theme = variants.getColorValue( print + 'OPENAPI-CODE-theme' );
@ -589,7 +589,7 @@ function initCodeClipboard(){
} }
var codeElements = document.querySelectorAll( 'code' ); 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 code = codeElements[i];
var text = getCodeText( code ); var text = getCodeText( code );
var inPre = code.parentNode.tagName.toLowerCase() == 'pre'; var inPre = code.parentNode.tagName.toLowerCase() == 'pre';
@ -688,7 +688,7 @@ function initChroma( update ){
var chroma = variants.getColorValue( 'CODE-theme' ); var chroma = variants.getColorValue( 'CODE-theme' );
var link = document.querySelector( '#R-variant-chroma-style' ); var link = document.querySelector( '#R-variant-chroma-style' );
var old_path = link.getAttribute( 'href' ); 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 ); link.setAttribute( 'href', new_path );
} }
@ -1233,39 +1233,39 @@ function scrollToPositions() {
} }
function mark() { function mark() {
// mark some additional stuff as searchable // mark some additional stuff as searchable
var bodyInnerLinks = document.querySelectorAll( '#R-body-inner a:not(.lightbox-link):not(.btn):not(.lightbox-back)' ); var bodyInnerLinks = document.querySelectorAll( '#R-body-inner a:not(.lightbox-link):not(.btn):not(.lightbox-back)' );
for( var i = 0; i < bodyInnerLinks.length; i++ ){ for( var i = 0; i < bodyInnerLinks.length; i++ ){
bodyInnerLinks[i].classList.add( 'highlight' ); 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' ); var highlightableElements = document.querySelectorAll( '.highlightable' );
highlight( highlightableElements, value, { element: 'mark' } ); highlight( highlightableElements, value, { element: 'mark' } );
var markedElements = document.querySelectorAll( 'mark' ); var markedElements = document.querySelectorAll( 'mark' );
for( var i = 0; i < markedElements.length; i++ ){ for( var i = 0; i < markedElements.length; i++ ){
var parent = markedElements[i].parentNode; var parent = markedElements[i].parentNode;
while( parent && parent.classList ){ while( parent && parent.classList ){
if( parent.classList.contains( 'expand' ) ){ if( parent.classList.contains( 'expand' ) ){
var expandInputs = parent.querySelectorAll( 'input:not(.expand-marked)' ); var expandInputs = parent.querySelectorAll( 'input:not(.expand-marked)' );
if( expandInputs.length ){ if( expandInputs.length ){
expandInputs[0].classList.add( 'expand-marked' ); expandInputs[0].classList.add( 'expand-marked' );
expandInputs[0].dataset.checked = expandInputs[0].checked ? 'true' : 'false'; expandInputs[0].dataset.checked = expandInputs[0].checked ? 'true' : 'false';
expandInputs[0].checked = true; expandInputs[0].checked = true;
} }
} }
if( parent.tagName.toLowerCase() === 'li' && parent.parentNode && parent.parentNode.tagName.toLowerCase() === 'ul' && parent.parentNode.classList.contains( 'collapsible-menu' )){ 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)' ); var toggleInputs = parent.querySelectorAll( 'input:not(.menu-marked)' );
if( toggleInputs.length ){ if( toggleInputs.length ){
toggleInputs[0].classList.add( 'menu-marked' ); toggleInputs[0].classList.add( 'menu-marked' );
toggleInputs[0].dataset.checked = toggleInputs[0].checked ? 'true' : 'false'; toggleInputs[0].dataset.checked = toggleInputs[0].checked ? 'true' : 'false';
toggleInputs[0].checked = true; toggleInputs[0].checked = true;
} }
} }
parent = parent.parentNode; parent = parent.parentNode;
} }
} }
psm && setTimeout( function(){ psm.update(); }, 10 ); psm && setTimeout( function(){ psm.update(); }, 10 );
} }
window.relearn.markSearch = mark; window.relearn.markSearch = mark;
@ -1298,9 +1298,9 @@ function highlight( es, words, options ){
} }
var re = new RegExp( pattern, flag ); 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 ); highlightNode( es[i], re, settings.element, settings.className );
} }
}; };
function highlightNode( node, re, nodeName, className ){ function highlightNode( node, re, nodeName, className ){
@ -1327,32 +1327,32 @@ function highlightNode( node, re, nodeName, className ){
}; };
function unmark() { function unmark() {
sessionStorage.removeItem( window.relearn.baseUriFull + 'search-value' ); sessionStorage.removeItem( window.relearn.baseUriFull + 'search-value' );
var markedElements = document.querySelectorAll( 'mark' ); var markedElements = document.querySelectorAll( 'mark' );
for( var i = 0; i < markedElements.length; i++ ){ for( var i = 0; i < markedElements.length; i++ ){
var parent = markedElements[i].parentNode; var parent = markedElements[i].parentNode;
while( parent && parent.classList ){ while( parent && parent.classList ){
if( parent.tagName.toLowerCase() === 'li' && parent.parentNode && parent.parentNode.tagName.toLowerCase() === 'ul' && parent.parentNode.classList.contains( 'collapsible-menu' )){ 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' ); var toggleInputs = parent.querySelectorAll( 'input.menu-marked' );
if( toggleInputs.length ){ if( toggleInputs.length ){
toggleInputs[0].checked = toggleInputs[0].dataset.checked === 'true'; toggleInputs[0].checked = toggleInputs[0].dataset.checked === 'true';
toggleInputs[0].dataset.checked = null; toggleInputs[0].dataset.checked = null;
toggleInputs[0].classList.remove( 'menu-marked' ); toggleInputs[0].classList.remove( 'menu-marked' );
} }
} }
if( parent.classList.contains( 'expand' ) ){ if( parent.classList.contains( 'expand' ) ){
var expandInputs = parent.querySelectorAll( 'input.expand-marked' ); var expandInputs = parent.querySelectorAll( 'input.expand-marked' );
if( expandInputs.length ){ if( expandInputs.length ){
expandInputs[0].checked = expandInputs[0].dataset.checked === 'true'; expandInputs[0].checked = expandInputs[0].dataset.checked === 'true';
expandInputs[0].dataset.checked = null; expandInputs[0].dataset.checked = null;
expandInputs[0].classList.remove( 'expand-marked' ); expandInputs[0].classList.remove( 'expand-marked' );
} }
} }
parent = parent.parentNode; parent = parent.parentNode;
} }
} }
var highlighted = document.querySelectorAll( '.highlightable' ); var highlighted = document.querySelectorAll( '.highlightable' );
unhighlight( highlighted, { element: 'mark' } ); unhighlight( highlighted, { element: 'mark' } );
psm && setTimeout( function(){ psm.update(); }, 10 ); psm && setTimeout( function(){ psm.update(); }, 10 );
} }
@ -1364,14 +1364,14 @@ function unhighlight( es, options ){
}; };
Object.assign( settings, 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 ); var highlightedElements = es[i].querySelectorAll( settings.element + '.' + settings.className );
for( var j = 0; j < highlightedElements.length; j++ ){ for( var j = 0; j < highlightedElements.length; j++ ){
var parent = highlightedElements[j].parentNode; var parent = highlightedElements[j].parentNode;
parent.replaceChild( highlightedElements[j].firstChild, highlightedElements[j] ); parent.replaceChild( highlightedElements[j].firstChild, highlightedElements[j] );
parent.normalize(); parent.normalize();
} }
} }
}; };
// replace jQuery.createPseudo with https://stackoverflow.com/a/66318392 // 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 // polyfill this rotten piece of sh...oftware
if( typeof NodeList !== "undefined" && NodeList.prototype && !NodeList.prototype.forEach ){ 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) { if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', { Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, rawPos) { value: function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0; var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search; 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}); "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 ){ 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' ); var new_path = old_path.replace( new RegExp(`^(.*\/theme-).*?(${mod}\.css.*)$`), '$1' + variant + '$2' );
return new_path; return new_path;
}, },
@ -264,50 +264,50 @@ var variants = {
}, },
adjustCSSRules: function(selector, props, sheets) { adjustCSSRules: function(selector, props, sheets) {
// get stylesheet(s) // get stylesheet(s)
if (!sheets) sheets = [].concat(Array.from(document.styleSheets));else if (sheets.sup) { if (!sheets) sheets = [].concat(Array.from(document.styleSheets));else if (sheets.sup) {
// sheets is a string // sheets is a string
var absoluteURL = new URL(sheets, document.baseURI).href; var absoluteURL = new URL(sheets, document.baseURI).href;
sheets = [].concat(document.styleSheets).filter(function (i) { sheets = [].concat(document.styleSheets).filter(function (i) {
return i.href == absoluteURL; return i.href == absoluteURL;
}); });
} else sheets = [sheets]; // sheets is a stylesheet } else sheets = [sheets]; // sheets is a stylesheet
// CSS (& HTML) reduce spaces in selector to one. // CSS (& HTML) reduce spaces in selector to one.
selector = selector.replace(/\s+/g, ' '); selector = selector.replace(/\s+/g, ' ');
var findRule = function findRule(s) { var findRule = function findRule(s) {
return [].concat(s.cssRules).reverse().find(function (i) { return [].concat(s.cssRules).reverse().find(function (i) {
return i.selectorText == selector; return i.selectorText == selector;
}); });
}; };
var rule = sheets.map(findRule).filter(function (i) { var rule = sheets.map(findRule).filter(function (i) {
return i; return i;
}).pop(); }).pop();
var propsArr = props.sup ? props.split(/\s*;\s*/).map(function (i) { var propsArr = props.sup ? props.split(/\s*;\s*/).map(function (i) {
return i.split(/\s*:\s*/); return i.split(/\s*:\s*/);
}) // from string }) // from string
: Object.entries(props); // from Object : Object.entries(props); // from Object
if (rule) { if (rule) {
for (var _iterator = _createForOfIteratorHelperLoose(propsArr), _step; !(_step = _iterator()).done;) { for (var _iterator = _createForOfIteratorHelperLoose(propsArr), _step; !(_step = _iterator()).done;) {
var _rule$style; var _rule$style;
var _step$value = _step.value, var _step$value = _step.value,
prop = _step$value[0], prop = _step$value[0],
val = _step$value[1]; val = _step$value[1];
// rule.style[prop] = val; is against the spec, and does not support !important. // 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)/))); (_rule$style = rule.style).setProperty.apply(_rule$style, [prop].concat(val.split(/ *!(?=important)/)));
} }
} else { } else {
sheet = sheets.pop(); sheet = sheets.pop();
if (!props.sup) props = propsArr.reduce(function (str, _ref) { if (!props.sup) props = propsArr.reduce(function (str, _ref) {
var k = _ref[0], var k = _ref[0],
v = _ref[1]; v = _ref[1];
return str + "; " + k + ": " + v; return str + "; " + k + ": " + v;
}, ''); }, '');
sheet.insertRule(selector + " { " + props + " }", sheet.cssRules.length); sheet.insertRule(selector + " { " + props + " }", sheet.cssRules.length);
} }
}, },
normalizeColor: function( c ){ normalizeColor: function( c ){