Modulo:Wikibase

El Vikifontaro

Dokumentado por ĉi tiu modulo povas esti kreata ĉe Modulo:Wikibase/dokumentado

-- Module:Wikibase
function getId( id )
    if not mw.wikibase then
           return "vikibaza modulo ne trovita"
    end
    
    if id then return id end
    
    entity = mw.wikibase.getEntity()
    if not entity then return nil end
    return entity.id
end

-- Returns the link corresponding to the code provided.
function sitelink(dbname, id)
    if dbname==nil or dbname=='' then
        return ''
    end
    local sl = mw.wikibase.getEntityObject(id)
    if sl and sl.sitelinks[dbname] then
        return sl.sitelinks[dbname].title
    end
    return ''
end

local p = {}
-- Returns the title of a data item provided in Esperanto.
function p.page(frame)
    id = getId(frame.args[1])
    if id == nil then
           return "(ero ne trovita)"
    end

    local sl = sitelink('eowiki', id)
    if sl~=nil and sl~='' then
        return sl
    end

    return id
end

return p