Restructuring wiki data to support many-to-one

pull/118/head
Kevin Payravi 2023-04-12 02:19:33 -05:00
parent 1949608ef9
commit d8be76f626
11 changed files with 812 additions and 298 deletions

View File

@ -50,9 +50,14 @@ Entries are formatted as follows:
``` ```
{ {
"id": "en-example", "id": "en-example",
"origin": "Example Fandom Wiki", "label": "Example Fandom Wiki",
"origin_base_url": "example.fandom.com", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Example Fandom Wiki",
"origin_base_url": "example.fandom.com",
"origin_content_path": "/wiki/"
}
]
"destination": "Example Wiki", "destination": "Example Wiki",
"destination_base_url": "example.com", "destination_base_url": "example.com",
"destination_content_path": "/w/", "destination_content_path": "/w/",
@ -62,6 +67,8 @@ Entries are formatted as follows:
``` ```
* `id`: A unique identifier for the wiki; should start with the two-letter language code for the wiki, followed by a hypen and the name of the subject/franchise the wiki covers. * `id`: A unique identifier for the wiki; should start with the two-letter language code for the wiki, followed by a hypen and the name of the subject/franchise the wiki covers.
* `label`: A label that is shown to the user, identifying the non-indie wiki(s). This is usually just the name of the wiki, but in the case of multiple wikis, it may be something like "Example Fandom Wikis" (plural).
* `origins`: An array of wikis being redirected to the independent wiki. The vast majority of the time, there is just one wiki here. There may be multiple when a series has multiple wikis that combined into one independent wiki; when a Fandom wiki has archived alternatives; or when there are multiple non-independent wikis across multiple wiki farms.
* `origin`: Name of the wiki being redirected. * `origin`: Name of the wiki being redirected.
* `origin_base_url`: Fully qualified domain name of the wiki being redirected. * `origin_base_url`: Fully qualified domain name of the wiki being redirected.
* `origin_content_path`: The URL path prefix for article links on the wiki being redirected. On MediaWiki wikis, it can be found at Special:Version. Fandom wikis are usually `/wiki/`. * `origin_content_path`: The URL path prefix for article links on the wiki being redirected. On MediaWiki wikis, it can be found at Special:Version. Fandom wikis are usually `/wiki/`.

View File

@ -72,7 +72,7 @@ function redirectToBreezeWiki(storage, eventInfo, url) {
} }
} }
// Load website data. // Load website data:
async function getData() { async function getData() {
const LANGS = ["DE", "EN", "ES", "FR", "IT", "PL", "TOK"]; const LANGS = ["DE", "EN", "ES", "FR", "IT", "PL", "TOK"];
let sites = []; let sites = [];
@ -81,8 +81,22 @@ async function getData() {
promises.push(fetch(chrome.runtime.getURL('data/sites' + LANGS[i] + '.json')) promises.push(fetch(chrome.runtime.getURL('data/sites' + LANGS[i] + '.json'))
.then((resp) => resp.json()) .then((resp) => resp.json())
.then(function (jsonData) { .then(function (jsonData) {
jsonData.forEach((site) => site.language = LANGS[i]); jsonData.forEach((site) => {
sites = sites.concat(jsonData); site.origins.forEach((origin) => {
sites.push({
"id": site.id,
"origin": origin.origin,
"origin_base_url": origin.origin_base_url,
"origin_content_path": origin.origin_content_path,
"destination": site.destination,
"destination_base_url": site.destination_base_url,
"destination_content_path": site.destination_content_path,
"destination_platform": site.destination_platform,
"destination_icon": site.destination_icon,
"lang": LANGS[i]
})
})
});
})); }));
} }
await Promise.all(promises); await Promise.all(promises);

View File

@ -23,7 +23,7 @@ function addLocationObserver(callback) {
observer.observe(document.body, config); observer.observe(document.body, config);
} }
// Load website data // Load website data:
async function getData() { async function getData() {
const LANGS = ["DE", "EN", "ES", "FR", "IT", "PL", "TOK"]; const LANGS = ["DE", "EN", "ES", "FR", "IT", "PL", "TOK"];
let sites = []; let sites = [];
@ -32,8 +32,22 @@ async function getData() {
promises.push(fetch(chrome.runtime.getURL('data/sites' + LANGS[i] + '.json')) promises.push(fetch(chrome.runtime.getURL('data/sites' + LANGS[i] + '.json'))
.then((resp) => resp.json()) .then((resp) => resp.json())
.then(function (jsonData) { .then(function (jsonData) {
jsonData.forEach((site) => site.language = LANGS[i]); jsonData.forEach((site) => {
sites = sites.concat(jsonData); site.origins.forEach((origin) => {
sites.push({
"id": site.id,
"origin": origin.origin,
"origin_base_url": origin.origin_base_url,
"origin_content_path": origin.origin_content_path,
"destination": site.destination,
"destination_base_url": site.destination_base_url,
"destination_content_path": site.destination_content_path,
"destination_platform": site.destination_platform,
"destination_icon": site.destination_icon,
"lang": LANGS[i]
})
})
});
})); }));
} }
await Promise.all(promises); await Promise.all(promises);

View File

@ -1,9 +1,14 @@
[ [
{ {
"id": "de-animalcrossing", "id": "de-animalcrossing",
"origin": "Animal Crossing Fandom Wiki", "label": "Animal Crossing Fandom Wiki",
"origin_base_url": "animalcrossing.fandom.com/de", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Animal Crossing Fandom Wiki",
"origin_base_url": "animalcrossing.fandom.com/de",
"origin_content_path": "/wiki/"
}
],
"destination": "Animal Crossing Wiki", "destination": "Animal Crossing Wiki",
"destination_base_url": "animalcrossingwiki.de", "destination_base_url": "animalcrossingwiki.de",
"destination_content_path": "/", "destination_content_path": "/",
@ -12,9 +17,14 @@
}, },
{ {
"id": "de-detektivconan", "id": "de-detektivconan",
"origin": "Detektiv Conan Fandom Wiki", "label": "Detektiv Conan Fandom Wiki",
"origin_base_url": "detektivconan.fandom.com", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Detektiv Conan Fandom Wiki",
"origin_base_url": "detektivconan.fandom.com",
"origin_content_path": "/wiki/"
}
],
"destination": "ConanWiki", "destination": "ConanWiki",
"destination_base_url": "conanwiki.org", "destination_base_url": "conanwiki.org",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",
@ -23,9 +33,14 @@
}, },
{ {
"id": "de-starcitizen", "id": "de-starcitizen",
"origin": "Star Citizen Fandom Wiki", "label": "Star Citizen Fandom Wiki",
"origin_base_url": "starcitizen.fandom.com/de", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Star Citizen Fandom Wiki",
"origin_base_url": "starcitizen.fandom.com/de",
"origin_content_path": "/wiki/"
}
],
"destination": "Star Citizen Wiki", "destination": "Star Citizen Wiki",
"destination_base_url": "star-citizen.wiki", "destination_base_url": "star-citizen.wiki",
"destination_content_path": "/", "destination_content_path": "/",

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,14 @@
[ [
{ {
"id": "es-animalcrossing", "id": "es-animalcrossing",
"origin": "Animal Crossing Fandom Wiki", "label": "Animal Crossing Fandom Wiki",
"origin_base_url": "animalcrossing.fandom.com/es", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Animal Crossing Fandom Wiki",
"origin_base_url": "animalcrossing.fandom.com/es",
"origin_content_path": "/wiki/"
}
],
"destination": "Animal Crossing Enciclopedia", "destination": "Animal Crossing Enciclopedia",
"destination_base_url": "animalcrossing.wikidex.net", "destination_base_url": "animalcrossing.wikidex.net",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",
@ -12,9 +17,14 @@
}, },
{ {
"id": "es-supersmashbros", "id": "es-supersmashbros",
"origin": "Smashpedia Fandom Wiki", "label": "Smashpedia Fandom Wiki",
"origin_base_url": "supersmashbros.fandom.com/es", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Smashpedia Fandom Wiki",
"origin_base_url": "supersmashbros.fandom.com/es",
"origin_content_path": "/wiki/"
}
],
"destination": "SmashPedia", "destination": "SmashPedia",
"destination_base_url": "es.ssbwiki.com", "destination_base_url": "es.ssbwiki.com",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",
@ -23,9 +33,14 @@
}, },
{ {
"id": "es-touhou", "id": "es-touhou",
"origin": "Touhou Fandom Wiki", "label": "Touhou Fandom Wiki",
"origin_base_url": "touhou.fandom.com/es", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Touhou Fandom Wiki",
"origin_base_url": "touhou.fandom.com/es",
"origin_content_path": "/wiki/"
}
],
"destination": "Touhou Wiki", "destination": "Touhou Wiki",
"destination_base_url": "es.touhouwiki.net", "destination_base_url": "es.touhouwiki.net",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",
@ -34,9 +49,14 @@
}, },
{ {
"id": "es-pokemon", "id": "es-pokemon",
"origin": "WikiDex (Fandom)", "label": "WikiDex (Fandom)",
"origin_base_url": "pokemon.fandom.com/es", "origins": [
"origin_content_path": "/wiki/", {
"origin": "WikiDex (Fandom)",
"origin_base_url": "pokemon.fandom.com/es",
"origin_content_path": "/wiki/"
}
],
"destination": "WikiDex", "destination": "WikiDex",
"destination_base_url": "www.wikidex.net", "destination_base_url": "www.wikidex.net",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",

View File

@ -1,9 +1,14 @@
[ [
{ {
"id": "fr-dragonquest", "id": "fr-dragonquest",
"origin": "Dragon Quest Fandom Wiki", "label": "Dragon Quest Fandom Wiki",
"origin_base_url": "dragonquest.fandom.com/fr", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Dragon Quest Fandom Wiki",
"origin_base_url": "dragonquest.fandom.com/fr",
"origin_content_path": "/wiki/"
}
],
"destination": "Wiki Dragon Quest", "destination": "Wiki Dragon Quest",
"destination_base_url": "wikidragonquest.fr", "destination_base_url": "wikidragonquest.fr",
"destination_content_path": "/", "destination_content_path": "/",
@ -12,9 +17,14 @@
}, },
{ {
"id": "fr-pokemon", "id": "fr-pokemon",
"origin": "Pokémon Fandom Wiki", "label": "Pokémon Fandom Wiki",
"origin_base_url": "pokemon.fandom.com/fr", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Pokémon Fandom Wiki",
"origin_base_url": "pokemon.fandom.com/fr",
"origin_content_path": "/wiki/"
}
],
"destination": "Poképédia", "destination": "Poképédia",
"destination_base_url": "www.pokepedia.fr", "destination_base_url": "www.pokepedia.fr",
"destination_content_path": "/", "destination_content_path": "/",

View File

@ -1,9 +1,14 @@
[ [
{ {
"id": "it-pokemon", "id": "it-pokemon",
"origin": "Analisi Pokémon Fandom Wiki", "label": "Analisi Pokémon Fandom Wiki",
"origin_base_url": "pokemon.fandom.com/it", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Analisi Pokémon Fandom Wiki",
"origin_base_url": "pokemon.fandom.com/it",
"origin_content_path": "/wiki/"
}
],
"destination": "Pokémon Central Wiki", "destination": "Pokémon Central Wiki",
"destination_base_url": "wiki.pokemoncentral.it", "destination_base_url": "wiki.pokemoncentral.it",
"destination_content_path": "/", "destination_content_path": "/",
@ -12,9 +17,14 @@
}, },
{ {
"id": "it-mario", "id": "it-mario",
"origin": "Mario Fandom Wiki", "label": "Mario Fandom Wiki",
"origin_base_url": "mario.fandom.com/it", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Mario Fandom Wiki",
"origin_base_url": "mario.fandom.com/it",
"origin_content_path": "/wiki/"
}
],
"destination": "Super Mario Wiki", "destination": "Super Mario Wiki",
"destination_base_url": "www.mariowiki.it", "destination_base_url": "www.mariowiki.it",
"destination_content_path": "/", "destination_content_path": "/",
@ -23,9 +33,14 @@
}, },
{ {
"id": "it-earthbound", "id": "it-earthbound",
"origin": "EarthBound Fandom Wiki", "label": "EarthBound Fandom Wiki",
"origin_base_url": "earthbound.fandom.com/it", "origins": [
"origin_content_path": "/wiki/", {
"origin": "EarthBound Fandom Wiki",
"origin_base_url": "earthbound.fandom.com/it",
"origin_content_path": "/wiki/"
}
],
"destination": "WikiBound", "destination": "WikiBound",
"destination_base_url": "it.wikibound.info", "destination_base_url": "it.wikibound.info",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",

View File

@ -1,9 +1,14 @@
[ [
{ {
"id": "pl-rayman", "id": "pl-rayman",
"origin": "Rayman Fandom Wiki", "label": "Rayman Fandom Wiki",
"origin_base_url": "rayman.fandom.com/pl", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Rayman Fandom Wiki",
"origin_base_url": "rayman.fandom.com/pl",
"origin_content_path": "/wiki/"
}
],
"destination": "RayWiki", "destination": "RayWiki",
"destination_base_url": "raymanpc.com", "destination_base_url": "raymanpc.com",
"destination_content_path": "/wiki/pl/", "destination_content_path": "/wiki/pl/",

View File

@ -1,9 +1,14 @@
[ [
{ {
"id": "tok-wikipesija", "id": "tok-wikipesija",
"origin": "Toki Pona Fandom Wiki", "label": "Toki Pona Fandom Wiki",
"origin_base_url": "tokipona.fandom.com", "origins": [
"origin_content_path": "/wiki/", {
"origin": "Toki Pona Fandom Wiki",
"origin_base_url": "tokipona.fandom.com",
"origin_content_path": "/wiki/"
}
],
"destination": "Wikipesija", "destination": "Wikipesija",
"destination_base_url": "wikipesija.org", "destination_base_url": "wikipesija.org",
"destination_content_path": "/wiki/", "destination_content_path": "/wiki/",

View File

@ -130,7 +130,7 @@ async function loadOptions(lang) {
inputDisabled.classList = 'toggleDisable'; inputDisabled.classList = 'toggleDisable';
inputDisabled.type = "radio"; inputDisabled.type = "radio";
inputDisabled.name = key; inputDisabled.name = key;
inputDisabled.title = 'Disable actions for ' + sites[i].origin; inputDisabled.title = 'Disable actions for ' + sites[i].label;
inputDisabled.id = key + '-redirect'; inputDisabled.id = key + '-redirect';
inputDisabled.lang = lang; inputDisabled.lang = lang;
@ -140,7 +140,7 @@ async function loadOptions(lang) {
inputRedirect.classList = 'toggleRedirect'; inputRedirect.classList = 'toggleRedirect';
inputRedirect.type = "radio"; inputRedirect.type = "radio";
inputRedirect.name = key; inputRedirect.name = key;
inputRedirect.title = 'Automatically redirect from ' + sites[i].origin + ' to ' + sites[i].destination; inputRedirect.title = 'Automatically redirect from ' + sites[i].label + ' to ' + sites[i].destination;
inputRedirect.id = key + '-redirect'; inputRedirect.id = key + '-redirect';
inputRedirect.lang = lang; inputRedirect.lang = lang;
@ -150,7 +150,7 @@ async function loadOptions(lang) {
inputAlert.classList = 'toggleAlert'; inputAlert.classList = 'toggleAlert';
inputAlert.type = "radio"; inputAlert.type = "radio";
inputAlert.name = key; inputAlert.name = key;
inputAlert.title = 'Notify with banner when visiting ' + sites[i].origin; inputAlert.title = 'Notify with banner when visiting ' + sites[i].label;
inputAlert.id = key + '-alert'; inputAlert.id = key + '-alert';
inputAlert.lang = lang; inputAlert.lang = lang;
@ -242,28 +242,28 @@ async function loadOptions(lang) {
// Output disable radio button: // Output disable radio button:
let inputDisabledText = document.createElement('span'); let inputDisabledText = document.createElement('span');
inputDisabledText.classList.add('visuallyHidden'); inputDisabledText.classList.add('visuallyHidden');
inputDisabledText.textContent = 'Disable action for ' + sites[i].origin; inputDisabledText.textContent = 'Disable action for ' + sites[i].label;
labelDisabled.appendChild(inputDisabled); labelDisabled.appendChild(inputDisabled);
labelDisabled.appendChild(inputDisabledText); labelDisabled.appendChild(inputDisabledText);
// Output redirect radio button: // Output redirect radio button:
let inputRedirectText = document.createElement('span'); let inputRedirectText = document.createElement('span');
inputRedirectText.classList.add('visuallyHidden'); inputRedirectText.classList.add('visuallyHidden');
inputRedirectText.textContent = 'Automatically redirect ' + sites[i].origin; inputRedirectText.textContent = 'Automatically redirect ' + sites[i].label;
labelRedirect.appendChild(inputRedirect); labelRedirect.appendChild(inputRedirect);
labelRedirect.appendChild(inputRedirectText); labelRedirect.appendChild(inputRedirectText);
// Output alert radio button: // Output alert radio button:
let inputAlertText = document.createElement('span'); let inputAlertText = document.createElement('span');
inputAlertText.classList.add('visuallyHidden'); inputAlertText.classList.add('visuallyHidden');
inputAlertText.textContent = 'Automatically alert for' + sites[i].origin; inputAlertText.textContent = 'Automatically alert for' + sites[i].label;
labelAlert.appendChild(inputAlert); labelAlert.appendChild(inputAlert);
labelAlert.appendChild(inputAlertText); labelAlert.appendChild(inputAlertText);
// Output search filter checkbox: // Output search filter checkbox:
let inputFilterText = document.createElement('span'); let inputFilterText = document.createElement('span');
inputFilterText.classList.add('visuallyHidden'); inputFilterText.classList.add('visuallyHidden');
inputFilterText.textContent = 'Filter ' + sites[i].origin + ' from search engine results'; inputFilterText.textContent = 'Filter ' + sites[i].label + ' from search engine results';
labelFilter.appendChild(inputFilter); labelFilter.appendChild(inputFilter);
labelFilter.appendChild(inputFilterText); labelFilter.appendChild(inputFilterText);
@ -279,7 +279,7 @@ async function loadOptions(lang) {
// Output text: // Output text:
let text = document.createElement('span'); let text = document.createElement('span');
text.textContent = sites[i].origin + ' » ' + sites[i].destination; text.textContent = sites[i].label + ' » ' + sites[i].destination;
let siteContainer = document.createElement("div"); let siteContainer = document.createElement("div");
siteContainer.appendChild(labelDisabled); siteContainer.appendChild(labelDisabled);