Modul:Stadtwikis: Unterschied zwischen den Versionen
Aus FürthWiki
Keine Bearbeitungszusammenfassung Markierung: Manuelle Zurücksetzung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
--local c = require( "Module:Common" ) | --local c = require( "Module:Common" ) | ||
function tableToString(tbl, indent) | |||
indent = indent or 0 | |||
local toprint = string.rep(" ", indent) .. "{\n" | |||
indent = indent + 2 | |||
for k, v in pairs(tbl) do | |||
toprint = toprint .. string.rep(" ", indent) | |||
if type(k) == "number" then | |||
toprint = toprint .. "[" .. k .. "] = " | |||
elseif type(k) == "string" then | |||
toprint = toprint .. k .. " = " | |||
end | |||
if type(v) == "number" then | |||
toprint = toprint .. v .. ",\n" | |||
elseif type(v) == "string" then | |||
toprint = toprint .. "\"" .. v .. "\",\n" | |||
elseif type(v) == "table" then | |||
toprint = toprint .. tableToString(v, indent + 2) .. ",\n" | |||
else | |||
toprint = toprint .. "\"" .. tostring(v) .. "\",\n" | |||
end | |||
end | |||
toprint = toprint .. string.rep(" ", indent - 2) .. "}" | |||
return toprint | |||
end | |||
function p.Versuch(frame) | function p.Versuch(frame) | ||
| Zeile 19: | Zeile 44: | ||
data, errors = mw.ext.externalData.getExternalData {'https://www.mediawiki.org/w/api.php?action=query&meta=siteinfo&format=json'} | data, errors = mw.ext.externalData.getExternalData {'https://www.mediawiki.org/w/api.php?action=query&meta=siteinfo&format=json'} | ||
json = not errors and data.__json or false | json = not errors and data.__json or false | ||
return json, errors | return json, tableToString(errors) | ||
end | end | ||
return p | return p | ||
Version vom 12. Mai 2025, 12:21 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Stadtwikis/Doku erstellt werden
local p = {}
--local c = require( "Module:Common" )
function tableToString(tbl, indent)
indent = indent or 0
local toprint = string.rep(" ", indent) .. "{\n"
indent = indent + 2
for k, v in pairs(tbl) do
toprint = toprint .. string.rep(" ", indent)
if type(k) == "number" then
toprint = toprint .. "[" .. k .. "] = "
elseif type(k) == "string" then
toprint = toprint .. k .. " = "
end
if type(v) == "number" then
toprint = toprint .. v .. ",\n"
elseif type(v) == "string" then
toprint = toprint .. "\"" .. v .. "\",\n"
elseif type(v) == "table" then
toprint = toprint .. tableToString(v, indent + 2) .. ",\n"
else
toprint = toprint .. "\"" .. tostring(v) .. "\",\n"
end
end
toprint = toprint .. string.rep(" ", indent - 2) .. "}"
return toprint
end
function p.Versuch(frame)
--pf = frame:getParent()
--args = pf.args
--url = frame.args.url or ""
--e,t=mw.ext.externaldata.getWebData {
-- url = "https://www.fuerthwiki.de/wiki/api.php?action=query&meta=siteinfo&siprop=statistics&format=json;",
-- extract = "*",
-- format = "json"}
--data, errors = mw.ext.externalData.getExternalData('https://www.mediawiki.org/w/api.php?action=query&meta=siteinfo&format=json')
--json = not errors and data.__json or false
--t=mw.ext.externaldata.getWebData {"https://www.fuerthwiki.de/wiki/api.php?action=query&meta=siteinfo&siprop=statistics&format=json",
-- extract="*",
-- format="json"
--}
data, errors = mw.ext.externalData.getExternalData {'https://www.mediawiki.org/w/api.php?action=query&meta=siteinfo&format=json'}
json = not errors and data.__json or false
return json, tableToString(errors)
end
return p