Modul:Stadtwikis: Unterschied zwischen den Versionen
Aus FürthWiki
Keine Bearbeitungszusammenfassung |
(Neues Spiel, neues Glück, Übertrag aus Modul:GetWebData!) |
||
| Zeile 37: | Zeile 37: | ||
data = {} | data = {} | ||
for i, | for i, u in ipairs(urls) do | ||
--t = getAPIdata(url.."?action=query&meta=siteinfo&siprop=statistics&format=json", "t") | --t = getAPIdata(url.."?action=query&meta=siteinfo&siprop=statistics&format=json", "t") | ||
--u = getAPIdata(url.."?action=query&meta=siteinfo&format=json", "u") | --u = getAPIdata(url.."?action=query&meta=siteinfo&format=json", "u") | ||
| Zeile 43: | Zeile 43: | ||
--h =h..tableToString(u) | --h =h..tableToString(u) | ||
local stat = mw.ext.externalData.getWebData{ | |||
url= | url=u.."?action=query&meta=siteinfo&siprop=statistics&format=json", | ||
format="json" | format="json" | ||
} | } | ||
local info = mw.ext.externalData.getWebData{ | |||
url=u.."?action=query&meta=siteinfo&format=json", | |||
url = | |||
format="json" | format="json" | ||
}) | } | ||
data[i] = mw.clone(stat) | |||
--mw.log("Stat: " .. mw.dumpObject(stat)) | |||
--mw.log("Info: " .. mw.dumpObject(info)) | |||
mw.log("Data: " .. mw.dumpObject(data)) | |||
--data['articles']=response.articles | |||
--data['images']=response.articles | |||
--data['edits']=response.articles | |||
--data['users']=response.articles | |||
--data['activeusers']=response.articles | |||
--data['admins']=response.articles | |||
--u = mw.ext.externalData.getExternalData {u="__all"} | --u = mw.ext.externalData.getExternalData {u="__all"} | ||
h=h..tableToString(data) | --h=h..tableToString(data) | ||
--h=h..tabelizeData(url, t) | --h=h..tabelizeData(url, t) | ||
end | end | ||
Version vom 13. Mai 2025, 16:32 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Stadtwikis/Doku erstellt werden
local p = {}
local c = require( "Module:Common" )
--local http = require("mw.http")
--local json = require("mw.text").jsonDecode
function p.Versuch(frame)
urls = {"https://www.fuerthwiki.de/wiki/api.php",
"https://oesterreichwiki.org/w/api.php",
"https://www.geschichtewiki.wien.gv.at/api.php",
-- "https://ka.stadtwiki.net/w/api.php", <= siteinfo down
"https://www.sn.at/wiki/api.php",
"https://www.niederbayern-wiki.de/api.php",
-- "https://www.aw-wiki.de/w/api.php", <= siteinfo down
"https://www.hammwiki.info/api.php",
"https://www.muenchenwiki.de/w/api.php",
"https://rhein-neckar-wiki.de/api.php",
-- "https://www.stadtwikidd.de/wiki/api.php" <= too old version, no api
"https://www.gelsenkirchener-geschichten.de/w/api.php",
"https://atterwiki.at/api.php",
"https://www.ennstalwiki.at/wiki/api.php",
--"https://wuerzburgwiki.de/w/api.php",
"https://wiki.muenster.org/api.php",
"https://www.tuepedia.de/api.php",
"https://www.linzwiki.at/w/api.php",
}
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>'
data = {}
for i, u in ipairs(urls) do
--t = getAPIdata(url.."?action=query&meta=siteinfo&siprop=statistics&format=json", "t")
--u = getAPIdata(url.."?action=query&meta=siteinfo&format=json", "u")
--h = h..tableToString(t)
--h =h..tableToString(u)
local stat = mw.ext.externalData.getWebData{
url=u.."?action=query&meta=siteinfo&siprop=statistics&format=json",
format="json"
}
local info = mw.ext.externalData.getWebData{
url=u.."?action=query&meta=siteinfo&format=json",
format="json"
}
data[i] = mw.clone(stat)
--mw.log("Stat: " .. mw.dumpObject(stat))
--mw.log("Info: " .. mw.dumpObject(info))
mw.log("Data: " .. mw.dumpObject(data))
--data['articles']=response.articles
--data['images']=response.articles
--data['edits']=response.articles
--data['users']=response.articles
--data['activeusers']=response.articles
--data['admins']=response.articles
--u = mw.ext.externalData.getExternalData {u="__all"}
--h=h..tableToString(data)
--h=h..tabelizeData(url, t)
end
h=h..'</table>'
return h
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