Cache common css in filesystem

Adds several common Wikipedia stylesheets into the filesystem and calls them instead of searching in ZIM file


Former-commit-id: 4bc437a57c10d8cc776bff317f2f69985228c086 [formerly 6319655c85dcc349d4b2755d69b13c00fbd7a9d2]
Former-commit-id: de9f3c234b9e5c8decedac9cc13f74282ce08132
This commit is contained in:
Jaifroid 2017-07-09 21:22:57 +01:00
parent 57ca1beda9
commit 1832c49346
5 changed files with 28 additions and 7 deletions

View File

@ -0,0 +1 @@
.cite-accessibility-label{top:-99999px;clip:rect( 1px 1px 1px 1px );clip:rect( 1px,1px,1px,1px );position:absolute !important;padding:0 !important;border:0 !important;height:1px !important;width:1px !important;overflow:hidden}

View File

@ -0,0 +1 @@
.mw-cite-backlink,.cite-accessibility-label{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.mw-references-columns{-webkit-column-width:35em;-moz-column-width:35em;column-width:35em}.mw-references-columns li{-webkit-column-break-inside:avoid;page-break-inside:avoid;break-inside:avoid-column}sup.reference{unicode-bidi:-moz-isolate;unicode-bidi:-webkit-isolate;unicode-bidi:isolate;white-space:nowrap}ol.references li:target,sup.reference:target{background-color:#def;background-color:rgba( 0,127,255,0.133 )}.mw-ext-cite-error{font-weight:bold;unicode-bidi:embed}@media print{.mw-cite-backlink{display:none}}

View File

@ -0,0 +1 @@
@media screen{.tochidden,.toctoggle{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.toctoggle{font-size:94%}}@media print{#toc.tochidden,.toc.tochidden,.toctoggle{display:none}}

9
www/-/s/style.css Normal file

File diff suppressed because one or more lines are too long

View File

@ -793,9 +793,19 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
var linkArray = regexpSheetHref.exec(arr[i]);
regexpSheetHref.lastIndex = 0; //Reset start position for next loop
if (regexpMetadataUrl.test(linkArray[2])) { //It's a CSS file contained in ZIM
var linkURL = uiUtil.removeUrlParameters(decodeURIComponent(linkArray[2].match(regexpMetadataUrl)[1]));
console.log("Attempting to resolve CSS link #" + i + "...");
var linkBLOB = resolveCSS(linkURL, i); //Pass link and index
var zimLink = decodeURIComponent(uiUtil.removeUrlParameters(linkArray[2]));
//If this is a standard Wikipedia css stylesheet cached in the filesystem...
if (zimLink.match(/-\/s\/style\.css/i) ||
zimLink.match(/-\/s\/css_modules\/mediawiki\.toc\.css/i) ||
zimLink.match(/-\/s\/css_modules\/ext\.cite\.styles\.css/i) ||
zimLink.match(/-\/s\/css_modules\/ext\.cite\.a11y\.css/i)) {
blobArray[i] = zimLink; //Store href as is
injectCSS();
} else { //Try to get the stylesheet from the ZIM file
var linkURL = zimLink.match(regexpMetadataUrl)[1];
console.log("Attempting to resolve CSS link #" + i + "...");
resolveCSS(linkURL, i); //Pass link and index
}
} else {
blobArray[i] = linkArray[2]; //If CSS not in ZIM, store URL in blobArray
injectCSS(); //Ensure this is called even if none of CSS links are in ZIM
@ -805,18 +815,17 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
function resolveCSS(title, index) {
selectedArchive.getDirEntryByTitle(title).then(
function (dirEntry) {
function (dirEntry) {
selectedArchive.readBinaryFile(dirEntry, function (readableTitle, content) {
//var cssContent = util.uintToString(content);
var cssBlob = new Blob([content], { type: 'text/css' });
var newURL = URL.createObjectURL(cssBlob);
//return URL.createObjectURL(cssBlob);
blobArray[index] = newURL;
injectCSS();
injectCSS(); //Don't move this: it must run within .then function to pass correct values
});
}).fail(function (e) {
console.error("could not find DirEntry for CSS : " + title, e);
blobArray[index] = "Error";
blobArray[index] = title;
injectCSS();
});
}