mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-08 03:37:12 -04:00
Implement app:// links
Former-commit-id: ff15b66ac35bdb6299161ce28e6b10fd35d5485c [formerly 2a9ae3a2f8f21b98cee7fa3ad76373e6985f135b [formerly bb46b193feb478c21d8da955a7399b64e7a337cb]] Former-commit-id: 0ae9b105f136e965045a21afecac89572a365a67 Former-commit-id: 14779e41a52aa29126013b4b46d1eca9775b0328
This commit is contained in:
parent
81ef3a97e5
commit
14aebab45f
@ -3080,7 +3080,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
// URLs that begin 'http' (i.e. non-relative URLs). It then captures the whole of the URL up until either the opening delimiter
|
||||
// (" or ', which is capture group \3) or a querystring or hash character (? or #). When the regex is used below, it will be further
|
||||
// processed to calculate the ZIM URL from the relative path. This regex can cope with legitimate single quote marks (') in the URL.
|
||||
var regexpTagsWithZimUrl = /(<(?:img|script|link|track)\b[^>]*?\s)(?:src|href)(\s*=\s*(["']))(?!http)(.+?)(?=\3|\?|#)/ig;
|
||||
var regexpTagsWithZimUrl = /(<(?:img|script|link|track)\b[^>]*?\s)(?:src|href)(\s*=\s*(["']))(?!http|app:)(.+?)(?=\3|\?|#)/ig;
|
||||
// Regex below tests the html of an article for active content [kiwix-js #466]
|
||||
// It inspects every <script> block in the html and matches in the following cases: 1) the script loads a UI application called app.js;
|
||||
// 2) the script block has inline content that does not contain "importScript()", "toggleOpenSection" or an "articleId" assignment
|
||||
@ -3271,7 +3271,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
var regexpGeoLocationDE = /<span\s+class\s?=\s?"[^"]+?listing-coordinates[\s\S]+?latitude">([^<]+)[\s\S]+?longitude">([^<]+)<[\s\S]+?(<span[^>]+listing-name[^>]+>([^<]+)<\/span>)/ig;
|
||||
htmlArticle = htmlArticle.replace(regexpGeoLocationDE, function (match, latitude, longitude, href, id) {
|
||||
return '<a href="bingmaps:?collection=point.' + latitude + '_' + longitude + '_' + encodeURIComponent(id.replace(/_/g, " ")) +
|
||||
'">\r\n<img alt="Map marker" title="Diesen Ort auf einer Karte zeigen" src="img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;margin-top:5px !important" />\r\n</a>' + href;
|
||||
'">\r\n<img alt="Map marker" title="Diesen Ort auf einer Karte zeigen" src="app:///www/img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;margin-top:5px !important" />\r\n</a>' + href;
|
||||
});
|
||||
|
||||
//Adapt English Wikivoyage POI data format
|
||||
@ -3279,12 +3279,15 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
|
||||
htmlArticle = htmlArticle.replace(regexpGeoLocationEN, function (match, p1, latitude, longitude, p4, p5, p6, id) {
|
||||
return p1 + "bingmaps:?collection=point." + latitude + "_" + longitude + "_" +
|
||||
encodeURIComponent(id.replace(/_/g, " ")).replace(/\.(\w\w)/g, "%$1") +
|
||||
(p5 ? "\&lvl=" + p5 : "") + p4.replace(/style\s?="\s?background:[^"]+"\s?/i, "") + '<img alt="Map marker" title="Show this place on a map" src="img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;" />' + p6 + id;
|
||||
(p5 ? "\&lvl=" + p5 : "") + p4.replace(/style\s?="\s?background:[^"]+"\s?/i, "") + '<img alt="Map marker" title="Show this place on a map" src="app:///www/img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;" />' + p6 + id;
|
||||
});
|
||||
|
||||
//Clean up remaining geo: links
|
||||
htmlArticle = htmlArticle.replace(/href\s*=\s*"\s*geo:([\d.-]+),([\d.-]+)/ig, 'href="bingmaps:?collection=point.$1_$2_' + encodeURIComponent(dirEntry.getTitleOrUrl()));
|
||||
|
||||
// Process any app:// links (these are always from the app payload) to match the current protocol
|
||||
htmlArticle = htmlArticle.replace(/(['"])app:\/\//g, '$1' + window.location.protocol + '//');
|
||||
|
||||
//Setup endnote backlinks if the ZIM doesn't have any
|
||||
htmlArticle = htmlArticle.replace(/<li\b[^>]+id=["']cite[-_]note[-_]([^"']+)[^>]+>(?![^/]+?[↑^])/ig, function (match, id) {
|
||||
var fnSearchRegxp = new RegExp('id=["' + "'](cite[-_]ref[-_]" + id.replace(/[-_()+]/g, "[-_()]+") + '[^"' + "']*)", 'i');
|
||||
|
@ -56,12 +56,13 @@ params['archivePath'] = "archives"; //The directory containing the packaged arch
|
||||
params['fileVersion'] = getSetting('fileVersion') || "wikipedia_en_100_maxi_2021-01.zim (23-Jan-2021)"; //This will be displayed in the app - optionally include date of ZIM file
|
||||
// List of known start pages cached in the FS:
|
||||
params['cachedStartPages'] = {
|
||||
'wikipedia_en_medicine-app_maxi': 'A/Wikipedia:WikiProject_Medicine/Open_Textbook_of_Medicine'
|
||||
'wikipedia_en_medicine-app_maxi': 'A/Wikipedia:WikiProject_Medicine/Open_Textbook_of_Medicine',
|
||||
'wikivoyage_en_all_maxi': 'A/Main_Page'
|
||||
};
|
||||
params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/"; //Include final slash
|
||||
/******* DEV: ENSURE SERVERS BELOW ARE LISTED IN package.appxmanifest ************/
|
||||
params['PWAServer'] = "https://pwa.kiwix.org/"; // Production server
|
||||
// params['PWAServer'] = "https://kiwix.github.io/kiwix-js-windows/"; // Test server
|
||||
// params['PWAServer'] = "https://pwa.kiwix.org/"; // Production server
|
||||
params['PWAServer'] = "https://kiwix.github.io/kiwix-js-windows/"; // Test server
|
||||
params['PWAMode'] = getSetting('PWAMode'); // Set to true if the app should always operate in PWA mode
|
||||
|
||||
params['storeType'] = getBestAvailableStorageAPI();
|
||||
|
Loading…
x
Reference in New Issue
Block a user