Modulo:Ciclismo: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nuovo modulo
 
m modulo no globals obsoleto
 
(6 versioni intermedie di 3 utenti non mostrate)
Riga 1:
--[[
* Module implementing "Template:Tappe corsa ciclismo" and "Template:Vincitori corsa ciclismo".
* Author: httphttps://it.wikipedia.org/wiki/User:Rotpunkt
]]--
 
require('Module:No globalsstrict')
 
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Module:Wikidata')
local cfg = mw.loadData("Modulo'Module:BioCiclismo/Configurazione"Configuration')
cfg.local i18n = cfg.i18n[mw.language.getContentLanguage():getCode()]
 
-------------------------------------------------------------------------------
Riga 25 ⟶ 26:
setmetatable(self, { __index = StagesTable })
self.stages = {}
local lang = mw.language.getContentLanguage()
local ids = mWikidata._getProperty( { 'P527', formatting = 'raw', from = from }, true ) or {}
for _, id in ipairs(ids) do
local timestamp = mWikidata._getProperty( { 'P585', n = 1, formatting = 'raw', from = id } )
local year, month, day = timestamp:match('(%d+)%-(%d%d)%-(%d%d).+')
local lang = mw.language.getContentLanguage()
local month = lang:formatDate('F', tonumber(year) .. '-' .. month .. '-' .. day)
self.stages[#self.stages + 1] = {
Riga 37 ⟶ 38:
origin = mWikidata._getProperty( { 'P1427', n = 1, from = id } ),
destination = mWikidata._getProperty( { 'P1444', n = 1, from = id } ),
length = mWikidata._getProperty( { 'P2043P3157', n = 1, unit = 'km', formatnum = true , from = id } )
}
end
Riga 52 ⟶ 53:
local tableNode = mw.html.create('table'):addClass('wikitable'):css(tableStyle)
local tr = tableNode:tag('tr')
tr:tag('th'):wikitext(cfg.i18n.thStage)
tr:tag('th'):wikitext(cfg.i18n.thDate)
tr:tag('th'):wikitext(cfg.i18n.thCourse)
tr:tag('th'):wikitext(cfg.i18n.thDistance)
tr:tag('th'):wikitext(cfg.i18n.thWinnerthStageWinner)
tr:tag('th'):wikitext(cfg.i18n.thLeader)
 
for _, stage in ipairs(self.stages) do
Riga 110 ⟶ 111:
local tableNode = mw.html.create('table'):addClass('wikitable'):css(tableStyle)
local tr = tableNode:tag('tr')
tr:tag('th'):wikitext(cfg.i18n.thYear)
tr:tag('th'):wikitext(cfg.i18n.thWinner)
tr:tag('th'):wikitext(cfg.i18n.thSecond)
tr:tag('th'):wikitext(cfg.i18n.thThird)
 
for _, edition in ipairs(self.editions) do