Modul:Stadtwikis: Unterschied zwischen den Versionen
Aus FürthWiki
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 43: | Zeile 43: | ||
} | } | ||
end | end | ||
return tableToString(results) | h='<table class="wikitable sortable"><tr>'.. | ||
'<th>Wiki URL</th>'.. | |||
'<th>Artikel</th>'.. | |||
'<th>Bilder</th>'.. | |||
'<th>Bearbeitungen</th>'.. | |||
'<th>Benutzer</th>'.. | |||
'<th>Aktive</th>'.. | |||
'<th>Admins</th>'.. | |||
'</tr>' | |||
for i = 1, #urls do | |||
h=h..tabelizeData(results[i]) | |||
end | |||
h=h.."<table>" | |||
return h--tableToString(results) | |||
end | end | ||
Version vom 14. Mai 2025, 17:25 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Stadtwikis/Doku erstellt werden
local p = {}
local c = require( "Module:Common" )
function getUrls(frame)
urls = {
"https://www.fuerthwiki.de/wiki/api.php",
"https://oesterreichwiki.org/w/api.php",
"https://www.geschichtewiki.wien.gv.at/api.php",
"https://www.sn.at/wiki/api.php",
"https://www.niederbayern-wiki.de/api.php",
"https://www.hammwiki.info/api.php",
"https://www.muenchenwiki.de/w/api.php",
"https://rhein-neckar-wiki.de/api.php",
"https://www.gelsenkirchener-geschichten.de/w/api.php",
"https://atterwiki.at/api.php",
"https://www.ennstalwiki.at/wiki/api.php",
"https://wiki.muenster.org/api.php",
"https://www.tuepedia.de/api.php",
-- "https://www.linzwiki.at/w/api.php" <= Fehlerteufel
}
-- Ausgefallene oder nicht vorhandene MediaWikis:
-- "https://ka.stadtwiki.net/w/api.php", <= siteinfo down
-- "https://www.aw-wiki.de/w/api.php", <= siteinfo down
-- "https://www.stadtwikidd.de/wiki/api.php" <= too old version, no api
-- "https://wuerzburgwiki.de/w/api.php",
return urls
end
function p.Versuch(frame)
local urls = getUrls()
local results = {}
for i = 1, #urls do
local data_stat = mw.ext.externalData.getWebData{
url = urls[i].."?action=query&meta=siteinfo&siprop=statistics&format=json",
format = "json"}
local data_info = mw.ext.externalData.getWebData{
url = urls[i].."?action=query&meta=siteinfo&format=json",
format = "json"}
results[i] = {
stat = mw.clone(data_stat),
info = mw.clone(data_info)
}
end
h='<table class="wikitable sortable"><tr>'..
'<th>Wiki URL</th>'..
'<th>Artikel</th>'..
'<th>Bilder</th>'..
'<th>Bearbeitungen</th>'..
'<th>Benutzer</th>'..
'<th>Aktive</th>'..
'<th>Admins</th>'..
'</tr>'
for i = 1, #urls do
h=h..tabelizeData(results[i])
end
h=h.."<table>"
return h--tableToString(results)
end
function tabelizeData(url, t)
h='<tr>'..
'<td>'..url..'</td>'..
'<td>'..t['articles']..'</td>'..
'<td>'..t['images']..'</td>'..
'<td>'..t['edits']..'</td>'..
'<td>'..t['users']..'</td>'..
'<td>'..t['activeusers']..'</td>'..
'<td>'..t['admins']..'</td>'..
'</tr>'
return h
end
function getAPIdata(url, data)
mw.ext.externalData.getWebData {url=url,
data=data,
format="json"
}
return mw.ext.externalData.getExternalData(data)
end
return p