Content deleted Content added
will the caption collapse I wonder. it should... |
No edit summary |
||
(29 intermediate revisions by 6 users not shown) | |||
Line 1:
require('
local p = {}
Line 78:
end
local function
builder:tag('tr')
:addClass(
:tag('th')
:attr('
:attr('
:wikitext(headingText)
:done()
:tag('th')
:attr('scope', 'colgroup')
:attr('colspan', #activeSystems)
:wikitext(data.i18n.display.score)
:done()
builder = builder:tag('tr')
Line 112 ⟶ 100:
end
local function renderHeadingRow(builder
builder:tag('tr')
:addClass(
:tag('th')
:attr('scope', 'col')
:wikitext(nameHeading)
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.score)
:done()
end
Line 140 ⟶ 127:
elseif na then
cell
:addClass(
:wikitext(data.i18n.display.na)
:done()
end
Line 150 ⟶ 137:
builder:tag('tr')
:tag('td')
:addClass(
:wikitext(name)
:done()
Line 158 ⟶ 145:
end
local function
local aggregatorCount = #providedAggregators + #customAggregatorKeys
if aggregatorCount == 0 then return end
builder = builder:tag('table')
:addClass(
: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()
if #activeSystems ~= 0 then
local na = yesno(args.na)
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.aggregator)
else
renderHeadingRow(builder, data.i18n.display.aggregator)
end
end
else
for _, v in ipairs(providedAggregators) do
end
for _, v in ipairs(customAggregatorKeys) do
end
end
end
local function
customReviewerKeys, args, reviewerCount, priorReviewCount)
if reviewerCount == 0 then return end
builder = builder:tag('table')
:addClass(
: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()
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.display.publication)
else
renderHeadingRow(builder, data.i18n.display.publication)
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
else
renderHeadingRow(builder, data.i18n.display.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, priorReviewCount)
if #awardKeys == 0 then return end
builder = builder:tag('
:addClass(data.i18n.class.awards)
:addClass(args.state and 'mw-collapsible-content' or nil)
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
:
:done()
:tag('tr')
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.publication)
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.award)
:done()
for _, v in ipairs(awardKeys) do
Line 257 ⟶ 258:
end
local function
if not wikidata then return end
builder:tag('div')
:addClass(data.i18n.class.wikidata)
:wikitext(vgwd.getUpdateLink())
:done()
local function categorizePlatformCount(builder, platformCount)
if platformCount ~= 0 then
builder:wikitext(data.i18n.category.multiplatform)
else
builder:wikitext(data.i18n.category.singleplatform)
end
end
local function renderTitles(builder, title, subtitle)
builder:tag('div')
:
:wikitext(title or data.i18n.display.reception)
:done()
if
:addClass(
-- The only reason to use the subtitle is collapsible content
-- So always add the related class.
:addClass('mw-collapsible-content')
:wikitext(
:done()
end
end
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
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(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 and args.state or nil)
renderTitles(div, args.title, args.subtitle)
local aggregatorCount = #providedAggregators + #customAggregatorKeys
renderAggregators(
div,
providedAggregators,
activeSystems,
customAggregatorKeys,
args,
aggregatorCount
)
local reviewerCount = #customReviewerKeys + #providedReviewers
renderReviews(
div,
providedReviewers,
activeSystems,
customReviewerKeys,
args,
reviewerCount,
aggregatorCount
)
renderAwards(
div,
args,
awardKeys,
reviewerCount + aggregatorCount
)
renderEditOnWikidata(div, wikidata, args.state)
categorizePlatformCount(div, #activeSystems)
return div
end
Line 339 ⟶ 345:
local function checkForWikidata(frame, args, activeSystems, providedAggregators)
local wikidata = false
if args.qid == 'none' then
return wikidata
end
vgwd.setDateFormat(args
vgwd.setGame(args
vgwd.setSystem(nil)
vgwd.setGenerateReferences(true)
vgwd.setShowUpdateLink(false)
vgwd.setUpdateLinkStyle("text and pen")
vgwd.setSystemFormat(args
-- Loop through aggregators if we have any.
Line 404 ⟶ 414:
))
elseif mw.title.getCurrentTitle().namespace == 0 then
return data.i18n.
end
end
Line 412 ⟶ 422:
getArgs = require('Module:Arguments').getArgs
end
return p._reviewbox(frame, getArgs(frame,
{ wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n } )) end
|