Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
fix
No edit summary
 
(17 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')
Line 109:
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.score)
:done()
end
Line 128:
cell
:addClass(data.i18n.class.na)
:wikitext(data.i18n.display.na)
:done()
end
Line 152:
builder = builder:tag('table')
:addClass(data.i18n.class.aggregators)
div:addClass(data.i18n.class.containersinglewikitable)
if :addClass(args.state thenand builder:addClass('mw-collapsible-content') endor nil)
local caption = data.i18n[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores']
builder :tag('caption')
local caption = :wikitext(data.i18n.display[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
:wikitext(caption)
:done()
 
if #activeSystems ~= 0 then
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)
:addClass(data.i18n.class.wikitable)
if :addClass(args.state thenand builder:addClass('mw-collapsible-content') endor nil)
 
:wikitexttag('caption')
local caption = :wikitext(data.i18n.display[reviewerCount == 1 and 'reviewScore' or 'reviewScores'])
builder:tag('caption')
if :addClass(priorReviewCount > 0 thenand builder:addClass(data.i18n.class.stacked) endor nil)
:wikitext(caption)
:done()
if priorReviewCount > 0 then builder:addClass(data.i18n.class.stacked) end
builder:done()
if #activeSystems ~= 0 then
Line 204 ⟶ 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 216 ⟶ 214:
end
else
renderHeadingRow(builder, data.i18n.display.publication)
for _, v in ipairs(providedReviewers) do
renderRating(builder, data.reviewers[v].name, args[v])
Line 231 ⟶ 229:
builder = builder:tag('table')
:addClass(data.i18n.class.awards)
:addClass(data.i18n.class.wikitable)
if :addClass(args.state thenand builder:addClass('mw-collapsible-content') endor nil)
builder :tag('caption')
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
if :addClass(priorReviewCount > 0 thenand builder:addClass(data.i18n.class.stacked) endor nil)
if priorReviewCount > 0 then builder:addClass(data.i18n.class.stacked) end
builder:done()
builder:tag('tr')
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.publication)
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.award)
:done()
builder :tag('tr')
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.publication)
div :done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.award)
builder :done()
 
for _, v in ipairs(awardKeys) do
Line 262 ⟶ 258:
end
 
local function renderEditOnWikidata(builder, wikidata, state)
if not wikidata then return end
divbuilder:tag('div')
:addClass(data.i18n.class.wikidata)
:addClass(state and 'mw-collapsible-content' or nil)
-- TODO: I think getUpdateLink can be made const in the other module.
:wikitext(data.i18n.editOnWikidata .. vgwd.getUpdateLink('nosub'))
:done()
if state then div:addClass('mw-collapsible-content') end
div:done()
end
 
local function categorizePlatformCount(builder, platformCount)
if platformCount ~= 0 then
divbuilder:wikitext(data.i18n.multiplatformCategorycategory.multiplatform)
else
divbuilder: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 302 ⟶ 295:
local function render(providedReviewers, providedAggregators, awardKeys,
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local is_collapsible = args.title and args.state and
(args.state == data.i18n.state.autocollapse or
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', 'complementary')
:addClass(data.i18n.class.container)
:addClass(#activeSystems == 0 and data.i18n.class.containersingle or nil)
:addClass(args.align == data.i18n.align.left and data.i18n.class.containerleft or nil)
if args.align then
if :addClass(args.align == data.i18n.align.leftnone and data.i18n.class.containernone or thennil)
div:addClass(data.i18n.class.containerleftis_collapsible and 'mw-collapsible' or nil)
elseif:addClass(is_collapsible and args.alignstate == data.i18n.alignstate.nonecollapsed and 'mw-collapsed' or thennil)
div:addClass(is_collapsible and args.state == data.i18n.classstate.autocollapse and args.containernonestate or nil)
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 356 ⟶ 337:
reviewerCount + aggregatorCount
)
renderEditOnWikidata(div, wikidata, args.state)
categorizePlatformCount(div, #activeSystems)
return div
Line 364 ⟶ 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 429 ⟶ 414:
))
elseif mw.title.getCurrentTitle().namespace == 0 then
return data.i18n.emptyCategorycategory.empty
end
end
Line 437 ⟶ 422:
getArgs = require('Module:Arguments').getArgs
end
return p._reviewbox(frame, getArgs(frame,
{ wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n }
))
end