Main Page: Difference between revisions

No edit summary
Fix remaining broken arrow characters on main page
 
(6 intermediate revisions by 2 users not shown)
Line 1,012: Line 1,012:
<span class="vu-explore-description">Biographies recorded across the wiki.</span>
<span class="vu-explore-description">Biographies recorded across the wiki.</span>
</span>
</span>
<span class="vu-explore-arrow"></span>
<span class="vu-explore-arrow">&gt;</span>
</a>
</a>


Line 1,021: Line 1,021:
<span class="vu-explore-description">Places documented throughout the history.</span>
<span class="vu-explore-description">Places documented throughout the history.</span>
</span>
</span>
<span class="vu-explore-arrow"></span>
<span class="vu-explore-arrow">&gt;</span>
</a>
</a>


Line 1,030: Line 1,030:
<span class="vu-explore-description">Family lines and their members.</span>
<span class="vu-explore-description">Family lines and their members.</span>
</span>
</span>
<span class="vu-explore-arrow"></span>
<span class="vu-explore-arrow">&gt;</span>
</a>
</a>


Line 1,039: Line 1,039:
<span class="vu-explore-description">Institutions and organized groups.</span>
<span class="vu-explore-description">Institutions and organized groups.</span>
</span>
</span>
<span class="vu-explore-arrow"></span>
<span class="vu-explore-arrow">&gt;</span>
</a>
</a>


Line 1,048: Line 1,048:
<span class="vu-explore-description">Events recorded throughout the history.</span>
<span class="vu-explore-description">Events recorded throughout the history.</span>
</span>
</span>
<span class="vu-explore-arrow"></span>
<span class="vu-explore-arrow">&gt;</span>
</a>
</a>


Line 1,057: Line 1,057:
<span class="vu-explore-description">The historical periods used by the wiki.</span>
<span class="vu-explore-description">The historical periods used by the wiki.</span>
</span>
</span>
<span class="vu-explore-arrow"></span>
<span class="vu-explore-arrow">&gt;</span>
</a>
</a>
</nav>
</nav>
Line 1,074: Line 1,074:
<h2>
<h2>
<a data-wiki-title="Reichsministerium für Bergbau und Rohstoffe" href="/wiki/Reichsministerium_f%C3%BCr_Bergbau_und_Rohstoffe">
<a data-wiki-title="Reichsministerium für Bergbau und Rohstoffe" href="/wiki/Reichsministerium_f%C3%BCr_Bergbau_und_Rohstoffe">
Reichsministerium für Bergbau und Rohstoffe
Reichsministerium f&uuml;r Bergbau und Rohstoffe
</a>
</a>
</h2>
</h2>


<p>
<p>
The Reichsministerium für Bergbau und Rohstoffe was a central ministry of the
The Reichsministerium f&uuml;r Bergbau und Rohstoffe was a central ministry of the
<a data-wiki-title="Government of the Tanoa Einsatzgruppen" href="/wiki/Government_of_the_Tanoa_Einsatzgruppen">Government of the Tanoa Einsatzgruppen</a>.
<a data-wiki-title="Government of the Tanoa Einsatzgruppen" href="/wiki/Government_of_the_Tanoa_Einsatzgruppen">Government of the Tanoa Einsatzgruppen</a>.
It administered mining and the state supply of raw materials.
It administered mining and the state supply of raw materials.
Line 1,145: Line 1,145:


<div class="vu-people-controls">
<div class="vu-people-controls">
<button class="vu-slide-button" id="vu-person-prev" type="button" aria-label="Previous person"></button>
<button class="vu-slide-button" id="vu-person-prev" type="button" aria-label="Previous person">&lt;</button>
<button class="vu-slide-button" id="vu-person-toggle" type="button" aria-label="Pause slideshow">Pause</button>
<button class="vu-slide-button" id="vu-person-toggle" type="button" aria-label="Pause slideshow">Pause</button>


Line 1,154: Line 1,154:
<div class="vu-slide-count" id="vu-person-count">1 / 1</div>
<div class="vu-slide-count" id="vu-person-count">1 / 1</div>


<button class="vu-slide-button" id="vu-person-next" type="button" aria-label="Next person"></button>
<button class="vu-slide-button" id="vu-person-next" type="button" aria-label="Next person">&gt;</button>
</div>
</div>
</section>
</section>
<div class="vu-heading">
<div class="vu-heading">
<div class="vu-heading-title">How to use this wiki</div>
<div class="vu-heading-title">How to use this wiki</div>
Line 1,244: Line 1,243:
var root = document.querySelector(".vu-main");
var root = document.querySelector(".vu-main");
var slider = document.getElementById("vu-people-slider");
var slider = document.getElementById("vu-people-slider");
var status = document.getElementById("vu-people-status");
var image = document.getElementById("vu-person-image");
var image = document.getElementById("vu-person-image");
var title = document.getElementById("vu-person-title");
var title = document.getElementById("vu-person-title");
Line 1,256: Line 1,256:
!root ||
!root ||
!slider ||
!slider ||
!status ||
!image ||
!image ||
!title ||
!title ||
Line 1,269: Line 1,270:


var fallbackImage = "/wiki/Special:Redirect/file/Vu-logo.png";
var fallbackImage = "/wiki/Special:Redirect/file/Vu-logo.png";
var cacheKey = "vu-main-people-slides-v4";
var cacheKey = "vu-main-people-slides-v9";
var cacheLifetime = 6 * 60 * 60 * 1000;
var cacheLifetime = 6 * 60 * 60 * 1000;
var slideInterval = 9000;
var slideInterval = 9000;
var apiPath = "/wiki/api.php";
var people = [];
var people = [];
var currentIndex = 0;
var currentIndex = 0;
Line 1,282: Line 1,284:
count.textContent = "1 / 1";
count.textContent = "1 / 1";
toggle.textContent = "Play";
toggle.textContent = "Play";
previous.textContent = "<";
next.textContent = ">";
function showStatus(message) {
if (!message) {
status.hidden = true;
status.textContent = "";
return;
}
status.textContent = message;
status.hidden = false;
}


function shuffle(items) {
function shuffle(items) {
Line 1,322: Line 1,337:


var finalSpace = cut.lastIndexOf(" ");
var finalSpace = cut.lastIndexOf(" ");
return cut.slice(0, finalSpace > 0 ? finalSpace : limit) + "";
return cut.slice(0, finalSpace > 0 ? finalSpace : limit) + "...";
}
}


Line 1,337: Line 1,352:
}
}


function normalizePages(data) {
function pageUrl(pageTitle) {
var pages =
if (window.mw && mw.util) {
data &&
return mw.util.getUrl(pageTitle);
data.query &&
}
Array.isArray(data.query.pages)
? data.query.pages
: [];


return "/wiki/" + encodeURIComponent(pageTitle.replace(/ /g, "_"));
}
function normalizePages(pages) {
return shuffle(
return shuffle(
pages
pages
.filter(function (page) {
.filter(function (page) {
return (
return page && !page.missing && page.title;
page &&
!page.missing &&
page.title &&
cleanText(page.extract).length >= 60 &&
getImage(page)
);
})
})
.map(function (page) {
.map(function (page) {
var pageExtract = shorten(page.extract, 650);
if (!pageExtract) {
pageExtract =
"This page is listed in Category:People. Open the page for the full article.";
}
return {
return {
title: page.title,
title: page.title,
extract: shorten(page.extract, 650),
extract: pageExtract,
image: getImage(page),
image: getImage(page) || fallbackImage,
url:
url: page.fullurl || pageUrl(page.title)
page.fullurl ||
(window.mw && mw.util
? mw.util.getUrl(page.title)
: "/wiki/" +
  encodeURIComponent(
  page.title.replace(/ /g, "_")
  ))
};
};
})
})
).slice(0, 12);
);
}
}


Line 1,495: Line 1,505:


function activateSlides(items) {
function activateSlides(items) {
if (!Array.isArray(items) || items.length < 2) {
if (!Array.isArray(items) || !items.length) {
showStatus("No people pages were loaded.");
return;
return;
}
}
Line 1,501: Line 1,512:
people = shuffle(items);
people = shuffle(items);
currentIndex = 0;
currentIndex = 0;
previous.disabled = false;
previous.disabled = people.length < 2;
next.disabled = false;
next.disabled = people.length < 2;
toggle.disabled = false;
toggle.disabled = people.length < 2;
showStatus("");
showSlide(0);
showSlide(0);
setPlaying(true);
setPlaying(people.length > 1);
}
}


Line 1,538: Line 1,550:
}
}
});
});
function buildQuery(params) {
var parts = [];
Object.keys(params).forEach(function (key) {
parts.push(
encodeURIComponent(key) +
"=" +
encodeURIComponent(params[key])
);
});
return parts.join("&");
}
function requestJson(params) {
return window
.fetch(apiPath + "?" + buildQuery(params), {
credentials: "same-origin"
})
.then(function (response) {
if (!response.ok) {
throw new Error("API HTTP " + response.status);
}
return response.json();
});
}
function copyParams(params) {
var copied = {};
Object.keys(params).forEach(function (key) {
copied[key] = params[key];
});
return copied;
}
function loadCategoryMembers(params, collectedPages) {
return requestJson(params).then(function (data) {
var nextPages =
data &&
data.query &&
Array.isArray(data.query.categorymembers)
? data.query.categorymembers
: [];
var allPages = collectedPages.concat(nextPages);
if (data && data.continue) {
var nextParams = copyParams(params);
Object.keys(data.continue).forEach(function (key) {
nextParams[key] = data.continue[key];
});
showStatus("Loading people... " + String(allPages.length));
return loadCategoryMembers(nextParams, allPages);
}
return allPages;
});
}
function uniqueTitles(items) {
var seen = {};
var titles = [];
items.forEach(function (item) {
if (!item || !item.title || seen[item.title]) {
return;
}
seen[item.title] = true;
titles.push(item.title);
});
return titles;
}
function loadPageDetails(titles) {
var groups = [];
for (var index = 0; index < titles.length; index += 1) {
groups.push(titles.slice(index, index + 1));
}
return groups
.reduce(function (chain, group) {
return chain.then(function (pages) {
return requestJson({
action: "query",
titles: group.join("|"),
prop: "extracts|pageimages|info",
exintro: 1,
explaintext: 1,
exchars: 700,
piprop: "thumbnail|original",
pithumbsize: 1000,
inprop: "url",
redirects: 1,
formatversion: 2,
format: "json"
}).then(function (data) {
var nextPages =
data &&
data.query &&
Array.isArray(data.query.pages)
? data.query.pages
: [];
if (
(pages.length + nextPages.length) % 10 === 0 ||
pages.length + nextPages.length === titles.length
) {
showStatus(
"Loading details... " +
String(pages.length + nextPages.length) +
" / " +
String(titles.length)
);
}
return pages.concat(nextPages);
});
});
}, Promise.resolve([]));
}


var cachedPeople = readCache();
var cachedPeople = readCache();
Line 1,545: Line 1,684:
}
}


if (!window.mw || !mw.loader) {
if (!window.fetch) {
showStatus("This browser cannot load the people list.");
return;
return;
}
}


mw.loader
showStatus("Loading people...");
.using(["mediawiki.api", "mediawiki.util"])
loadCategoryMembers(
.then(function () {
{
var api = new mw.Api();
action: "query",
 
list: "categorymembers",
/*
cmtitle: "Category:People",
* One request obtains category members, lead extracts,
cmnamespace: 0,
* page images and page URLs.
cmtype: "page",
*/
cmlimit: "max",
return api.get({
formatversion: 2,
action: "query",
format: "json"
generator: "categorymembers",
},
gcmtitle: "Category:People",
[]
gcmnamespace: 0,
)
gcmtype: "page",
.then(function (members) {
gcmlimit: 120,
var titles = uniqueTitles(members);
prop: "extracts|pageimages|info",
showStatus("Loading details... 0 / " + String(titles.length));
exintro: 1,
return loadPageDetails(titles);
explaintext: 1,
exchars: 700,
piprop: "thumbnail|original",
pithumbsize: 1000,
inprop: "url",
redirects: 1,
formatversion: 2
});
})
})
.then(function (data) {
.then(function (pages) {
var loadedPeople = normalizePages(data);
var loadedPeople = normalizePages(pages);
 
if (loadedPeople.length < 2) {
return;
}


saveCache(loadedPeople);
saveCache(loadedPeople);
Line 1,587: Line 1,715:
})
})
.catch(function () {
.catch(function () {
/*
showStatus("Could not load people list.");
* The initial slide remains visible if the request fails.
* No permanent loading message is shown.
*/
return;
});
});


Line 1,598: Line 1,722:
* keep MediaWiki's red-link appearance.
* keep MediaWiki's red-link appearance.
*/
*/
mw.loader
if (window.mw && mw.loader) {
.using(["mediawiki.api", "mediawiki.util"])
mw.loader
.then(function () {
.using(["mediawiki.api", "mediawiki.util"])
var api = new mw.Api();
.then(function () {
var links = Array.prototype.slice.call(
var api = new mw.Api();
root.querySelectorAll("a[data-wiki-title]")
var links = Array.prototype.slice.call(
);
root.querySelectorAll("a[data-wiki-title]")
);


var titles = links
var titles = links
.map(function (item) {
.map(function (item) {
return item.getAttribute("data-wiki-title");
return item.getAttribute("data-wiki-title");
})
})
.filter(function (item, index, allItems) {
.filter(function (item, index, allItems) {
return item && allItems.indexOf(item) === index;
return item && allItems.indexOf(item) === index;
});
});


if (!titles.length) {
if (!titles.length) {
return;
return;
}
}


return api
return api
.get({
.get({
action: "query",
action: "query",
titles: titles.join("|"),
titles: titles.join("|"),
formatversion: 2
formatversion: 2
})
})
.then(function (data) {
.then(function (data) {
var missing = {};
var missing = {};


if (data.query && Array.isArray(data.query.pages)) {
if (data.query && Array.isArray(data.query.pages)) {
data.query.pages.forEach(function (page) {
data.query.pages.forEach(function (page) {
if (page.missing) {
if (page.missing) {
missing[page.title] = true;
missing[page.title] = true;
}
}
});
});
}
}


links.forEach(function (item) {
links.forEach(function (item) {
var pageTitle =
var pageTitle =
item.getAttribute("data-wiki-title");
item.getAttribute("data-wiki-title");


if (!missing[pageTitle]) {
if (!missing[pageTitle]) {
return;
return;
}
}


item.classList.add("new");
item.classList.add("new");
item.href = mw.util.getUrl(pageTitle, {
item.href = mw.util.getUrl(pageTitle, {
action: "edit",
action: "edit",
redlink: 1
redlink: 1
});
item.title =
pageTitle + " (page does not exist)";
});
});
item.title =
pageTitle + " (page does not exist)";
});
});
});
});
})
}
.catch(function () {
return;
});
});
});
})();
})();