Modül:Futbol maçı kutusu
Modül belgelemesi[oluştur]
Bu modül şu Lua modülünü kullanıyor: |
-- Implements [[Şablon:Futbol maçı kutusu]]
local p = {}
local lang = nil
local delink = require('Modül:Bağlantıyı kes')._delink
local eventschema = "http://schema.org/SportsEvent"
local teamschema = "http://schema.org/SportsTeam"
local placeschema = "http://schema.org/Place"
local penalties = '[[Penaltı vuruşları (futbol)|Penaltılar]]'
local aet = '[[Uzatma süresi#Futbol|uz.]]'
local asdet = '[[Ani ölüm (spor)#Futbol|a.ö.]]'
local agget = '[[Uzatma süresi#Futbol|uz.]]/[[Altın gol#Futbol|a.g.]]'
local asget = '[[Uzatma süresi#Futbol|uz.]]/[[Altın gol#Gümüş gol|g.g.]]'
local attendance = 'Seyirci:'
local referee = 'Hakem:'
local templatestyles = 'Modül:Futbol maçı kutusu/styles.css'
local tracking, preview
local function checkarg(k,v)
if not k or type(k) ~= 'string' then return end
if k == 'assistantreferees2' then
elseif k == 'aggregatescore' or k == 'assistantreferees' or
k == 'fourthofficial' or k == 'game' or k == 'motm' or
k == 'nobars' or k == 'note' or k == 'result' then
-- valid and tracked
table.insert(tracking, '[[Kategori:Pages using football box with ' .. k .. ']]')
elseif k == 'size' or k == 'bg' or k == 'id' or k == 'event' or
k == 'date' or k == 'time' or k == 'round' or k == 'team1' or
k == 'team2' or k == 'score1' or k == 'score2' or k == 'score' or k == 'scorenote' or
k == 'aet' or k == 'asdet' or k == 'agget' or k == 'asget' or k == 'goals1' or k == 'report' or k == 'goals2' or
k == 'penaltyscore' or k == 'penalties1' or k == 'penalties2' or
k == 'stadium' or k == 'location' or k == 'attendance' or
k == 'referee' or k == 'stack' then
-- valid and not tracked
else
-- invalid
local vlen = mw.ustring.len(k)
k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25)
k = mw.ustring.gsub(k, '[^%w\-_ ]', '?')
table.insert(tracking, '[[Kategori:Pages using football box with unknown parameters|' .. k .. ']]')
table.insert(preview, '"' .. k .. '"')
end
end
local function timestamp(d, t)
if not d then return nil end
lang = lang or mw.language.getContentLanguage() -- lazy initialize
local success, timestamp = pcall(lang.formatDate, lang, 'c', delink({d .. ' ' .. (t or '')}))
if success then
return timestamp
else
return nil
end
end
local function fmtlist(s)
s = mw.ustring.gsub(s or '', '%[%[ *([%?-]) *%]%]', '%1')
s = mw.ustring.gsub(s, '%[%[ *[%?-] *| *(.-) *%]%]', '%1')
if mw.ustring.sub(s, 1, 1) == '*' then
return tostring(mw.html.create('div'):addClass('plainlist'):newline():wikitext(s))
end
return s
end
local function makelink(s,t)
if s:match('^[Hh][Tt][Tt][Pp][Ss]?:[^ ]*$') then
return '[' .. s .. ' ' .. t .. ']'
end
return s
end
local function trim(s)
return s:match('^[\'"%s]*(.-)[\'"%s]*$')
end
local function getid(s)
s = trim(s or '')
if s and s ~= '' then
return s
end
return nil
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
local id = getid(args['id'] or args['tanım'])
local d = timestamp(args['date'] or args['tarih'], args['time'] or args['zaman'])
local block
tracking, preview = {}, {}
for k, v in pairs(args) do
if v ~= '' then
checkarg(k,v)
end
end
local score = 'v'
if args['score1'] or args['sonuç1'] or args['score2'] or args['sonuç2'] then
score = (args['score1'] or args['sonuç1'] or '0') .. '-' .. (args['score2'] or args['sonuç2'] or '0')
elseif (args['score'] and args['score'] ~= '') or (args['sonuç'] and args['sonuç'] ~= '') then
score = args['score'] or args['sonuç']
end
if args['aet'] or args['uzatma'] then
score = score .. ' (' .. aet .. ')'
elseif args['asdet'] then
score = score .. ' (' .. asdet .. ')'
elseif args['agget'] then
score = score .. ' (' .. agget .. ')'
elseif args['asget'] then
score = score .. ' (' .. asget .. ')'
end
if args['scorenote'] or args['sonuç_not'] then
score = score .. '<br>' .. args['scorenote'] or args['sonuç_not']
end
-- Start box
local root =
mw.html.create('div')
:attr('itemscope', '')
:attr('itemtype', eventschema)
:addClass('footballbox')
:css('width', args['size'] or args['boyut'])
:css('background-color', args['bg'] or args['arkaplan'])
:attr('id', id)
root:newline()
if args['event'] or args['müsabaka'] then
root:tag('div')
:addClass('ftitle')
:wikitext(args['event'] or args['müsabaka'])
end
-- Start left block
block = root:tag('div')
:addClass('fleft')
local timetag = block:tag('time')
:attr('itemprop', d and 'startDate' or nil)
:attr('datetime', d)
timetag:tag('div')
:addClass('fdate')
:wikitext(args['date'] or args['tarih'])
if args['time'] or args['zaman'] then
timetag:tag('div')
:addClass('ftime')
:wikitext(args['time'] or args['zaman'])
end
if args['round'] or args['tur'] then
block:tag('div')
:addClass('frnd')
:wikitext(args['round'] or args['tur'])
end
-- End block
-- Start table
local rtable = root:tag('table')
:addClass('fevent')
local row = rtable:tag('tr')
:attr('itemprop', 'name')
row:newline()
row:tag('th')
:addClass('fhome')
:attr('itemprop', 'homeTeam')
:attr('itemscope', '')
:attr('itemtype', teamschema)
:tag('span')
:attr('itemprop', 'name')
:wikitext(args['team1'] or args['takım1'])
row:tag('th')
:addClass('fscore')
:wikitext(score)
row:tag('th')
:addClass('faway')
:attr('itemprop', 'awayTeam')
:attr('itemscope', '')
:attr('itemtype', teamschema)
:tag('span')
:attr('itemprop', 'name')
:wikitext(args['team2'] or args['takım2'])
row = rtable:tag('tr')
:addClass('fgoals')
:newline()
row:tag('td')
:addClass('fhgoal')
:wikitext(fmtlist(args['goals1'] or args['goller1']))
row:newline()
row:tag('td')
:wikitext(makelink(args['report'] or args['rapor'] or '', 'Rapor'))
row:newline()
row:tag('td')
:addClass('fagoal')
:wikitext(fmtlist(args['goals2'] or args['goller2']))
row:newline()
if args['penaltyscore'] then
rtable
:tag('tr')
:tag('th')
:attr('colspan', 3)
:wikitext(penalties)
row = rtable:tag('tr')
:addClass('fgoals')
row:newline()
row:tag('td')
:addClass('fhgoal')
:wikitext(fmtlist(args['penalties1']))
row:newline()
row:tag('th')
:wikitext(args['penaltyscore'])
row:newline()
row:tag('td')
:addClass('fagoal')
:wikitext(fmtlist(args['penalties2']))
row:newline()
end
-- End table
-- Start right block
block = root:tag('div')
:addClass('fright')
if args['stadium'] or args['stadyum'] then
local sdiv = block:tag('div')
:attr('itemprop', 'location')
:attr('itemscope', '')
:attr('itemtype', placeschema)
if args['location'] or args['yer'] then
sdiv:tag('span')
:attr('itemprop', 'name')
:wikitext(args['stadium'] or args['stadyum'])
sdiv:wikitext(', ')
sdiv:tag('span')
:attr('itemprop', 'address')
:wikitext(args['location'] or args['yer'])
else
sdiv:tag('span')
:attr('itemprop', 'name address')
:wikitext(args['stadium'] or args['stadyum'])
end
end
if args['attendance'] or args['seyirci'] then
block:tag('div'):wikitext(attendance ..' ' .. args['attendance'] or args['seyirci'])
end
if args['referee'] or args['hakem'] then
block:tag('div'):wikitext(referee .. ' ' .. args['referee'] or args['hakem'])
end
local trackstr = (#tracking > 0) and table.concat(tracking, '') or ''
if #preview > 0 and frame:preprocess( "{{REVISIONID}}" ) == "" then
trackstr = tostring(mw.html.create('div')
:addClass('hatnote')
:css('color','red')
:tag('strong'):wikitext('Warning:'):done()
:wikitext('Unknown parameters: ' .. table.concat(preview, '; ')))
end
return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(root) .. trackstr
end
return p