Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
new "text and pen" wikidata link style
m formatting cleanup
Line 9:
local function getActiveSystems(args)
local activeSystems = {}
for k, v in pairs(args) do
if data.systems[k] and yesno(v) then
table.insert(activeSystems, k)
Line 34:
return tonumber(a:match('%d+')) < tonumber(b:match('%d+'))
end
 
table.sort(reviewers, comparator)
table.sort(aggregators, comparator)
Line 121 ⟶ 122:
:wikitext(data.i18n.score)
builder = builder:tag('tr')
for _, v in ipairs(activeSystems) do
builder:tag('th')
:attr('scope', 'col')
Line 130 ⟶ 131:
local function renderHeadingRow(builder, captionText, nameHeading)
renderCaption(builder, captionText)
builder:tag('tr')
:tag('trth')
:tagattr('thscope', 'col')
:attrcss('scopebackground', 'col#e8f4f8')
:css('backgroundtext-align', '#e8f4f8center')
:css('textvertical-align', 'centermiddle')
:wikitext(nameHeading)
:css('vertical-align', 'middle')
:done()
:wikitext(nameHeading)
:donetag('th')
:tagattr('thscope', 'col')
:attrcss('scopebackground', 'col#e8f4f8')
:css('backgroundvertical-align', '#e8f4f8middle')
:wikitext(data.i18n.score)
:css('vertical-align', 'middle')
:wikitext(data.i18n.score)
end
 
Line 149:
builder = builder:tag('tr')
builder:tag('td')
:css('vertical-align', 'middle')
:wikitext(name)
 
for _, v in ipairs(activeSystems) do
local combinedCode = code .. '_' .. v
local cell = builder:tag('td')
if args[combinedCode] then
cell:css('vertical-align', 'middle')
cell
:css('vertical-align', 'middle')
:wikitext(args[combinedCode])
elseif na then
cell:css('color', '#707070')
:css('colorvertical-align', '#707070middle')
:css('vertical-align','middle')
:css('text-align', 'center')
:addClass('table-na')
Line 205 ⟶ 203:
end
 
for _, v in ipairs(providedReviewers) do
renderRatingsBySystem(builder, v, data.reviewers[v].name, activeSystems, args, na)
end
for _, v in ipairs(customReviewerKeys) do
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
end
Line 221 ⟶ 219:
end
 
for _, v in ipairs(providedAggregators) do
renderRatingsBySystem(builder, v, data.aggregators[v].name, activeSystems, args, na)
end
for _, v in ipairs(customAggregatorKeys) do
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
end
Line 232 ⟶ 230:
if aggregatorCount ~= 0 then
renderHeadingRow(builder, aggregateScore, data.i18n.aggregator)
for _, v in ipairs(providedAggregators) do
renderRating(builder, data.aggregators[v].name, args[v])
end
for _, v in ipairs(customAggregatorKeys) do
renderRating(builder, args[v], args[v .. 'Score'])
end
Line 241 ⟶ 239:
if reviewerCount ~= 0 then
renderHeadingRow(builder, reviewScore, data.i18n.publication)
for _, v in ipairs(providedReviewers) do
renderRating(builder, data.reviewers[v].name, args[v])
end
for _, v in ipairs(customReviewerKeys) do
renderRating(builder, args[v], args[v .. 'Score'])
end
Line 258 ⟶ 256:
:css('border-top', borderTop)
:css('border-spacing', 0)
 
renderCaption(builder, data.i18n[#awardKeys == 1 and 'award' or 'awards'], borderTop)
 
Line 270 ⟶ 268:
: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
Line 287 ⟶ 285:
:attr('role', 'complementary')
:attr('aria-labelledby', 'reception-title')
:css('margin', args.align and ((args.align == 'left' or args.align == 'none') and '0em 1em 1em 0em') or '0em 1em 1em 1em')
((args.align == 'left' or args.align == 'none') and '0em 1em 1em 0em') or
'0em 1em 1em 1em')
:css('text-align', 'center')
:css('float', args.align or 'right')
:css('clear', args.align or 'right')
 
if #activeSystems == 0 then
-- Width: 20% Seems better since it scales with the article size.
aside:css('width', args.width or '23em')
aside
: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
aside:addClass('mw-collapsible')
:addClass('mw-collapsible')
:addClass(args.state == 'collapsed' and 'mw-collapsed' or args.state)
end
Line 322 ⟶ 316:
aside:tag('div')
:tag('table')
:addClass('infobox wikitable noprint')
:attr('role', 'presentation')
:css('width', '100%')
:css('margin', '0em')
:css('border-top', 'none')
:css('border-spacing', 0)
:tag('tr')
:tag('td')
:css('border-top', 'none')
:css('background', '#d1dbdf')
:css('text-align', 'center')
:css('font-weight', 'bold')
:wikitext(vgwd.getUpdateLink())
end
 
Line 341 ⟶ 336:
local function checkForWikidata(frame, args, activeSystems, providedAggregators)
local wikidata = false
 
vgwd.setDateFormat(args["df"])
vgwd.setGame(args["qid"])
Line 349 ⟶ 344:
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
Line 366 ⟶ 361:
args[combinedCode] = vgwdScore
end
wikidata = true
end
end
else
vgwd.setShowSystem(true)
if args[aggr] == 'wikidata' then
local vgwdScore = vgwd.printReviewScores(frame)
if vgwdScore then
Line 378 ⟶ 373:
wikidata = true
end
end
end
end
Line 402 ⟶ 397:
getArgs = require('Module:Arguments').getArgs
end
return p._reviewbox(frame, getArgs(frame, { wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n }))
end