Module:Temporary exhibition
Jump to navigation
Jump to search
Lua
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules
Template for Template:Temporary Exhibition.
p.exhibLine(item)
creates a string providing basic data about an exhibition (name, place, date).
Code
local p = {}
local wd = require "Module:Wikidata"
local linguistic = require "Module:Linguistic"
local lang = mw.getCurrentFrame():callParserFunction("int", "lang")
local function catLink(cat)
return "[[File:Commons logo optimized.svg|12px|link=Category:" .. cat .. "]]"
end
function p.exhibLine(item)
-- clean up args from frame
if type(item) == 'table' and item.args then
item = item.args[1]
end
if (not item) or (item == "") then
return nil
end
local elements = {}
-- name
table.insert(elements, "<i>" .. wd._getLabel(item) .. "</i>") -- formatting should be language dependent, port [[Template:Italics]] to module:Linguistic
-- location
local places = wd.getClaims{entity = item, property = "P276"}
table.insert(elements, places and wd.formatStatements{
claims = places,
showdate = (places and (#places >1) ) -- if only one place, use main P580 / P582 rather than qualifiers, more chance to have that filled
})
-- date
if places and #places == 1 then
table.insert(elements, wd._main_date(item))
end
-- category link
local cat = wd.formatStatements{item = item, property = "P373", numval = 1}
if cat then
table.insert(elements, catLink(cat))
end
return linguistic.conj(elements, lang, "comma")
end
return p