Module:Jornal-pcd
Appearance
Documentation for this module may be created at Module:Jornal-pcd/doc
local p = {}
local lang = "pcd"
local img = "Newspaper Cover.svg"
local NS = mw.title.getCurrentTitle().namespace
local CatNS = mw.site.namespaces.Category.name
function p.main(frame)
if frame.args.wd == nil or frame.args.wd == "" then return end
-- data from Wikidata
local item = mw.wikibase.getEntity(frame.args.wd)
local html = mw.html.create()
if item == nil then
return "I n' a poin éd donnèes su Wikidata avu chole ID « "..frame.args.wd.." »"
end
if NS == 0 then
html:wikitext('[['..CatNS..':Picard]]')
html:wikitext('[['..CatNS..':Jornals in picard]]')
if frame.args.index ~= nil and frame.args.index ~= "" then
local I = string.upper(frame.args.index)
div_index = mw.html.create( 'div' )
div_index:wikitext('[[Wikisource:mags-'..I..'|mag Index: '..I..']]')
html:wikitext('[['..CatNS..':mags-'..I..']]')
end
end
div_mag = mw.html.create( 'div' )
div_mag:css({
["margin-bottom"] = "1em",
["border"] = "1px solid #a9a9a9",
["background"] = "#e0e0e0",
["overflow"] = "auto",
["padding"] = "10px",
["border-radius"] = "10px",
["box-shadow"] = "0 0 10px #a9a9a9"
})
div_mag_text = mw.html.create( 'div' )
div_mag_text:css({
["margin-left"] = "200px"
})
div_iw = mw.html.create( 'div' )
div_iw:css({
["float"] = "right"
})
-- index
if div_index ~= nil then div_iw:node( div_index ) end
-- Wikidata
if item.id~= nil then
div_iw:wikitext( '<div>[[:d:'..item.id..'|Wikidata]]</div>' )
end
-- Wikipedia
local iwd = item:getSitelink( lang..'wiki' )
if iwd ~= nil then
div_iw:wikitext( '<div>[[:w:'..lang..':'..iwd..'|Wikipedia]]</div>' )
end
-- Commons
local iwc = item:formatPropertyValues('P373').value
if iwc ~= nil and iwc ~= '' then
div_iw:wikitext( '<div>[[:c:Category:'..iwc..'|Commons]]</div>' )
end
div_mag:node( div_iw )
div_mag:wikitext( '[[File:'..img..'|left|128px]]' )
local nameWD = item:getLabel(lang)
local nameWD_fr = item:getLabel('fr')
if nameWD == nil then nameWD = "?" end
div_mag_name = mw.html.create( 'div' )
div_mag_fname = mw.html.create( 'span' )
div_mag_fname:css({
["font-weight"] = "bold",
["font-family"] = "sherif",
["font-size"] = "200%"
})
div_mag_fname:wikitext(nameWD)
div_mag_name:node( div_mag_fname )
local altname = ""
if nameWD_fr ~= nil and nameWD_fr ~= "" and nameWD_fr ~= nameWD then
altname = '<abbr title="poin in franchoés">n.f.</abbr> ' .. nameWD_fr
if altname ~= "" then
div_mag_name:wikitext(' ('..altname..')')
end
end
div_mag_text:node( div_mag_name )
local startWD = item:getBestStatements('P571')
local endWD = item:getBestStatements('P582')
if startWD == nil or startWD[1] == nil then startWD = "?" else startWD = string.sub(startWD[1].mainsnak.datavalue.value.time, 2, 5) end
if endWD == nil or endWD[1] == nil then endWD = "?" else endWD = string.sub(endWD[1].mainsnak.datavalue.value.time, 2, 5) end
div_mag_dates = mw.html.create( 'div' )
div_mag_dates:wikitext(startWD.." — "..endWD)
div_mag_text:node( div_mag_dates )
local descWD = item:getDescription( lang )
if descWD == nil then descWD = "''i n' y a coère poined déscripcion su Wikidata pour chele jornal-lo''" end
div_mag_des = mw.html.create( 'div' )
div_mag_des:wikitext(descWD)
div_mag_text:node( div_mag_des )
div_mag:node( div_mag_text )
html:node( div_mag )
return html
end
return p