Module:Basic

De Wikivoyage

La documentation pour ce module peut être créée à Module:Basic/doc

local p = {}
local entity = mw.wikibase.getEntityObject()

function p.id(frame)
    if entity ~= nil then
        return entity.id
    end
end

function p.commonscat(frame)
    local catname = mw.text.trim(frame.args[1]) -- catname could be empty
    if (entity ~= nil) and (entity.claims ~= nil) and (entity.claims.P373 ~= nil) then
        catname = entity.claims.P373[1].mainsnak.datavalue.value
    end
    if catname ~="" then
        return table.concat({"[[Commons:Category:", catname, "]]"}, "")
    end
end

function p.frwiki(frame)
    local articlename = mw.text.trim(frame.args[1])
    if (entity ~= nil) and (entity.sitelinks ~= nil) and (entity.sitelinks.frwiki ~= nil) then
        articlename = entity.sitelinks.frwiki.title
    end
    if articlename ~="" then
        return table.concat({articlename}, "")
    end
end

function p.latitude(frame)
    if (entity ~= nil) and (entity.claims ~= nil) and (entity.claims.P625 ~= nil) then
        return entity.claims.P625[1].mainsnak.datavalue.value.latitude
    end
end

function p.longitude(frame)
    if (entity ~= nil) and (entity.claims ~= nil) and (entity.claims.P625 ~= nil) then
        return entity.claims.P625[1].mainsnak.datavalue.value.longitude
    end
end

return p