Module:Wikiprojet/Wikiconcours
Apparence
[voir] [modifier] [historique] [purger]
Module remplaçant {{Wikiprojet/Wikiconcours}}, notamment afin de centraliser et simplifier les ajouts de concours.
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local p = {}
local data = {
['2006'] = { from = '15 novembre 2006' , to = '15 décembre 2006' , background = '#cfcf00' },
['2007'] = { from = '7 mai 2007' , to = '1er juillet 2007' , background = '#772f99', color = '#ffffff' },
['mars 2008'] = { from = '1er mars 2008' , to = '30 avril 2008' , background = '#009933', color = '#ffffff' },
['septembre 2008'] = { from = '1er septembre 2008', to = '31 octobre 2008' , background = '#ff6000' },
['mars 2009'] = { from = '1er mars 2009' , to = '30 avril 2009' , background = '#80d0d0' },
['septembre 2009'] = { from = '1er septembre 2009', to = '15 septembre 2009', background = '#b82010', color = '#ffffff' },
['mars 2010'] = { from = '1er mars 2010' , to = '30 avril 2010' , background = '#c8ad7f' },
['septembre 2010'] = { from = '15 septembre 2010' , to = '14 novembre 2010' , background = '#40e0d0' },
['mars 2011'] = { from = '1er mars 2011' , to = '15 mars 2011' , background = '#ff69b4' },
['septembre 2011'] = { from = '15 septembre 2011' , to = '14 novembre 2011' , background = '#868686', color = '#ffffff' },
['mars 2012'] = { from = '1er mars 2012' , to = '30 avril 2012' , background = '#f6ffbf' },
['octobre 2012'] = { from = '1er octobre 2012' , to = '15 octobre 2012' , background = '#dcb9dc' },
['mars 2013'] = { from = '1er mars 2013' , to = '30 avril 2013' , background = '#81b381' },
['septembre 2013'] = { from = '15 septembre 2013' , to = '14 novembre 2013' , background = '#ffffd0' },
['mars 2014'] = { from = '1er mars 2014' , to = '21 mars 2014' , background = '#d9e5fb' },
['septembre 2014'] = { from = '19 septembre 2014' , to = '23 novembre 2014' , background = '#efb776' },
['mars 2015'] = { from = '1er mars 2015' , to = '30 avril 2015' , background = '#fbc5b3' },
['octobre 2015'] = { from = '3 octobre 2015' , to = '1er novembre 2015', background = '#fbfcfa' },
['mars 2016'] = { from = '1er mars 2016' , to = '30 avril 2016' , background = '#82b395' },
['octobre 2016'] = { from = '1er octobre 2016' , to = '30 novembre 2016' , background = '#F6DC12' },
['mars 2017'] = { from = '1er mars 2017' , to = '21 mars 2017' , background = '#BBD2E1' },
['septembre 2017'] = { from = '15 septembre 2017' , to = '19 novembre 2017' , background = '#F5A9A9' },
['mars 2018'] = { from = '1er mars 2018' , to = '30 avril 2018' , background = '#CECECE' },
['septembre 2018'] = { from = '22 septembre 2018' , to = '21 octobre 2018' , background = '#F5DEB3' },
['mars 2019'] = { from = '1er mars 2019' , to = '30 avril 2019' , background = '#B2C6FF' },
}
-- exemple de résultat : « s’est déroulé du {{date-|22 septembre 2018-}} au {{date-|21 octobre 2018}} »
local function periode( from, to )
local moduleDate = require 'Module:Date'
local fromDay, fromMonth, fromYear = from:match( '(%S+) (%S+) (%S+)' )
local toDay, toMonth, toYear = to:match( '(%S+) (%S+) (%S+)' )
local fromISO = moduleDate.dateISO{ jour = fromDay, mois = fromMonth, annee = fromYear }
local toISO = moduleDate.dateISO{ jour = toDay, mois = toMonth, annee = toYear }
local todayISO = os.date( '%F' )
local verbe
if toISO < todayISO then
verbe = 's’est déroulé'
elseif todayISO < fromISO then
verbe = 'se déroulera'
else
verbe = 'se déroule'
end
local fromText = moduleDate.modeleDate{
fromDay,
fromMonth .. ( fromMonth == toMonth and '-' or '' ),
fromYear .. ( fromYear == toYear and '-' or '' ),
nolinks = true
}
local toText = moduleDate.modeleDate{
toDay,
toMonth,
toYear,
nolinks = true
}
return verbe .. ' du ' .. fromText .. ' au ' .. toText
end
local function row( edition, num_equipe )
local concours = data[ edition ]
local equipe
if edition == '2006' then
equipe = "{{u'|" .. num_equipe .. "}}" -- cas particulier édition 2006
else
equipe = 'l’[[Wikipédia:Wikiconcours/' .. edition .. '/Équipes/Équipe ' .. num_equipe .. '|équipe {{numéro}}' .. num_equipe .. ']]'
end
local background = ' background:' .. concours[ 'background' ] .. ';'
local color = ( concours[ 'color' ] and ' color:' .. concours[ 'color' ] .. ';' or '' )
return '<tr>'
.. '<td style="width:10%; text-align:center; font-weight:bold;' .. background .. color .. '">'
.. edition
.. '</td>'
.. '<td style="font-size:italic">'
.. 'Il a été choisi par ' .. equipe
.. " pour le '''[[Wikipédia:Wikiconcours/" .. edition .. "|Wikiconcours " .. edition .. "]]'''"
.. ' qui ' .. periode( concours[ 'from' ], concours[ 'to' ] ) .. '.'
.. '</td>'
.. '</tr>'
end
function p.main( frame )
local args = frame:getParent().args
local rows = {}
local categories = {}
local nocat = ( args.nocat and args.nocat ~= '' )
for k, v in pairs( args ) do
local edition = tostring( k ):match( '^wikiconcours (.+)$' )
if edition and data[ edition ] then
rows[ #rows + 1 ] = row( edition, v )
categories[ #categories + 1 ] = '[[Catégorie:Wikipédia:Wikiconcours/' .. edition .. '|{{PAGENAME}}]]'
end
end
if #rows > 0 then
return '<table style="background:#ededed; width:100%; margin-top:1.2em; border-spacing:0.6em 2px; padding:0.4em 0; border:1px solid #a7d7f9; border-radius:10px; border-collapse:separate;">'
.. '<caption style="padding-bottom:5px">'
.. '[[Image:Goldenwiki nostand.png|20px|Wikiconcours]]'
.. ' Cet article a été sélectionné lors ' .. ( #rows == 1 and 'd’un' or 'de plusieurs' ) .. ' [[Wikipédia:Wikiconcours|Wikiconcours]] :'
.. '</caption>'
.. table.concat( rows )
.. '</table>'
.. ( nocat and '' or table.concat( categories ) )
else
return ''
end
end
return p