Modul:Benutzer:Reinhard Kraasch/MyScript.lua

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Die Dokumentation für dieses Modul kann unter Modul:Benutzer:Reinhard Kraasch/MyScript.lua/Doku erstellt werden

local p = {} 
--local wd = require('Module:Wikidata')

function p.hello(frame)
    local name = frame.args[1]
    if not name then 
        name = 'Welt' 
    end
    return  'Hallo, ' .. name .. '! Dies ist Lua!' 
end 

function p.accessPage(frame)
    id  = mw.wikibase.getEntityIdForTitle( 'Berlin' )
    url = mw.wikibase.getEntityUrl(id)
    return url
end

function p.accessData(frame)
    prop = -1
    local arg = frame.args[1]
    if not arg then 
        arg = 'Berlin' 
    end
    id  = mw.wikibase.getEntityIdForTitle(arg)
    entity = mw.wikibase.getEntity(id)
    props = entity:getProperties()
    s = '<h1>' .. entity:getLabel() .. '</h1>\n' .. entity:getDescription() .. "\n\n"
    for k, v in pairs(props) do
    	pv = entity:formatPropertyValues(v)
    	s = s .. pv ['label'] .. ' (' .. v .. '): ' .. pv['value'] .. "\n"
    end
    return "<pre>" .. s .. "</pre>"
end

function p.getFinchLabel(frame)
    id = 'Q167'
    finchLabel = mw.wikibase.getLabel(id)
    return finchLabel
end
return p