Difference between revisions of "Module:Album ratings"
Jump to navigation
Jump to search
blackwiki>Mr. Stradivarius (implement Template:Album ratings) |
blackwiki>Mr. Stradivarius (remove extra tr element) |
||
| Line 13: | Line 13: | ||
local function makeRow(review, score) | local function makeRow(review, score) | ||
| − | |||
| − | |||
| − | |||
local row = mw.html.create('tr') | local row = mw.html.create('tr') | ||
makeCell(row, review) | makeCell(row, review) | ||
| Line 25: | Line 22: | ||
local row = mw.html.create('tr') | local row = mw.html.create('tr') | ||
row | row | ||
| − | :tag(' | + | :tag('th') |
| − | + | :attr('scope', scope ~= false and 'col' or nil) | |
| − | + | :attr('colspan', 2) | |
| − | + | :css('text-align', 'center') | |
| − | + | :css('background', background ~= false and '#d1dbdf' or nil) | |
| − | + | :css('font-size', '120%') | |
| − | + | :wikitext(header) | |
| − | |||
return row | return row | ||
end | end | ||
Revision as of 04:28, 8 July 2015
| 40px | This Lua module is used on approximately 88,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages. Consider discussing changes on the talk page before implementing them.
Transclusion count updated automatically (see documentation). |
| 40x40px | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module implements {{Album ratings}}. Please see the template page for documentation.
See also
- Category:Articles with album ratings that need to be turned into prose
- Category:Pages using album ratings with duplicate score parameters (0)
-- This module implements [[Template:Album ratings]].
local mTableTools = require('Module:TableTools')
local p = {}
local function makeCell(html, s)
html
:tag('td')
:css('text-align', 'center')
:css('vertical-align', 'middle')
:wikitext(s)
end
local function makeRow(review, score)
local row = mw.html.create('tr')
makeCell(row, review)
makeCell(row, score)
return row
end
local function makeHeaderRow(header, background, scope)
local row = mw.html.create('tr')
row
:tag('th')
:attr('scope', scope ~= false and 'col' or nil)
:attr('colspan', 2)
:css('text-align', 'center')
:css('background', background ~= false and '#d1dbdf' or nil)
:css('font-size', '120%')
:wikitext(header)
return row
end
local function makeRatingHeaderRow()
local row = mw.html.create('tr')
row
:tag('th')
:attr('scope', 'col')
:wikitext('Source')
:done()
:tag('th')
:attr('scope', 'col')
:wikitext('Rating')
return row
end
function p._main(args)
local reviewNums = mTableTools.affixNums(args, 'rev')
local root = mw.html.create('table')
-- Table base
root
:addClass('wikitable infobox')
:css('float', args.align or 'right')
:css('width', args.width or '24.2em')
:css('font-size', '80%')
:css('text-align', 'center')
:css('margin', '0.5em 0 0.5em 1em')
:css('padding', 0)
:css('border-spacing', 0)
:tag('tr')
:tag('th')
:attr('scope', 'col')
:attr('colspan', 2)
:css('font-size', '120%')
:wikitext(args.title or 'Professional ratings')
-- Subtitle
if args.subtitle then
root:node(makeHeaderRow(args.subtitle, false, false))
end
-- Metacritic
if args.MC then
root:node(makeHeaderRow('Aggregate scores', true, true))
root:node(makeRatingHeaderRow())
root:node(makeRow('[[Metacritic]]', args.MC))
end
-- Review rows
root:node(makeHeaderRow('Review scores', true, true))
for i, num in ipairs(reviewNums) do
root:node(makeRow(
args['rev' .. num],
args['rev' .. num .. 'Score'] or
args['Rev' .. num .. 'Score'] or
args['rev' .. num .. 'score'] or
args['Rev' .. num .. 'score']
))
end
return tostring(root)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Album ratings'
})
return p._main(args)
end
return p