Kategorie:Seiten, die DynamicPageList3 parser function nutzen und Widget:Autorenbox: Unterschied zwischen den Seiten
Aus ZUM-Unterrichten
(Unterschied zwischen Seiten)
(Automatisch von der AutoCreateCategoryPages-Erweiterung erstellt.) Markierung: 2017-Quelltext-Bearbeitung |
KKeine Bearbeitungszusammenfassung Markierung: 2017-Quelltext-Bearbeitung |
||
Zeile 1: | Zeile 1: | ||
<includeonly> | |||
<div class="autorenbox zum-hintergrund-links zum-farbe-xx-heller uk-hidden"> | |||
<h2>Autor*innen</h2> | |||
<small class="autorenbox-updated" data-zum-hook="last-modified">aktualisiert am: </small> | |||
<div class="autorenbox-autoren" data-zum-hook="userlist"> | |||
</div> | |||
</div> | |||
<script type="text/javascript"> | |||
(function () { | |||
const paramArtikel = "<!--{$artikel|escape:'javascript'}-->" || null; | |||
const paramKategorie = "<!--{$kategorie|escape:'javascript'}-->" || null; | |||
const paramMitUnterseiten = "<!--{$mit_unterseiten|escape:'javascript'}-->" === "ja"; | |||
const element = document.currentScript && document.currentScript.previousElementSibling; | |||
if (element) { | |||
window.RLQ.push(function () { | |||
mw.loader.enqueue(['mediawiki.api'], function () { | |||
const getCurrentTitle = () => mw.Title.makeTitle( | |||
mw.config.get('wgNamespaceNumber'), | |||
mw.config.get('wgTitle') | |||
).getPrefixedText() | |||
; | |||
const userlistEl = $(element).find('[data-zum-hook="userlist"]'); | |||
const lastModifiedEl = $(element).find('[data-zum-hook="last-modified"]'); | |||
const api = new mw.Api(); | |||
const queries = []; | |||
if (paramKategorie) { | |||
queries.push({ | |||
action: 'query', | |||
prop: ['contributors', 'info'], | |||
generator: 'categorymembers', | |||
gcmtitle: `Kategorie:${paramKategorie}`, | |||
gcmnamespace: 0, | |||
gcmtype: 'page', | |||
gcmlimit: 'max' | |||
}); | |||
} else { | |||
queries.push({ | |||
action: 'query', | |||
prop: ['revisions', 'info', 'contributors'], | |||
titles: paramArtikel || getCurrentTitle(), | |||
rvlimit: 150, | |||
rvprop: ['userid', 'user', 'flags', 'timestamp'], | |||
}); | |||
} | |||
if (paramMitUnterseiten){ | |||
queries.push({ | |||
action: 'query', | |||
prop: ['contributors', 'info'], | |||
generator: 'allpages', | |||
gapprefix: (paramArtikel || getCurrentTitle()) + '/', | |||
gaplimit:'max' | |||
}); | |||
} | |||
const response = $.Deferred(); | |||
function continueQueryOrResolve(result, query, pages, lastContinue) { | |||
api.get({...query, ...lastContinue}) | |||
.then((response) => { | |||
const newPages = Object.values(response.query.pages).reduce((pages, page) => { | |||
pages[page.pageid] = {...pages[page.pageid], ...page}; | |||
return pages; | |||
}, pages); | |||
if (response.continue !== undefined) { | |||
continueQueryOrResolve(result, query, newPages, response.continue); | |||
} else if (response.batchcomplete !== undefined) { | |||
result.resolve(Object.values(newPages)); | |||
} | |||
}); | |||
} | |||
const def = $.Deferred(); | |||
def.resolve([]); | |||
queries.reduce((result, query) => { | |||
const newResult = $.Deferred(); | |||
continueQueryOrResolve(newResult, query, {}, null); | |||
return newResult.then((b) => { | |||
return result.then((a) => ([...a, ...b])); | |||
}); | |||
}, def.promise()) | |||
.then((data) => { response.resolve(data);}); | |||
response | |||
.then((pages) => { | |||
const userCounts = pages.reduce((acc, pageData) => { | |||
acc.touched = Math.max(acc.touched || -1, Date.parse(pageData.touched)); | |||
acc.userChanges = (pageData.contributors || []) | |||
.reduce((userChanges, c) => { | |||
userChanges[c.userid] = userChanges[c.userid] || { | |||
count: 0, | |||
last: -1, | |||
userid: c.userid, | |||
username: c.name | |||
}; | |||
userChanges[c.userid].count += 1; | |||
return userChanges; | |||
}, acc.userChanges || {}); | |||
acc.userChanges = (pageData.revisions || []) | |||
.reduce((userChanges, r) => { | |||
userChanges[r.userid] = userChanges[r.userid] || { | |||
count: 0, | |||
last: -1, | |||
userid: r.userid, | |||
username: r.user | |||
}; | |||
userChanges[r.userid].count += r.minor !== undefined ? 0.1 : 1; | |||
userChanges[r.userid].last = Math.max(userChanges[r.userid].last, r.revid); | |||
return userChanges; | |||
}, acc.userChanges || {}); | |||
return acc; | |||
}, {}); | |||
const usernames = Object.values(userCounts.userChanges) | |||
.filter((userChange) => userChange.username !== 'Christian') | |||
.sort((a, b) => { | |||
let diff = b.count - a.count; | |||
if (diff !== 0) { | |||
return diff; | |||
} | |||
return b.last - a.last; | |||
}).map((user) => user.username); | |||
$(lastModifiedEl).append(new Date(userCounts.touched).toLocaleDateString()); | |||
const userdatas = usernames.map((user) => api | |||
.parse(`{{#avatar:${user}|l}}`) | |||
.then((imgTag) => $(imgTag)) | |||
.then((img$) => img$.find('img').addBack('img').attr('src')) | |||
.then((imgSrc) => ({user, imgSrc})) | |||
.fail((ignored) => null) | |||
); | |||
$.when(...userdatas) | |||
.then((...userdatas) => userdatas.filter((ud) => ud !== null)) | |||
.then((userdatas) => { | |||
userdatas.map(({user, imgSrc}) => { | |||
const userTitle = mw.Title.makeTitle(mw.config.get('wgNamespaceIds')['benutzer'], user); | |||
if(userTitle === null){ | |||
return null; | |||
} | |||
return $('<img>') | |||
.attr('src', imgSrc) | |||
.wrap('<a>') | |||
.parent() | |||
.attr('href', userTitle.getUrl()) | |||
.wrap('<div class="autorenbox-avatar" style="overflow:hidden;width:60%;margin:auto;">') | |||
.parent() | |||
.wrap('<div class="autorenbox-container" style="max-width:12ch">') | |||
.parent() | |||
.append( | |||
$('<a>') | |||
.append(user) | |||
.attr('href', userTitle.getUrl()) | |||
.wrap('<div class="autorenbox-name">') | |||
.parent() | |||
); | |||
}) | |||
.filter((elem) => elem !== null) | |||
.forEach((elem) => elem.appendTo($(userlistEl))); | |||
}) | |||
.then((ignored) => $(element).removeClass('uk-hidden')); | |||
});//end response.then | |||
});//end loader.enqueue | |||
});//end RLQ.push | |||
}//end if | |||
})(); | |||
</script> | |||
</includeonly> |
Version vom 9. Februar 2024, 12:49 Uhr
Seiten in der Kategorie „Seiten, die DynamicPageList3 parser function nutzen“
Folgende 112 Seiten sind in dieser Kategorie, von 112 insgesamt.
A
- Afrika
- Benutzer:Alexweller/Lineares und exponentielles Wachstum
- Algorithmus
- Am Anfang war das Feuer
- Am Anfang war das Feuer/LE01 Was macht den Menschen zum Menschen?
- Am Anfang war das Feuer/LE02 Zeitreise in die Steinzeit
- Am Anfang war das Feuer/LE03 Gefangen im Körper eines Steinzeitmenschen
- Am Anfang war das Feuer/LE04 Höhlenmalerei
- American Revolution
- American Revolution/LE1 A new World?
- American Revolution/LE2 French-Indian War
- American Revolution/LE3 Don't tread on me!
- American Revolution/LE4 Inventing a new Nation
- Anglizismen
- Arbeit
- Vorlage:Arbeitsblatt
- Australia
- Australia/LE1 Fact File
- Australia/LE2 Dangerous Animals
- Australia/LE3 Exploring the Outback
- Australia/LE4 Dream Time
- Australia/LE5 Convicts
- Australia/LE6 Strain
- Australia/LE7 Work and Travel
- Australia/LE8 Planning a Holiday
B
C
- Benutzer:Christian
- Benutzer:Christian/Chemie-Liste
- Benutzer:Christian/Hallo Julia
- Benutzer:Christian/Hallo Julia/LE1Was will Julia?
- Benutzer:Christian/Hallo Julia/LE1Wer ist Julia?
- Benutzer:Christian/Lernpfad Energie/Das physikalische Konzept Energie
- Benutzer:Christian/Lernpfad/LE1 zuerst kommt Schritt 1
- Benutzer:Christian/Lernpfad/LE2 dann kommt Schritt 2
- Benutzer:Christian/Test
- Benutzer:Christian/TestKapiteleinbettungen
- Benutzer:Christine Werner/Globale Risiken und Nachhaltigkeit
D
J
L
- Latein
- Vorlage:Lernpfad
- Lernpfad Akustik
- Lernpfad Akustik/LE1 Schallwellen und das Ohr
- Lernpfad Akustik/LE2 Tonerzeugung der Musikinstrumente
- Lernpfad Akustik/LE3 Naturtonreihe und Obertöne
- Lernpfad Akustik/LE4 Das Problem der Blechbläser
- Lernpfad Akustik/LE5 Das Problem des Klavierstimmers
- Lernpfade Ethik/Die Macht des Konsums 2
- Vorlage:LernpfadNeu
- Vorlage:LernpfadNeu/Lerneinheit/Preload
- Vorlage:LernpfadNeu/Preload
O
P
V
- Vereinte Nationen/Struktur und Organe
- Virtuelle Exkursionen
- Vom Erz zum Metall
- Vom Erz zum Metall/LE01 Das Geheimnis der Kupfergewinnung
- Vom Erz zum Metall/LE02 Von Rennofen bis Hochofen
- Vom Erz zum Metall/LE03 Gesellschaft
- Vom Erz zum Metall/LE04 Gusstechniken
- Vom Erz zum Metall/LE05 Die Himmelsscheibe von Nebra