Modulis:Infokaste/Funkcijas
Izskats
Lua kļūda Modulis:Documentation, 144. rinda: message: type error in message cfg.container (string expected, got nil).
--oriģkods: fr:Module:Infobox/Fonctions
-- Fonctions communes à diverses infobox
local wikidata = require 'Module:Interface Wikidata'.fromLua
local coordfunctions = require 'Modulis:Infokaste/Funkcijas/Ģeo'
local lang = mw.language.new('fr')
local p = {}
function p.title(icon, style, subtitleparam, subtitlequery)
local title = localdata['nom']
if not title then
title = lang:ucfirst(wikidata.getLabel(item) or mw.title.getCurrentTitle().text)
end
if subtitleparam then
subtitle = localdata[subtitleparam]
end
if (not subtitle) and subtitlequery then
subtitle = wikidata.formatStatements(subtitlequery)
end
return {
type = 'title',
value = function() return title end,
subtitle = function() return subtitle end,
icon = icon,
style = style,
}
end
function p.mainimage(cat, defaultimage, size, upright)
return {
type = 'images',
imageparameters = {'image'},
defaultimages = defaultimage,
defaultimagelink = 'Aide:Insérer une image',
sizeparameter = 'taille image',
uprightparameter = 'upright',
defaultupright = upright,
defaultsize = size,
maintenancecat =
function(localdata, item, params)
if cat and (cat ~= '-') then
return cat
else
return 'Article à illustrer'
end
end,
captionparameter = 'légende',
defaultcaption = function() return defaultcaption end,
property = 'P18',
numval = 1,
}
end
function p.logo(upright)
return {
type = 'images',
imageparameters = {'logo'},
-- defaultimage = {},
-- maintenancecat =
captionparameter = 'légende logo',
property = 'P154',
defaultupright = upright or '0.6',
uprightparameter = 'upright logo',
sizeparameter = 'taille logo',
numval = 1,
}
end
-- Liens externes
function p.website() --texte libre [http://example.org example.org] ou url seule
local function getLinks(item)
return wikidata.getClaims {property='P856', entity = item}
end
return {
type = 'mixed',
label = 'Site web',
wikidatalabel = function()
local links = getLinks(item)
if links and #links > 1 then
return 'Sites web'
end
return 'Site web'
end,
wikidata = function()
local claims = getLinks(item)
return wikidata.formatAndCat{entity = item, claims = claims, displayformat = 'weblink', conjtype = '<br />', property = 'P856'}
end,
value = function(localdata)
local website = localdata['site web'] or localdata['site_web'] or localdata['site officiel']
if website then
if (string.sub(website, 1, 4) == 'http') and (not string.find(website, ' ')) then -- if website is url
return require("Module:Weblink").makelink(website)
else
return website
end
elseif localdata['url'] then
return require("Module:Weblink").makelink(localdata['url'])
end
end
}
end
-- Pays
function p.country(default)
return coordfunctions.country(default)
end
return p