Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
this should just be tidying
No edit summary
 
(13 intermediate revisions by 6 users not shown)
Line 1:
require('Module:No globalsstrict')
 
local p = {}
Line 89:
:attr('scope', 'colgroup')
:attr('colspan', #activeSystems)
:wikitext(data.i18n.display.score)
:done()
builder = builder:tag('tr')
for _, v in ipairs(activeSystems) do
builder:tag('th')
Line 109:
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.score)
:done()
end
 
local function renderRatingsBySystem(builder, code, name, activeSystems, args, na)
builder = builder:tag('tr')
builder:tag('td')
:wikitext(name)
:done()
 
for _, v in ipairs(activeSystems) do
Line 129 ⟶ 128:
cell
:addClass(data.i18n.class.na)
:wikitext(data.i18n.display.na)
:done()
end
Line 153 ⟶ 152:
builder = builder:tag('table')
:addClass(data.i18n.class.aggregators)
div:addClass(data.i18n.class.containernonewikitable)
:addClass(args.state and 'mw-collapsible-content' or nil)
:tag('caption')
:wikitext(data.i18n.display[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
:done()
 
Line 162:
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if showplatforms then
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.aggregator)
else
renderHeadingRow(builder, data.i18n.display.aggregator)
end
 
Line 174:
end
else
renderHeadingRow(builder, data.i18n.display.aggregator)
for _, v in ipairs(providedAggregators) do
renderRating(builder, data.aggregators[v].name, args[v])
Line 191:
builder = builder:tag('table')
:addClass(data.i18n.class.reviews)
div:addClass(data.i18n.class.containersinglewikitable)
:addClass(args.state and 'mw-collapsible-content' or nil)
:tag('caption')
:wikitext(data.i18n.display[reviewerCount == 1 and 'reviewScore' or 'reviewScores'])
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
:done()
Line 201 ⟶ 202:
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if showplatforms then
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.publication)
else
renderHeadingRow(builder, data.i18n.display.publication)
end
 
Line 213 ⟶ 214:
end
else
renderHeadingRow(builder, data.i18n.display.publication)
for _, v in ipairs(providedReviewers) do
renderRating(builder, data.reviewers[v].name, args[v])
Line 228 ⟶ 229:
builder = builder:tag('table')
:addClass(data.i18n.class.awards)
:addClass(data.i18n.class.wikitable)
:addClass(args.state and 'mw-collapsible-content' or nil)
:tag('caption')
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
:done()
Line 236 ⟶ 238:
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.publication)
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.award)
:done()
 
Line 252 ⟶ 254:
:done()
end
builder:done()
builder:done()
end
 
Line 260 ⟶ 263:
builder:tag('div')
:addClass(data.i18n.class.wikidata)
:addClass(args.state and 'mw-collapsible-content' or nil)
:wikitext(data.i18n.editOnWikidata .. vgwd.getUpdateLink('nosub'))
-- TODO: I think getUpdateLink can be made const in the other module.
:wikitext(data.i18n.editOnWikidata .. vgwd.getUpdateLink('nosub'))
:done()
end
Line 268 ⟶ 270:
local function categorizePlatformCount(builder, platformCount)
if platformCount ~= 0 then
builder:wikitext(data.i18n.multiplatformCategorycategory.multiplatform)
else
builder:wikitext(data.i18n.singleplatformCategorycategory.singleplatform)
end
end
 
 
local function renderTitles(builder, title, subtitle)
builder:tag('div')
:addClass(data.i18n.class.title)
:wikitext(title or data.i18n.display.reception)
:done()
 
Line 294 ⟶ 295:
local function render(providedReviewers, providedAggregators, awardKeys,
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local is_collapsible = args.title and args.state and
if (args.alignstate == data.i18n.alignstate.leftautocollapse thenor
if args.state == 'data.i18n.state.collapsed' thenor
or args.state == 'collapsed' or argsdata.i18n.state == '.expanded') then
)
local div = mw.html.create('div')
:attr('role', 'figurecomplementary')
:addClass(data.i18n.class.container)
:addClass(#activeSystems == 0 and data.i18n.class.containersingle or nil)
:attr('role', 'figure')
:addClass(args.align == data.i18n.align.left and data.i18n.class.containerleft or nil)
:addClass(args.align == data.i18n.align.none and data.i18n.class.containernone or nil)
if args.align then
div:addClass(is_collapsible and 'mw-collapsible' or nil)
if args.align == data.i18n.align.left then
div:addClass(is_collapsible and args.state == data.i18n.classstate.containerleftcollapsed and 'mw-collapsed' or nil)
elseif:addClass(is_collapsible and args.alignstate == data.i18n.alignstate.noneautocollapse and args.state or thennil)
div:addClass(data.i18n.class.containernone)
end
end
if #activeSystems == 0 then
div:addClass(data.i18n.class.containersingle)
:css('width', args.width or nil)
end
 
if args.title and args.state and (args.state == 'autocollapse'
or args.state == 'collapsed' or args.state == 'expanded') then
div:addClass('mw-collapsible')
if args.state == 'collapsed' then
div:addClass('mw-collapsed')
elseif args.state == 'autocollapse' or args.state == 'expanded' then
div:addClass(args.state)
end
end
 
renderTitles(div, args.title, args.subtitle)
Line 349 ⟶ 338:
)
renderEditOnWikidata(div, wikidata, args.state)
categorizePlatformCount(div, #activeSystems)
return div
Line 356 ⟶ 345:
local function checkForWikidata(frame, args, activeSystems, providedAggregators)
local wikidata = false
if args.alignqid == 'none' then
return wikidata
end
 
vgwd.setDateFormat(args['.df'])
vgwd.setGame(args['.qid'])
vgwd.setSystem(nil)
vgwd.setGenerateReferences(true)
vgwd.setShowUpdateLink(false)
vgwd.setUpdateLinkStyle("text and pen")
vgwd.setSystemFormat(args['.systemFormat'])
 
-- Loop through aggregators if we have any.
Line 421 ⟶ 414:
))
elseif mw.title.getCurrentTitle().namespace == 0 then
return data.i18n.emptyCategorycategory.empty
end
end
Line 429 ⟶ 422:
getArgs = require('Module:Arguments').getArgs
end
return p._reviewbox(frame, getArgs(frame,
{ wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n }
))
end