Modul:Stadtwikis: Unterschied zwischen den Versionen

Aus FürthWiki

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 4: Zeile 4:
--local http = require("mw.http")
--local http = require("mw.http")
--local json = require("mw.text").jsonDecode
--local json = require("mw.text").jsonDecode
function p.Versuch(frame)
function p.Trennenen(frame)
local urls = {"https://www.fuerthwiki.de/wiki/api.php",  
local urls = {"https://www.fuerthwiki.de/wiki/api.php",  
    "https://oesterreichwiki.org/w/api.php",
    "https://oesterreichwiki.org/w/api.php",
Zeile 25: Zeile 25:
-- "https://wuerzburgwiki.de/w/api.php",
-- "https://wuerzburgwiki.de/w/api.php",
----------------------------------------------------------------------------
----------------------------------------------------------------------------
return
end
function Versuch(frame)
ep_stat = "?action=query&meta=siteinfo&siprop=statistics&format=json"
ep_stat = "?action=query&meta=siteinfo&siprop=statistics&format=json"
ep_info = "?action=query&meta=siteinfo&format=json"
ep_info = "?action=query&meta=siteinfo&format=json"
      
      
     --local urls = {
     local urls = {
    --    "https://www.fuerthwiki.de/wiki/api.php",
        "https://www.fuerthwiki.de/wiki/api.php",
    --    "https://www.tuepedia.de/api.php"
        "https://www.tuepedia.de/api.php"
     --}
     }
     local results = {}
     local results = {}
     for i = 1, #urls do
     for i = 1, #urls do
Zeile 42: Zeile 46:
         }
         }
     end
     end
   
h='<table class="wikitable sortable"><tr>'..
    local output = {}
'<th>Wiki URL</th>'..
    for i, pair in ipairs(results) do
'<th>Artikel</th>'..
        --local a = pair.A and pair.A.query and pair.A.query.statistics and pair.A.query.statistics.edits or "?"
'<th>Bilder</th>'..
        --local b = pair.B and pair.B.query and pair.B.query.statistics and pair.B.query.statistics.edits or "?"
'<th>Bearbeitungen</th>'..
        --table.insert(output, string.format("Zeile %d: A = %s, B = %s", i, a, b))
'<th>Benutzer</th>'..
    mw.log("Stats: " .. mw.dumpObject(pair))
'<th>Aktive</th>'..
    end
'<th>Admins</th>'..
 
'</tr>'
    return tableToString(results) --table.concat(output, "<br>")
return tableToString(results)
end
end



Version vom 14. Mai 2025, 17:05 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.Trennenen(frame)
	local 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"
	}
		    -- "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
end

function Versuch(frame)	
	ep_stat = "?action=query&meta=siteinfo&siprop=statistics&format=json"
	ep_info = "?action=query&meta=siteinfo&format=json"
    
    local urls = {
        "https://www.fuerthwiki.de/wiki/api.php",
        "https://www.tuepedia.de/api.php"
    }
    local results = {}
    for i = 1, #urls do
        local data_stat = mw.ext.externalData.getWebData{ url = urls[i]..ep_stat, format = "json" }
        local data_info = mw.ext.externalData.getWebData{ url = urls[i]..ep_info, format = "json" }

        results[i] = {
            stat = mw.clone(data_stat),
            info = mw.clone(data_info)
        }
    end
    
    local output = {}
    for i, pair in ipairs(results) do
        --local a = pair.A and pair.A.query and pair.A.query.statistics and pair.A.query.statistics.edits or "?"
        --local b = pair.B and pair.B.query and pair.B.query.statistics and pair.B.query.statistics.edits or "?"
        --table.insert(output, string.format("Zeile %d: A = %s, B = %s", i, a, b))
    	mw.log("Stats: " .. mw.dumpObject(pair))
    end

    return tableToString(results) --table.concat(output, "<br>")
end

function Garbage()
	----------------------------------------------------------------------------
	results = {}
	for i, u in ipairs(urls) do
		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"
		}
		results[i] = {
			A=mw.clone(stat),
			B=mw.clone(info)
		}
	end
	
	mw.log("Results: " .. mw.dumpObject(results))

	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