Diferencia entre revisiones de «Módulo:Enlaces»
Contenido eliminado Contenido añadido
Sin resumen de edición |
alpha0.1 |
||
Línea 1:
-- The sister project linking module
local p = {}
local Wikidata = require('Módulo:Wikidata')
local function getsize(tab)
count=0
Línea 8 ⟶ 9:
return count
end
local relevants = { --{['name']='',['image']='',['text']='',['prefix']='',}
['commonswiki'] = { ['name'] = 'Wikimedia Commons',
['
['
['
['
['specieswiki'] = 'Wikispecies',▼
['
['
['text'] = 'Noticias',
['
['
▲ ['wikinews'] = 'Wikinews',
['
['
['
['wikispecies'] = 'Wikispecies',▼
['
['prefix'] = 'es:wikiquote',},
▲ ['specieswiki'] = { ['name'] = 'Wikispecies',
}▼
end▼
['prefix'] = 'species:',},
['eswikiversity'] = { ['name'] = 'Wikiversity',
['text'] = 'Wikiversidad',
▲ ['commonswiki'] = 'Commons-logo.svg|link=c:',
['wikidata'] = { ['name'] = 'Wikidata',
▲ ['eswikibooks'] = 'Wikibooks-logo.svg|link=wikibooks:',
['
['text'] = 'Wikidata',
▲ ['eswiki'] = 'Wikipedia-logo-simple.png|link=w:',
['prefix'] = 'd:',},}
▲ ['eswikiquote'] = 'Wikiquote-logo.svg|link=wikiquote:',
▲ ['specieswiki'] = 'Wikispecies-logo.svg|link=species:',
▲ ['eswikiversity'] = 'Wikiversity-logo.svg|link=wikiversity:',
end▼
-- Function for getting the text for the project
local function getProjectText( frame )
Línea 62 ⟶ 59:
return projecttext[ frame.args[ 'project' ] ]
end
▲ ['wikiversity'] = 'wikiversity:',
end▼
-- The function to generate the links in the proper format
local function generateLinks( frame )
Línea 114 ⟶ 95:
return output
end
--todos los enlaces
function p.links(frame)
local output =
local Entidad = mw.wikibase.getEntityObject()
if Entidad then
mw.log('has entity')
output["wikidata"]["title"]=Entidad.id
-- mw.logObject( Entidad )
if getsize(Entidad["sitelinks"]) > 1 then
mw.log('has sitelinks')
for k, v in pairs(Entidad["sitelinks"]) do
if
output[k]["title"]=v["title"]
end
end
Línea 135 ⟶ 117:
newEntidad = mw.wikibase.getEntityObject(P629)
for k, v in pairs(newEntidad["sitelinks"]) do
if
output[k]["title"]=v["title"]
end
end
▲ end
-- categoría en commons
if not output[k]['commonswiki']['title'] and Entidad["claims"]["P373"] then
mw.log('has P373 commonscat')
output[k]['commonswiki']['title'] = 'Category:'..propiedad('P373')
end
end
mw.logObject(output)
return output
end
Línea 159 ⟶ 147:
return frame:preprocess( output )
▲end
function propiedad(idPropiedad,opciones)
if Entidad and Entidad.claims then --and Entidad.claims[idPropiedad] then
if not opciones then
opciones = {}
end
opciones['propiedad'] = idPropiedad
valorPropiedad = Wikidata.getPropiedad(opciones,Entidad.claims[idPropiedad])
if not valorPropiedad or valorPropiedad == '' then
return ''
end
return valorPropiedad
else return ''
▲ end
end
return p
|