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",
"origin": "Example Fandom Wiki",
"origin_base_url": "example.fandom.com",
"origin_content_path": "/wiki/",
"label": "Example Fandom Wiki",
"origins": [
{
"origin": "Example Fandom Wiki",
"origin_base_url": "example.fandom.com",
"origin_content_path": "/wiki/"
}
]
"destination": "Example Wiki",
"destination_base_url": "example.com",
"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.
* `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_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/`.

View File

@ -72,7 +72,7 @@ function redirectToBreezeWiki(storage, eventInfo, url) {
}
}
// Load website data.
// Load website data:
async function getData() {
const LANGS = ["DE", "EN", "ES", "FR", "IT", "PL", "TOK"];
let sites = [];
@ -81,8 +81,22 @@ async function getData() {
promises.push(fetch(chrome.runtime.getURL('data/sites' + LANGS[i] + '.json'))
.then((resp) => resp.json())
.then(function (jsonData) {
jsonData.forEach((site) => site.language = LANGS[i]);
sites = sites.concat(jsonData);
jsonData.forEach((site) => {
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);

View File

@ -23,7 +23,7 @@ function addLocationObserver(callback) {
observer.observe(document.body, config);
}
// Load website data
// Load website data:
async function getData() {
const LANGS = ["DE", "EN", "ES", "FR", "IT", "PL", "TOK"];
let sites = [];
@ -32,8 +32,22 @@ async function getData() {
promises.push(fetch(chrome.runtime.getURL('data/sites' + LANGS[i] + '.json'))
.then((resp) => resp.json())
.then(function (jsonData) {
jsonData.forEach((site) => site.language = LANGS[i]);
sites = sites.concat(jsonData);
jsonData.forEach((site) => {
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);

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -130,7 +130,7 @@ async function loadOptions(lang) {
inputDisabled.classList = 'toggleDisable';
inputDisabled.type = "radio";
inputDisabled.name = key;
inputDisabled.title = 'Disable actions for ' + sites[i].origin;
inputDisabled.title = 'Disable actions for ' + sites[i].label;
inputDisabled.id = key + '-redirect';
inputDisabled.lang = lang;
@ -140,7 +140,7 @@ async function loadOptions(lang) {
inputRedirect.classList = 'toggleRedirect';
inputRedirect.type = "radio";
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.lang = lang;
@ -150,7 +150,7 @@ async function loadOptions(lang) {
inputAlert.classList = 'toggleAlert';
inputAlert.type = "radio";
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.lang = lang;
@ -242,28 +242,28 @@ async function loadOptions(lang) {
// Output disable radio button:
let inputDisabledText = document.createElement('span');
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(inputDisabledText);
// Output redirect radio button:
let inputRedirectText = document.createElement('span');
inputRedirectText.classList.add('visuallyHidden');
inputRedirectText.textContent = 'Automatically redirect ' + sites[i].origin;
inputRedirectText.textContent = 'Automatically redirect ' + sites[i].label;
labelRedirect.appendChild(inputRedirect);
labelRedirect.appendChild(inputRedirectText);
// Output alert radio button:
let inputAlertText = document.createElement('span');
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(inputAlertText);
// Output search filter checkbox:
let inputFilterText = document.createElement('span');
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(inputFilterText);
@ -279,7 +279,7 @@ async function loadOptions(lang) {
// Output text:
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");
siteContainer.appendChild(labelDisabled);