Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
break all the pages
let's see how broke this sandbox can be
Line 2:
 
local p = {}
local data = require('Module:Video game reviews/data/sandbox')
local yesno = require('Module:Yesno')
local vgwd = require('Module:Video game wikidata')
Line 23:
local reviewers, aggregators, awards = {}, {}, {}
for k in pairs(args) do
if string.match(k, '^rev%d+$'data.i18n.pattern.reviewer) then
table.insert(reviewers, k)
elseif string.match(k, '^agg%d+$'data.i18n.pattern.aggregator) then
table.insert(aggregators, k)
elseif string.match(k, '^data.i18n.pattern.award%d+$') then
table.insert(awards, k)
end
Line 76:
end)
return providedReviewers, providedAggregators
end
 
local function renderTitleRow(tbl, title)
local titleCell = tbl:tag('tr'):tag('th')
 
if title then
titleCell
:wikitext(title)
else
titleCell
:addClass('Reception')
:wikitext(data.i18n.reception)
end
end
 
local function renderMainHeading(builder, colspan, headingText, borderTop)
builder:tag('tr')
:tag('th')
:attr('colspan', colspan)
:css('background', '#d1dbdf')
:css('border-top', borderTop)
:wikitext(headingText)
:done()
end
 
Line 102 ⟶ 91:
renderMainHeading(builder, #activeSystems + 1, mainHeading)
builder:tag('tr')
:tag('th')
:attr('rowspan', '2')
:css('background', '#e8f4f8')
:css('text-align', 'center')
:css('vertical-align', 'middle')
:wikitext(data.i18n.publication)
:done()
:tag('th')
:attr('colspan', #activeSystems)
:css('background', '#e8f4f8')
:css('vertical-align', 'middle')
:wikitext(data.i18n.score)
:done()
builder = builder:tag('tr')
for _, v in ipairs(activeSystems) do
Line 123 ⟶ 113:
renderMainHeading(builder, 2, mainHeading)
builder
:tag('tr')
:tag('th')
:css('background', '#e8f4f8')
:css('text-align', 'center')
:css('vertical-align', 'middle')
:wikitext(nameHeading)
:done()
:tag('th')
:css('background', '#e8f4f8')
:css('vertical-align', 'middle')
:wikitext(data.i18n.score)
:done()
end
 
Line 139 ⟶ 130:
builder = builder:tag('tr')
builder:tag('td')
:css('vertical-align', 'middle')
:wikitext(name)
 
for _, v in ipairs(activeSystems) do
Line 147 ⟶ 138:
if args[combinedCode] then
cell
:css('vertical-align', 'middle')
:css('text-align', 'center')
:wikitext(args[combinedCode])
:done()
elseif na then
cell
:css('color', '#707070')
:css('vertical-align', 'middle')
:css('text-align', 'center')
:addClass('table-na')
:wikitext(data.i18n.na)
:done()
end
end
Line 163 ⟶ 156:
local function renderRating(builder, name, rating)
builder:tag('tr')
:tag('td')
:css('text-align', 'center')
:css('vertical-align', 'middle')
:wikitext(name)
:done()
:tag('td')
:css('text-align', 'center')
:wikitext(rating)
:done()
end
 
local function renderReviews(builder, providedReviewers, providedAggregators, activeSystems, customAggregatorKeys, customReviewerKeys, args)
builder = builder:tag('table')
:addClass('infobox wikitable')
:attr('cellpadding', 0)
:attr('cellspacing', 0)
Line 245 ⟶ 238:
local function renderAwards(builder, args, awardKeys, borderTop)
builder = builder:tag('table')
:addClass('infobox wikitable')
:css('width', '100%')
:css('margin', '0em0')
:css('border-top', borderTop)
:attr('cellpadding', 3)
Line 272 ⟶ 264:
:wikitext(args[v])
end
builder:done()
builder:done()
end
 
local function renderMainTablerender(providedReviewers, providedAggregators, awardKeys,
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local tbldiv = mw.html.create('tablediv')
:addClass('video-game-reviews')
:attr('cellpadding', 0)
:attr('cellspacing', 0)
if titleargs.align then
:css('background', 'transparent')
if args.align == 'left' then
:css('padding', '0em')
div:addClass('infobox wikitablevgr-left')
:css('margin', args.align and
((args.align == 'left' orelseif args.align == 'none') and '0em 1em 1em 0em') orthen
div:addClass('infobox wikitablevgr-none')
'0em 1em 1em 1em')
end
:css('text-align', 'center')
end
:css('float', args.align or 'right')
:css('clear', args.align or 'right')
 
if #activeSystems == 0 then
div:addClass('vgr-single')
-- Width: 20% Seems better since it scales with the article size.
:css('marginwidth', args.alignwidth or andnil)
tbl
:css('width', args.width or '23em')
end
 
if args.title and args.state and (args.state == 'autocollapse'
or args.state == 'collapsed' or args.state == 'expanded') then
tbldiv
:addClass('collapsible')
:addClass(args.state)
end
 
renderTitleRow(tbl, args.title)
div:tag('tablediv')
:addClass('Receptionvgr-title')
:wikitext(title or data.i18n.reception)
:done()
 
if args.subtitle then
tbldiv:tag('tr'):tag('thdiv')
:wikitextaddClass(args.'vgr-subtitle')
:wikitext(titleargs.subtitle)
:done()
end
 
renderReviews(tbl:tag('tr'):tag('td')
div,
providedReviewers,
providedAggregators,
activeSystems,
customAggregatorKeys,
customReviewerKeys,
args)
)
if #awardKeys ~= 0 then
local borderTop =
renderAwards(tbl:tag('tr'):tag('td'), args, awardKeys, (#customAggregatorKeys ~= 0 or #customReviewerKeys ~= 0 or #providedAggregators ~= 0 or #providedReviewers ~= 0) and 'none' or nil)
(#customAggregatorKeys ~= 0 or
#customReviewerKeys ~= 0 or
#providedAggregators ~= 0 or
#providedReviewers ~= 0
) and 'none' or nil
renderAwards(
div,
args,
awardKeys,
borderTop
)
end
 
if wikidata == true then
tbldiv:tag('tr'):tag('tddiv')
:addClass('vgr-edit-on-wikidata')
:tag('table')
-- TODO: I think getUpdateLink can be made const in the other module.
:addClass('infobox wikitable')
:wikitext('Edit on Wikidata 'data.i18n.editOnWikidata .. vgwd.getUpdateLink('nosub'))
:css('width', '100%')
:css('margin', '0em')
:css('border-top', 'none')
:attr('cellpadding', 3)
:attr('cellspacing', 0)
:tag('tr'):tag('th')
:css('background', '#d1dbdf')
:css('border-top', 'none')
:wikitext('Edit on Wikidata ' .. vgwd.getUpdateLink('nosub'))
end
 
return tbldiv
end
 
Line 384 ⟶ 394:
return frame:extensionTag{
name='templatestyles', args = { src = data.i18n.templatestyles }
} .. tostring(render(
renderMainTable(
providedReviewers,
providedAggregators,
Line 394 ⟶ 403:
args,
wikidata
))
)
elseif mw.title.getCurrentTitle().namespace == 0 then
return data.i18n.emptyCategory