Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
poke
how much did we break?
Line 76:
end)
return providedReviewers, providedAggregators
end
 
local function renderMainHeading(builder, colspan, headingText)
builder:tag('tr')
:addClass('vgr-main-heading')
:tag('th')
:attr('colspan', colspan)
:attr('scope', colspan == 1 and 'col' or 'colgroup')
:wikitext(headingText)
:done()
end
 
local function renderHeadingRowWithSystems(builder, activeSystems, headingText)
builder:tag('tr')
:addClass('vgr-systems'data.i18n.class.headerrow)
:tag('th')
:attr('scope', 'col')
Line 112 ⟶ 102:
local function renderHeadingRow(builder, nameHeading)
builder:tag('tr')
:addClass('vgr-hrow'data.i18n.class.headerrow)
:tag('th')
:attr('scope', 'col')
Line 137 ⟶ 127:
elseif na then
cell
:addClass('table-data.i18n.class.na')
:wikitext(data.i18n.na)
:done()
Line 147 ⟶ 137:
builder:tag('tr')
:tag('td')
:addClass('vgr-center'data.i18n.class.centeredpub)
:wikitext(name)
:done()
Line 155 ⟶ 145:
end
 
local function renderAggregators(div, providedAggregators, activeSystems, customAggregatorKeys, args)
local function renderReviews(builder, providedReviewers, providedAggregators,
activeSystems, customAggregatorKeys, customReviewerKeys, args)
local aggregatorCount = #providedAggregators + #customAggregatorKeys
if aggregatorCount == 0 then return end
builder = builder:tag('table')
:addClass('vgr-reviews'data.i18n.class.aggregators)
if args.state then builder:addClass('mw-collapsible-content') end
local caption = data.i18n[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores']
builder:tag('caption')
:wikitext(caption)
:done()
 
local reviewerCount = #providedReviewers + #customReviewerKeys
local aggregatorCount = #providedAggregators + #customAggregatorKeys
local reviewScore = data.i18n[reviewerCount == 1 and 'reviewScore' or 'reviewScores']
local aggregateScore = data.i18n[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores']
if #activeSystems ~= 0 then
builder:wikitext(data.i18n.multiplatformCategory)
local na = yesno(args.na)
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if aggregatorCount ~= 0showplatforms then
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.aggregator)
if showplatforms then
else
renderMainHeading(builder, #activeSystems + 1, aggregateScore)
renderHeadingRowWithSystemsrenderHeadingRow(builder, activeSystems, data.i18n.aggregator)
else
renderMainHeading(builder, 2, aggregateScore)
renderHeadingRow(builder, data.i18n.aggregator)
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
end
if reviewerCount ~= 0 then
if showplatforms then
renderMainHeading(builder, #activeSystems + 1, reviewScore)
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.publication)
else
renderMainHeading(builder, 2, reviewScore)
renderHeadingRow(builder, data.i18n.publication)
end
 
for _, v in ipairs(providedReviewersprovidedAggregators) do
renderRatingsBySystem(builder, v, data.reviewersaggregators[v].name, activeSystems, args, na)
end
for _, v in ipairs(customReviewerKeyscustomAggregatorKeys) do
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
end
end
else
builder:wikitextrenderHeadingRow(builder, data.i18n.singleplatformCategoryaggregator)
for _, v in ipairs(providedAggregators) do
if aggregatorCount ~= 0 then
renderMainHeadingrenderRating(builder, 2data.aggregators[v].name, aggregateScoreargs[v])
renderHeadingRow(builder, 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
end
for _, v in ipairs(customAggregatorKeys) do
if reviewerCount ~= 0 then
renderMainHeadingrenderRating(builder, 2args[v], reviewScoreargs[v .. 'Score'])
end
end
end
 
local function renderReviews(builder, providedReviewers, activeSystems,
customReviewerKeys, args, reviewerCount, priorReviewCount)
if reviewerCount == 0 then return end
builder = builder:tag('table')
:addClass(data.i18n.class.reviews)
if args.state then builder:addClass('mw-collapsible-content') end
 
local caption = data.i18n[reviewerCount == 1 and 'reviewScore' or 'reviewScores']
builder:tag('caption')
:wikitext(caption)
if priorReviewCount > 0 then builder:addClass(data.i18n.class.stacked) end
builder:done()
if #activeSystems ~= 0 then
local na = yesno(args.na)
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if showplatforms then
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.publication)
else
renderHeadingRow(builder, data.i18n.publication)
end
for _, v in ipairs(providedReviewers) do
 
renderRating(builder, data.reviewers[v].name, args[v])
for _, v in ipairs(providedReviewers) do
end
renderRatingsBySystem(builder, v, data.reviewers[v].name, activeSystems, args, na)
for _, v in ipairs(customReviewerKeys) do
end
renderRating(builder, args[v], args[v .. 'Score'])
for _, v in ipairs(customReviewerKeys) do
end
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
end
else
renderHeadingRow(builder, 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
end
end
 
local function renderAwards(builder, args, awardKeys, stackedClasspriorReviewCount)
if #awardKeys == 0 then return end
builder = builder:tag('table')
:addClass('vgr-data.i18n.class.awards')
if args.state then builder:addClass('mw-collapsible-content') end
builder:tag('caption')
:wikitext(data.i18n[#awardKeys == 1 and 'award' or 'awards'])
:addClass(stackedClass)
if priorReviewCount > 0 then builder:addClass(data.i18n.class.stacked) end
builder:done()
builder:tag('tr')
Line 256 ⟶ 260:
builder:done()
builder:done()
end
 
local function renderEditOnWikidata(wikidata, updateLink, state)
if not wikidata then return end
div:tag('div')
:addClass(data.i18n.class.wikidata)
-- TODO: I think getUpdateLink can be made const in the other module.
:wikitext(data.i18n.editOnWikidata .. updateLink)
if state then div:addClass('mw-collapsible-content') end
div:done()
end
 
local function categorizePlatformCount(platformCount)
if #activeSystems ~= 0 then
div:wikitext(data.i18n.multiplatformCategory)
else
div:wikitext(data.i18n.singleplatformCategory)
end
end
 
 
local function renderTitles(builder, title, subtitle)
builder:tag('div')
:addClass(data.i18n.class.title)
:wikitext(title or data.i18n.reception)
:done()
 
if subtitle then
builder:tag('div')
:addClass(data.i18n.class.subtitle)
-- The only reason to use the subtitle is collapsible content
-- So always add the related class.
:addClass('mw-collapsible-content')
:wikitext(subtitle)
:done()
end
end
 
Line 261 ⟶ 303:
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local div = mw.html.create('div')
:addClass('video-game-reviews'data.i18n.class.container)
if args.align then
if args.align == 'data.i18n.align.left' then
div:addClass('vgr-left'data.i18n.class.containerleft)
elseif args.align == 'data.i18n.align.none' then
div:addClass('vgr-none'data.i18n.class.containernone)
end
end
if #activeSystems == 0 then
div:addClass('vgr-single'data.i18n.class.containersingle)
:css('width', args.width or nil)
end
Line 287 ⟶ 329:
end
 
renderTitles(div, args.title, args.subtitle)
div:tag('div')
:addClass('vgr-title')
:wikitext(args.title or data.i18n.reception)
:done()
 
if args.subtitle then
div:tag('div')
:addClass('vgr-subtitle')
-- The only reason to use the subtitle is collapsible content
-- So always add the related class.
:addClass('mw-collapsible-content')
:wikitext(args.subtitle)
:done()
end
 
local aggregatorCount = #providedAggregators + #customAggregatorKeys
renderAggregators(
div,
providedAggregators,
activeSystems,
customAggregatorKeys,
args,
aggregatorCount
)
local reviewerCount = #customReviewerKeys + #providedReviewers
renderReviews(
div,
providedReviewers,
providedAggregators,
activeSystems,
customAggregatorKeys,
customReviewerKeys,
args,
reviewerCount,
aggregatorCount
)
renderAwards(
if #awardKeys ~= 0 then
div,
local stackedClass =
args,
(#customAggregatorKeys ~= 0 or
awardKeys,
#customReviewerKeys ~= 0 or
reviewerCount + aggregatorCount
#providedAggregators ~= 0 or
)
#providedReviewers ~= 0
renderEditOnWikidata(wikidata, vgwd.getUpdateLink('nosub'), args.state)
) and 'vgr-stacked' or nil
renderAwards(
categorizePlatformCount(activeSystems)
div,
args,
awardKeys,
stackedClass
)
end
 
if wikidata == true then
div:tag('div')
:addClass('vgr-edit-on-wikidata')
-- TODO: I think getUpdateLink can be made const in the other module.
:wikitext(data.i18n.editOnWikidata .. vgwd.getUpdateLink('nosub'))
if args.state then div:addClass('mw-collapsible-content') end
end
 
return div
end
Line 341 ⟶ 366:
local wikidata = false
 
vgwd.setDateFormat(args[".df"])
vgwd.setGame(args[".qid"])
vgwd.setSystem(nil)
vgwd.setGenerateReferences(true)
vgwd.setShowUpdateLink(false)
vgwd.setUpdateLinkStyle("pen")
vgwd.setSystemFormat(args[".systemFormat"])
 
-- Loop through aggregators if we have any.