To jest kopia testowa (staging) WikiFNiN. Zmiany tutaj nie trafiają na wiki.fnin.eu.
MediaWiki:Gadget-metadata.js
Przejdź do nawigacji
Przejdź do wyszukiwania
Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.
- Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
- Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
- Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5.
- Opera: Naciśnij klawisze Ctrl+F5.
/*global mw, $, importScript */
function getCategories() {
var categories = [];
if (mw.config.get("wgIsArticle")) {
categories = mw.config.get("wgCategories");
if (categories === null) {
mw.loader.load("mediawiki.api");
return new Promise(function (resolve, reject) {
new mw.Api()
.getCategories(mw.config.get("wgTitle"))
.then(function (result) {
resolve(
result.map(function (e) {
return e.title;
})
);
});
});
}
}
return new Promise(function (resolve, reject) {
resolve(categories);
});
}
$(function () {
getCategories().then(function (categories) {
if (categories.indexOf("Powieści FNiN") > -1) {
var bookStructuredData = {
"@context": "https://schema.org",
"@type": "WebPage",
mainEntity: {
"@type": "Book",
"@id": $('link[rel="canonical"]').attr("href"),
author: $("#book-author").text(),
image: $('meta[property="og:image"]').attr("content"),
isbn: $("#book-isbn").text(),
name: mw.config.get("wgTitle").split(" (")[0],
numberOfPages: $("#book-page-number").text(),
publisher: $("#book-publisher").text(),
description: $("meta[name=description]").attr("content"),
},
};
const script = document.createElement("script");
script.setAttribute("type", "application/ld+json");
script.textContent = JSON.stringify(bookStructuredData);
document.head.appendChild(script);
}
});
});
$(function () {
getCategories().then(function (categories) {
if (categories.indexOf("Bohaterowie") > -1) {
var cannonicalUrl = $('link[rel="canonical"]').attr("href");
var bookFullUrl = "https://wiki.fnin.eu/index.php/Felix,_Net_i_Nika";
var bookUniqueUrl = $("#only-in a:first").attr("href");
if (bookUniqueUrl)
bookFullUrl = mw.config.get("wgServer") + bookUniqueUrl;
var characterStructuredData = {
"@type": "Book",
"@id": bookFullUrl,
character: {
"@type": "Person",
"@id": cannonicalUrl,
name: mw.config.get("wgTitle").split(" (")[0],
image: $('meta[property="og:image"]').attr("content"),
description: $("meta[name=description]").attr("content"),
url: cannonicalUrl,
},
};
var pageStructuredDate = {
"@context": "https://schema.org",
"@type": "WebPage",
mainEntity: characterStructuredData,
};
const script = document.createElement("script");
script.setAttribute("type", "application/ld+json");
script.textContent = JSON.stringify(pageStructuredDate);
document.head.appendChild(script);
}
});
});