Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
Undid revision 993346459 by Izno (talk) nope, that one broke it, lets not revert all the way though
No edit summary
 
(12 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)
:addClass(data.i18n.class.wikitable)
:addClass(args.state and 'mw-collapsible-content' or nil)
:tag('caption')
:wikitext(data.i18n.display[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
:done()
 
Line 161 ⟶ 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 173 ⟶ 174:
end
else
renderHeadingRow(builder, data.i18n.display.aggregator)
for _, v in ipairs(providedAggregators) do
renderRating(builder, data.aggregators[v].name, args[v])
Line 190 ⟶ 191:
builder = builder:tag('table')
:addClass(data.i18n.class.reviews)
:addClass(data.i18n.class.wikitable)
: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 200 ⟶ 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 212 ⟶ 214:
end
else
renderHeadingRow(builder, data.i18n.display.publication)
for _, v in ipairs(providedReviewers) do
renderRating(builder, data.reviewers[v].name, args[v])
Line 227 ⟶ 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 235 ⟶ 238:
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.publication)
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.award)
:done()
 
Line 261 ⟶ 264:
:addClass(data.i18n.class.wikidata)
:addClass(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 295 ⟶ 296:
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local is_collapsible = args.title and args.state and
(args.state == 'autocollapse' or argsdata.i18n.state == 'collapsed'.autocollapse or args.state == 'expanded')
args.state == data.i18n.state.collapsed or
args.state == data.i18n.state.expanded
)
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)
:addClass(args.align == data.i18n.align.none and data.i18n.class.containernone or nil)
:addClass(#activeSystems == 0 and data.i18n.class.containersingle or nil)
:addClass(is_collapsible and 'mw-collapsible' or nil)
:addClass((is_collapsible and args.state == 'data.i18n.state.collapsed') and 'mw-collapsed' or nil)
:addClass((is_collapsible and (args.state == 'data.i18n.state.autocollapse' orand args.state ==or 'expanded')nil)
and args.state or nil)
:css('width', #activeSystems == 0 and args.width or nil)
 
renderTitles(div, args.title, args.subtitle)
Line 335 ⟶ 338:
)
renderEditOnWikidata(div, wikidata, args.state)
categorizePlatformCount(div, #activeSystems)
return div
Line 342 ⟶ 345:
local function checkForWikidata(frame, args, activeSystems, providedAggregators)
local wikidata = false
if args.qid == '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 407 ⟶ 414:
))
elseif mw.title.getCurrentTitle().namespace == 0 then
return data.i18n.emptyCategorycategory.empty
end
end
Line 415 ⟶ 422:
getArgs = require('Module:Arguments').getArgs
end
return p._reviewbox(frame, getArgs(frame,
{ wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n }
))
end