Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
m formatting cleanup
sync to live
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/sandbox')
local getArgs
 
Line 34:
return tonumber(a:match('%d+')) < tonumber(b:match('%d+'))
end
 
table.sort(reviewers, comparator)
table.sort(aggregators, comparator)
Line 79 ⟶ 78:
end
 
local function renderTitlerenderTitleRow(asidetbl, title)
local titleElementtitleCell = asidetbl:tag('divtr'):tag('th')
:attr('id', 'reception-title')
:css('font-weight', 'bold')
 
if title then
titleCell
titleElement
:wikitext(title)
else
titleCell
titleElement
:addClass('Reception')
:wikitext(data.i18n.reception)
end
end
 
local function renderCaptionrenderMainHeading(builder, captionTextcolspan, headingText, borderTop)
builder:tag('captiontr'):tag('th')
:cssattr('font-sizecolspan', 'inherit'colspan)
:css('background', '#d1dbdf')
:css('border-top', borderTop or '1px solid #a2a9b1')
:wikitext(captionTextheadingText)
:css('border-left', '1px solid #a2a9b1')
:css('border-right', '1px solid #a2a9b1')
:wikitext(captionText)
end
 
local function renderHeadingRowWithSystems(builder, captionTextmainHeading, activeSystems)
renderMainHeading(builder, #activeSystems + 1, mainHeading)
renderCaption(builder, captionText)
builder:tag('tr')
:tag('th')
:attr('scoperowspan', 'col2')
:attrcss('rowspanbackground', '2#e8f4f8')
:css('backgroundtext-align', '#e8f4f8center')
:css('textvertical-align', 'centermiddle')
:wikitext(data.i18n.publication)
:css('vertical-align', 'middle')
:done()
:wikitext(data.i18n.publication)
:donetag('th')
:attr('colspan', #activeSystems)
:tag('th')
:attrcss('scopebackground', 'col#e8f4f8')
:attrcss('colspanvertical-align', #activeSystems'middle')
:wikitext(data.i18n.score)
:css('background', '#e8f4f8')
:css('vertical-align', 'middle')
:wikitext(data.i18n.score)
builder = builder:tag('tr')
for _, v in ipairs(activeSystems) do
builder:tag('th'):wikitext(data.systems[v].name)
:attr('scope', 'col')
:wikitext(data.systems[v].name)
end
end
 
local function renderHeadingRow(builder, captionTextmainHeading, nameHeading)
renderCaptionrenderMainHeading(builder, captionText2, mainHeading)
builder
:tag('tr')
:tag('th')
:attr('scope', 'col')
:css('background', '#e8f4f8')
:css('text-align', 'center')
:css('vertical-align', 'middle')
:wikitext(nameHeading)
:done()
:tag('th')
:attr('scope', 'col')
:css('background', '#e8f4f8')
:css('vertical-align', 'middle')
Line 149 ⟶ 139:
builder = builder:tag('tr')
builder:tag('td')
:css('vertical-align', 'middle')
:wikitext(name)
 
for _, v in ipairs(activeSystems) do
Line 156 ⟶ 146:
local cell = builder:tag('td')
if args[combinedCode] then
cell
:css('vertical-align', 'middle')
:css('verticaltext-align', 'middlecenter')
:wikitext(args[combinedCode])
elseif na then
cell
:css('color', '#707070')
:css('vertical-align', 'middle')
:css('text-align', 'center')
:addClass('table-na')
:wikitext(data.i18n.na)
end
end
Line 170 ⟶ 163:
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)
end
 
local function renderReviews(builder, providedReviewers, providedAggregators, activeSystems, customAggregatorKeys, customReviewerKeys, args)
builder = builder:tag('table')
:addClass('infobox wikitable')
:cssattr('border-spacingcellpadding', 0)
:cssattr('widthcellspacing', '100%'0)
:css('border-bottomwidth', 'none100%')
:css('marginborder-bottom', '0emnone')
:attrcss('scopemargin', 'col0em')
 
local reviewerCount = #providedReviewers + #customReviewerKeys
Line 212 ⟶ 206:
if aggregatorCount ~= 0 then
if reviewerCount ~= 0 then
renderCaptionrenderMainHeading(builder, #activeSystems + 1, aggregateScore)
elseif showplatforms then
renderHeadingRowWithSystems(builder, aggregateScore, activeSystems)
Line 251 ⟶ 245:
local function renderAwards(builder, args, awardKeys, borderTop)
builder = builder:tag('table')
:addClass('infobox wikitable')
:css('width', '100%')
:css('margin', '0em')
:css('border-top', borderTop)
:cssattr('border-spacingcellpadding', 03)
:attr('scopecellspacing', 'col'0)
 
renderCaptionrenderMainHeading(builder, 2, data.i18n[#awardKeys == 1 and 'award' or 'awards'], borderTop)
 
builder:tag('tr')
:tag('th')
:wikitext(data.i18n.publication)
:attr('scope', 'col')
:done()
:wikitext(data.i18n.publication)
:donetag('th')
:wikitext(data.systems[v]i18n.nameaward)
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.award)
 
for _, v in ipairs(awardKeys) do
builder:tag('tr')
:tag('td')
:css('font-weight', 'bold')
:css('background-color', '#f2f2f2')
:wikitext(args[v .. 'Pub'])
:done()
:tag('td')
:css('background-color', '#f2f2f2')
:wikitext(args[v])
end
end
 
local function renderMainTable(providedReviewers, providedAggregators, awardKeys, activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local asidetbl = mw.html.create('divtable')
:attr('rolecellpadding', 'complementary'0)
:attr('aria-labelledbycellspacing', 'reception-title'0)
:css('background', '#e8f4f8transparent')
:css('margin', args.align and ((args.align == 'left' or args.align == 'none') and '0em 1em 1em 0em') or '0em 1em 1em 1em')
:css('text-alignpadding', 'center0em')
:css('floatmargin', args.align or 'right')and
:css ((args.align == 'clearleft', or args.align or== 'rightnone') and '0em 1em 1em 0em') or
'0em 1em 1em 1em')
:css('fonttext-weightalign', 'boldcenter')
aside :css('widthfloat', args.widthalign or '23emright')
:css('clear', args.align or 'right')
 
if #activeSystems == 0 then
-- Width: 20% Seems better since it scales with the article size.
tbl
aside:css('width', args.width or '23em')
: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
tbl
aside:addClass('mw-collapsible')
:addClass(args.state == 'collapsedcollapsible' and 'mw-collapsed' or args.state)
:addClass(args.state)
end
renderTitlerenderTitleRow(asidetbl, args.title)
 
if args.subtitle then
asidetbl:tag('divtr'):tag('th')
:wikitext(dataargs.i18n.awardsubtitle)
:css('font-weight', 'bold')
:wikitext(args.subtitle)
end
 
renderReviews(asidetbl:tag('divtr'):tag('td'), providedReviewers, providedAggregators, activeSystems, customAggregatorKeys, customReviewerKeys, args)
if #awardKeys ~= 0 then
renderAwards(asidetbl:tag('divtr'):tag('td'), args, awardKeys, (#customAggregatorKeys ~= 0 or #customReviewerKeys ~= 0 or #providedAggregators ~= 0 or #providedReviewers ~= 0) and 'none' or nil)
end
 
if wikidata == true then
asidetbl:tag('divtr'):tag('td')
:tag('table')
:addClass('infobox wikitable noprint')
:attrcss('rolewidth', 'presentation100%')
:css('widthmargin', '100%0em')
:css('marginborder-top', '0emnone')
:cssattr('border-topcellpadding', 'none'3)
:cssattr('border-spacingcellspacing', 0)
:tag('tr'):tag('th')
:tagcss('tdbackground', '#d1dbdf')
:css('border-top', 'none')
:wikitext('Edit on Wikidata ' .. vgwd.getUpdateLink('nosub'))
:css('background', '#d1dbdf')
:css('text-align', 'center')
:css('font-weight', 'bold')
:wikitext(vgwd.getUpdateLink())
end
 
return asidetbl
end
 
Line 342 ⟶ 337:
vgwd.setGenerateReferences(true)
vgwd.setShowUpdateLink(false)
vgwd.setUpdateLinkStyle("text and pen")
vgwd.setSystemFormat(args["systemFormat"])
 
-- Loop through aggregators if we have any.
if #providedAggregators ~= 0 then
for _i_, aggr in ipairs(providedAggregators) do
-- Check if vgwd knows this aggregator.
if vgwd.setReviewer(aggr) == nil then
-- Loop through active systems
if #activeSystems ~= 0 then
for _j_, sys in ipairs(activeSystems) do
local combinedCode = aggr .. '_' .. sys
if args[combinedCode] == 'wikidata' then