Module:RemoteControl: Difference between revisions
Add complete inline styles for border, backgrounds to match CRT model infobox (via update-page on MediaWiki MCP Server) |
Add ECID field to infobox matching CRT model implementation (via update-page on MediaWiki MCP Server) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 22: | Line 22: | ||
local section = container:tag('div') | local section = container:tag('div') | ||
section:addClass('infobox-section-header') | section:addClass('infobox-section-header') | ||
css(section, 'grid-column: 1 / -1; text-align:center; padding:0.5em; font-weight:bold | css(section, 'grid-column: 1 / -1; text-align:center; padding:0.5em; font-weight:bold;') | ||
section:wikitext(title) | section:wikitext(title) | ||
end | end | ||
| Line 29: | Line 29: | ||
local labelDiv = container:tag('div') | local labelDiv = container:tag('div') | ||
labelDiv:addClass('infobox-label') | labelDiv:addClass('infobox-label') | ||
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left | css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;') | ||
labelDiv:wikitext(label) | labelDiv:wikitext(label) | ||
local valueDiv = container:tag('div') | local valueDiv = container:tag('div') | ||
valueDiv:addClass('infobox-value') | valueDiv:addClass('infobox-value') | ||
css(valueDiv, 'padding:0.2em 0.4em | css(valueDiv, 'padding:0.2em 0.4em;') | ||
if isRawHtml then | if isRawHtml then | ||
| Line 63: | Line 63: | ||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
local pageName = title.text | local pageName = title.text | ||
local pageId = title.id or 0 | |||
local brand = trim(args.brand) | local brand = trim(args.brand) | ||
| Line 68: | Line 69: | ||
local image_main = trim(args.image_main) | local image_main = trim(args.image_main) | ||
-- | -- Load the remote control stylesheet | ||
local styleTag = frame:extensionTag('templatestyles', '', {src = 'Template: | local styleTag = frame:extensionTag('templatestyles', '', {src = 'Template:Remote control/styles.css'}) | ||
local container = mw.html.create('div') | local container = mw.html.create('div') | ||
container:addClass('infobox') | container:addClass('infobox') | ||
container:addClass('infobox-remote-control') | container:addClass('infobox-remote-control') | ||
css(container, 'float:right; clear:right; margin:0 0 1em 1em; width:22em; font-size:88%; line-height:1.5em; display:grid; grid-template-columns:auto 1fr; gap: | css(container, 'float:right; clear:right; margin:0 0 1em 1em; width:22em; font-size:88%; line-height:1.5em; display:grid; grid-template-columns:auto 1fr; gap:3px; padding:3px;') | ||
-- Title row | -- Title row | ||
| Line 80: | Line 81: | ||
container, | container, | ||
(brand or '') .. ' ' .. (model_code or ''), | (brand or '') .. ' ' .. (model_code or ''), | ||
'text-align:center; font-size:125%; font-weight:bold; padding:0.5em | 'text-align:center; font-size:125%; font-weight:bold; padding:0.5em;', | ||
false, | false, | ||
'infobox-title' | 'infobox-title' | ||
| Line 90: | Line 91: | ||
container, | container, | ||
string.format('[[File:%s|frameless|300px]]', file), | string.format('[[File:%s|frameless|300px]]', file), | ||
'text-align:center; padding:0 | 'text-align:center; padding:0;', | ||
false, | false, | ||
'infobox-image' | 'infobox-image' | ||
| Line 113: | Line 114: | ||
addRow(container, 'Type', 'Remote', false) | addRow(container, 'Type', 'Remote', false) | ||
-- ECID row: build as a normal external link wikitext; preprocess not required, but fine. | |||
local ecidWikitext = string.format('[{{fullurl:%s|curid=%d}} EC%d]', pageName, pageId, pageId) | |||
addRow(container, 'ECID', frame:preprocess(ecidWikitext), true) | |||
-- Contribute section | -- Contribute section | ||
| Line 128: | Line 133: | ||
-- Create the edit button div | -- Create the edit button div | ||
local editDiv = container:tag('div') | local editDiv = container:tag('div') | ||
css(editDiv, 'grid-column: 1 / -1; padding:0. | css(editDiv, 'grid-column: 1 / -1; padding:0.2em 0.4em; text-align:center;') | ||
-- Add edit button | -- Add edit button using the infobox-button classes | ||
editDiv:wikitext('[' .. tostring(editUrl) .. ' <span | editDiv:wikitext('[' .. tostring(editUrl) .. ' <span class="infobox-button infobox-button-primary">Edit this data</span>]') | ||
-- Return templatestyles tag + container HTML | -- Return templatestyles tag + container HTML | ||