Module:Accessory

Revision as of 17:34, 9 February 2026 by Arclight-MCP-Bot (talk | contribs) (Create Module:Accessory for rendering accessory infoboxes (remotes, stands, option cards, etc.) (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

-- Module:Accessory -- Builds the Accessory infobox (remotes, stands, option cards, etc.)

local p = {}

local function trim(s) if s == nil then return nil end s = tostring(s) s = s:gsub('^%s+', ):gsub('%s+$', ) if s == then return nil end return s end

local function css(node, cssText) if cssText and cssText ~= then node:cssText(cssText) end return node end

local function addSectionRow(container, title) local section = container:tag('div') section:addClass('infobox-section-header') css(section, 'grid-column: 1 / -1; text-align:center; padding:0.5em; font-weight:bold;') section:wikitext(title) end

local function addRow(container, label, valueHtmlOrWikitext, isRawHtml) local labelDiv = container:tag('div') labelDiv:addClass('infobox-label') css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;') labelDiv:wikitext(label)

local valueDiv = container:tag('div') valueDiv:addClass('infobox-value') css(valueDiv, 'padding:0.2em 0.4em;')

if isRawHtml then valueDiv:node(mw.html.create('span'):wikitext(valueHtmlOrWikitext)) else valueDiv:wikitext(valueHtmlOrWikitext) end end

local function addFullRow(container, valueHtmlOrWikitext, cssText, isRawHtml, extraClass) local fullDiv = container:tag('div') css(fullDiv, 'grid-column: 1 / -1; ' .. (cssText or )) if extraClass then fullDiv:addClass(extraClass) end

if isRawHtml then fullDiv:wikitext(valueHtmlOrWikitext) else fullDiv:wikitext(valueHtmlOrWikitext) end end

function p.infobox(frame) local parent = frame:getParent() local args = parent and parent.args or frame.args

local title = mw.title.getCurrentTitle() local pageName = title.text local fullPageName = title.fullText local pageId = title.id or 0

-- Core fields local brand = trim(args.brand) local model_code = trim(args.model_code) local accessory_type = trim(args.accessory_type) local description = trim(args.description) local image_main = trim(args.image_main)

-- Option card specific local card_signals = trim(args.card_signals)

-- Media specific local media_format = trim(args.media_format)

-- Load stylesheet local styleTag = frame:extensionTag('templatestyles', , {src = 'Template:Infobox styles.css'})

local container = mw.html.create('div') container:addClass('infobox') container:addClass('infobox-accessory') 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 addFullRow( container, (brand or ) .. ' ' .. (model_code or ), 'text-align:center; font-size:125%; font-weight:bold; padding:0.5em;', false, 'infobox-title' )

if image_main then local file = image_main:gsub('^File:', ) addFullRow( container, string.format('File:%s', file), 'text-align:center; padding:0;', false, 'infobox-image' ) end

addSectionRow(container, 'Overview')

-- Brand row using #formredlink if brand then local brandWikitext = string.format( '%s', brand, brand ) local brandHtml = frame:preprocess(brandWikitext) addRow(container, 'Brand', brandHtml, true) end

if model_code then addRow(container, 'Model', model_code, false) end

if accessory_type then addRow(container, 'Type', accessory_type, false) end

if description then addRow(container, 'Description', description, false) end

-- Type-specific fields if accessory_type == 'Option card' and card_signals then addRow(container, 'Signals', card_signals, false) end

if accessory_type == 'Media' and media_format then addRow(container, 'Format', media_format, false) end

-- ECID row local ecidWikitext = string.format('EC%d', pageName, pageId, pageId) addRow(container, 'ECID', frame:preprocess(ecidWikitext), true)

-- Compatible CRT models section local crtCountWikitext = 'The part "\n' ..</br> '" of the query was not understood.</br>Results might not be as expected.' local crtCountFromForward = frame:preprocess(crtCountWikitext)

-- Also check reverse links (Has related CRT model set on this accessory page) local crtReverseCountWikitext = 'The part "\n' ..</br> '" of the query was not understood.</br>Results might not be as expected.' local crtCountFromReverse = frame:preprocess(crtReverseCountWikitext)

-- Query for CRTs that have this accessory via forward link (remote_control field) -- OR via Has related CRT model property set on this accessory local hasCRTs = (tonumber(trim(crtCountFromForward)) or 0) > 0

-- Also query CRTs listed in the accessory's crt_models field local crt_models = trim(args.crt_models) local hasCRTsFromField = crt_models and crt_models ~=

if hasCRTs or hasCRTsFromField then addSectionRow(container, 'Compatible CRT Models')

local crtDiv = container:tag('div') css(crtDiv, 'grid-column: 1 / -1; padding:0.2em 0.4em;')

-- Query CRTs that reference this accessory via Has accessory property -- (This handles forward references like remote_control field) local crtQueryWikitext = 'The part "\n' ..</br> '" of the query was not understood.</br>Results might not be as expected.'

-- If we have CRTs from the crt_models field, also query those if hasCRTsFromField then -- Parse crt_models and create OR conditions local crtConditions = {} for crt in crt_models:gmatch('[^,]+') do local c = trim(crt) if c then table.insert(crtConditions, '' .. c .. '') end end

if #crtConditions > 0 then crtQueryWikitext =

'

CRT model\n' .. 'Photo\n' .. 'Model\n' .. 'Size\n' .. '
AKAI CFT2790AKAI CFT2790 front.jpgCFT279027
AKAI CT-K108CT-K108
Action ACN 3505Action ACN 3505 front.jpgACN 35055
Action ACN-3501Action ACN-3501 front.jpgACN-35015
Ademco AMM972224dc4-5780-45e8-b422-dd125e6a6775umar 12101.jpgAMM9
Admiral JSJ12801BAdmiral JSJ12801B front.jpgJSJ12801B25
Advent DV1418AAdvent DV1418A front.jpgDV1418A14
Advent Q1435AAdvent Q1435A front.jpgQ1435A14
Aiwa VX-F205UAiwa VX-F205U front.jpgVX-F205U20
Alexandrower Radiowerk Rekord-BAlexandrower Radiowerk Rekord-B front.jpgRekord-B
Amdek Color 300Color 30013
Amdek Color-1Amdek Color-1 front.jpgColor-113
Apple M4681Apple M4681 front.jpgM468115
Apple Macintosh 5200/75 LCApple Macintosh 5200-75 LC front.jpgMacintosh 5200/75 LC15
Apple Monitor IIApple Monitor II front.jpgMonitor II12
Apple Studio DisplayApple Studio Display front.jpgStudio Display17
Atari PS-3000Atari PS-3000 front.pngPS-300013
Atari SC1224Atari SC1224 monitors (JVC and Goldstar versions).jpgSC122412
Atari SC1435Atari SC1435 front.jpgSC143514
Audiosonic KT-8842Audiosonic KT-8842 front.jpgKT-8842
Audiosonic KT9142MTXAudiosonic KT9142MTX front.jpgKT9142MTX
B&O MX3000B&O MX3000 front.jpgMX300021
BARCONet ADVM20BARCONet ADVM20 front.jpgADVM2020
Bang & Olufsen 35/20Bang & Olufsen 35-20 front.jpg35/20
Bang & Olufsen AV 9000Bang & Olufsen AV 9000 front.jpgAV 900028
Bang & Olufsen BEOCENTER AV5Bang & Olufsen BEOCENTER AV5 front.jpgBeoCenter AV525
Bang & Olufsen BeoVision Avant 28Bang & Olufsen BeoVision Avant 28 front.jpgBeoVision Avant 2828
Bang & Olufsen BeoVision MX 4000Bang & Olufsen BeoVision MX 4000 front.jpgBeoVision MX 400021
Bang & Olufsen Beovision Avant 32Bang & Olufsen Beovision Avant 32 front.jpgBeovision Avant 3232
Bang & Olufsen Beovision MX 6000Beovision MX 600028
Bang & Olufsen MX7000Bang & Olufsen MX7000 front.jpgMX700028
Bang and Olufsen BeoVision Avant 32Bang and Olufsen BeoVision Avant 32 front.jpgBeoVision Avant 3232
Barco 808sBarco 808s front.jpg808s
Barco ADVM14Barco ADVM14 front.jpgADVM1414
Barco ADVM28Barco ADVM28 front.jpgADVM2828
Barco CVM 3670DCVM 3670D28
Bentley 100CBentley 100C front.jpg100C5
Blaupunkt PM 55-48Blaupunkt PM 55-48 front.jpgPM 55-4821
Blaupunkt PalmaBlaupunkt Palma front.jpgPalma
Broksonic CTSG-2799CBroksonic CTSG-2799C front.jpgCTSG-2799C9
Broksonic CTSGT-2799CBroksonic CTSGT-2799C front.jpgCTSGT-2799C9
Category maintenance
Chuntex 1792EChuntex 1792E front.jpg1792E17
Commodore 1084108413
Commodore 1084-DCommodore 1084-D front.jpg1084-D13
Commodore 1084S1084S13
Commodore 1701170113
Commodore 1702Commodore 1702 Video Monitor.jpg170213
Compaq FS7555Compaq FS7555 front.jpgFS755517
Compaq FS7600Compaq FS7600 front.jpgFS760017
... further results

<ul><li>The part "\n' .. '" of the query was not understood.Results might not be as expected.</li> <!--br--><li>The part "' .. table.concat(crtConditions, ' OR ') .. '" of the query was not understood.Results might not be as expected.</li> <!--br--><li>Some subquery has no valid condition.</li></ul>'

end end

local crtHtml = frame:preprocess(crtQueryWikitext) crtDiv:wikitext(crtHtml) end

-- Compatible AV devices section local av_devices = trim(args.av_devices) if av_devices and av_devices ~= then addSectionRow(container, 'Compatible AV Devices')

local avDiv = container:tag('div') css(avDiv, 'grid-column: 1 / -1; padding:0.2em 0.4em;')

-- Parse av_devices and create OR conditions local avConditions = {} for av in av_devices:gmatch('[^,]+') do local a = trim(av) if a then table.insert(avConditions, '' .. a .. '') end end

if #avConditions > 0 then local avQueryWikitext =

'

AV device\n' .. 'Photo\n' .. 'Model\n' .. 'Type\n' .. '
Aiwa AV-50MAV-50MVCR
Aiwa AV-70MAV-70MVCR
Alba VCP 2000VCP 2000Video player
Baird 89228922VCR
Canopus ADVC-300ADVC-300Video processor
Category maintenance
Denon AVR-5805AVR-5805Other
Digital Processing Systems DPS-210Digital Processing Systems DPS-210 front.jpgDPS-210Video processor
Digital Processing Systems DPS-220DPS-220Time base corrector
Digital Processing Systems DPS-235DPS-235 front.jpgDPS-235Time base corrector
Digital Processing Systems DPS-245DPS-245 Quad Framestore.pngDPS-245Frame synchronizer
Digital Processing Systems DPS-265DPS-265Frame synchronizer
Digital Processing Systems DPS-270Digital Processing Systems DPS-270 front.webpDPS-270Time base corrector
Digital Processing Systems DPS-275DPS-275Time base corrector
Digital Processing Systems DPS-290Digital Processing Systems DPS-290 front.jpgDPS-290Time base corrector
Digital Processing Systems DPS-295Digital Processing Systems DPS-295 front.webpDPS-295Time base corrector
Digital Processing Systems DPS-465DPS-465Frame synchronizer
Digital Processing Systems DPS-470DPS-470Frame synchronizer
Digital Processing Systems Personal TBC IVDigital Processing Systems Personal TBC IV front.jpgPersonal TBC IVTime base corrector
Edirol VMC-1VMC-1Video mixer
Emerson VCP660VCP660Video player
Emerson VCP661VCP661Video player
Emerson VCP662VCP662Video player
Emerson VCP663VCP663Video player
Emerson VCP664VCP664Video player
Emerson VCP665VCP665Video player
Emerson VCP675VCP675Video player
Emerson VCP700VCP700VCR
Emerson VCR650VCR650VCR
Emerson VCR754VCR754VCR
Emerson VCR755VCR755VCR
Emerson VCR765VCR765VCR
Emerson VCR765NVCR765NVCR
Emerson VCR800VCR800VCR
Emerson VCR801VCR801VCR
Emerson VCR850VCR850VCR
Emerson VCR870VCR870VCR
Emerson VCR870HVCR870HVCR
Emerson VCR872VCR872VCR
Emerson VCR873VCR873VCR
Emerson VCR874VCR874VCR
Emerson VCR875VCR875VCR
Emerson VCR900VCR900VCR
Emerson VCR910VCR910VCR
Emerson VCR920VCR920VCR
Emerson VCR950VCR950VCR
Emerson VCR951VCR951VCR
Emerson VCR951AVCR951AVCR
Emerson VCR952VCR952VCR
Emerson VCR953VCR953VCR
... further results

<ul><li>The part "\n' .. '" of the query was not understood.Results might not be as expected.</li> <!--br--><li>The part "' .. table.concat(avConditions, ' OR ') .. '" of the query was not understood.Results might not be as expected.</li> <!--br--><li>Some subquery has no valid condition.</li></ul>'

local avHtml = frame:preprocess(avQueryWikitext) avDiv:wikitext(avHtml) end end

-- Documents section addSectionRow(container, 'Documents')

-- Build upload link local timestamp = os.time() math.randomseed(timestamp + pageId) local random = math.random(1000, 9999) local target = "Document:" .. timestamp .. "-" .. random

-- For accessories, we don't have a dedicated document field yet, -- but we can link to the general document form local uploadUrl = mw.uri.fullUrl( "Special:FormEdit", { form = "Document", target = target } )

local docsDiv = container:tag('div') css(docsDiv, 'grid-column: 1 / -1; padding:0.2em 0.4em; text-align:center;') docsDiv:wikitext('[' .. tostring(uploadUrl) .. ' Add a document]')

-- Contribute section addSectionRow(container, 'Contribute')

local editUrl = mw.uri.fullUrl( "Special:FormStart", { form = "Accessory", page_name = pageName } )

local editDiv = container:tag('div') css(editDiv, 'grid-column: 1 / -1; padding:0.2em 0.4em; text-align:center;') editDiv:wikitext('[' .. tostring(editUrl) .. ' Edit this data]')

return styleTag .. tostring(container) end

return p

MediaWiki Appliance - Powered by TurnKey Linux