Ir al contenido

Diferencia entre revisiones de «Módulo:Wikibase»

m Protegió «Módulo:Wikibase»: recuperar protección ([Editar=Solo bibliotecarios] (indefinido) [Pueden trasladar=Solo bibliotecarios] (indefinido))
Actualización de funciones de Módulo:Wikibase, más específicamente desde esta versión
Línea 8: Línea 8:
         end
         end
   
   
         entity = mw.wikibase.getEntityObject()
         id = mw.wikibase.getEntityIdForCurrentPage()
   
   
         if entity == nil then
         if id == nil then
           return ""
           return ""
         end
         end
   
   
         return entity.id
         return id
end
end
   
   
Línea 20: Línea 20:
function p.etiqueta(frame)
function p.etiqueta(frame)
         if frame.args[1] == nil then
         if frame.args[1] == nil then
             entity = mw.wikibase.getEntityObject()
             label = mw.wikibase.getLabel()
            if not entity then return nil end
            id = entity.id
         else
         else
             id = frame.args[1]
             label = mw.wikibase.getLabel(frame.args[1])
         end
         end
   
   
         return mw.wikibase.label( id )
         return label
end
end
   
   
Línea 34: Línea 31:
function p.enlace(frame)
function p.enlace(frame)
         if frame.args[1] == nil then
         if frame.args[1] == nil then
             entity = mw.wikibase.getEntityObject()
             id = mw.wikibase.getEntityIdForCurrentPage()
             if not entity then return nil end
             if not id then return nil end
            id = entity.id
         else
         else
             id = frame.args[1]
             id = frame.args[1]
         end
         end
   
   
         return mw.wikibase.sitelink( id )
         return mw.wikibase.getSitelink( id )
end
end


Línea 48: Línea 43:
function p.descripcion(frame)
function p.descripcion(frame)
         if frame.args[1] == nil then
         if frame.args[1] == nil then
             entity = mw.wikibase.getEntityObject()
             desc = mw.wikibase.getDescription()
            if not entity then return nil end
            id = entity.id
         else
         else
             id = frame.args[1]
             desc = mw.wikibase.getDescription(frame.args[1])
         end
         end
   
   
         return mw.wikibase.description( id )
         return desc
end
end
   
   
return p
return p

Revisión del 02:48 20 feb 2021

La documentación para este módulo puede ser creada en Módulo:Wikibase/doc

-- Module:Wikibase
local p = {}
 
-- Devuelve la ID del ítem, el nombre o el enlace de la página en la wiki local.
function p.id(frame)
        if not mw.wikibase then
           return "módulo wikibase no encontrado"
        end
 
        id = mw.wikibase.getEntityIdForCurrentPage()
 
        if id == nil then
           return ""
        end
 
        return id
end
 
-- Devuelve la etiqueta de un ítem dado.
function p.etiqueta(frame)
        if frame.args[1] == nil then
            label = mw.wikibase.getLabel()
        else
            label = mw.wikibase.getLabel(frame.args[1])
        end
 
        return label
end
 
-- Devuelve la página local de un ítem dado.
function p.enlace(frame)
        if frame.args[1] == nil then
            id = mw.wikibase.getEntityIdForCurrentPage()
            if not id then return nil end
        else
            id = frame.args[1]
        end
 
        return mw.wikibase.getSitelink( id )
end

-- Devuelve la descripción de un ítem dado.
function p.descripcion(frame)
        if frame.args[1] == nil then
            desc = mw.wikibase.getDescription()
        else
            desc = mw.wikibase.getDescription(frame.args[1])
        end
 
        return desc
end
 
return p