Module:CRTModel: Difference between revisions

Restyle accessories section: group by type using addRow (label/value grid) instead of bullet list, matching Archival Links style (via update-page on MediaWiki MCP Server)
Unify connectivity rendering with AV Device: replace separate Inputs/Outputs/Control Ports sections with single Connectivity section using location-grouped display (Front/Rear/Side stripe groups). Uses new CRT input row, CRT output row, and CRT control port row templates. (via update-page on MediaWiki MCP Server)
Line 73: Line 73:
-- Otherwise return the full name
-- Otherwise return the full name
return accessoryName
return accessoryName
end
-- Helper to query inputs/outputs/control ports for a specific location
local function queryIOByLocation(frame, fullPageName, ioType, location)
local locationProp
if ioType == 'input' then
locationProp = 'Has input location'
elseif ioType == 'output' then
locationProp = 'Has output location'
else -- control
locationProp = 'Has control port location'
end
local locationFilter = ''
if location then
locationFilter = ' [[' .. locationProp .. '::' .. location .. ']]\n'
end
local signalProp, countProp, connectorProp, notesProp, labelProp, templateName
local extraProps = ''
if ioType == 'input' then
signalProp = 'Has video signal format'
countProp = 'Has input count'
connectorProp = 'Has connector type'
notesProp = 'Has input notes'
labelProp = 'Has input label'
templateName = 'CRT input row'
extraProps = ' |?Has audio type=audio\n' ..
' |?Has audio connector=audio_connector\n' ..
' |?Has audio shared with=audio_shared\n'
elseif ioType == 'output' then
signalProp = 'Has output signal format'
countProp = 'Has output count'
connectorProp = 'Has output connector'
notesProp = 'Has output notes'
labelProp = 'Has output label'
templateName = 'CRT output row'
else -- control
signalProp = 'Has control signal format'
countProp = 'Has control port count'
connectorProp = 'Has control port connector'
notesProp = 'Has control port notes'
labelProp = 'Has control port label'
templateName = 'CRT control port row'
extraProps = ' |?Has control port direction=direction\n'
end
local queryWikitext =
'{{#ask:\n' ..
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
' [[' .. signalProp .. '::+]]\n' ..
locationFilter ..
' |?' .. countProp .. '=count\n' ..
' |?' .. signalProp .. '=signal\n' ..
' |?' .. connectorProp .. '=connector\n' ..
' |?' .. labelProp .. '=label\n' ..
' |?' .. notesProp .. '=notes\n' ..
extraProps ..
' |format=template\n' ..
' |template=' .. templateName .. '\n' ..
' |named args=yes\n' ..
' |link=none\n' ..
'}}'
local result = frame:preprocess(queryWikitext)
return trim(result)
end
-- Helper to count inputs/outputs/control ports for a specific location
local function countIOByLocation(frame, fullPageName, ioType, location)
local locationProp
if ioType == 'input' then
locationProp = 'Has input location'
elseif ioType == 'output' then
locationProp = 'Has output location'
else -- control
locationProp = 'Has control port location'
end
local locationFilter = ''
if location then
locationFilter = ' [[' .. locationProp .. '::' .. location .. ']]\n'
end
local signalProp
if ioType == 'input' then
signalProp = 'Has video signal format'
elseif ioType == 'output' then
signalProp = 'Has output signal format'
else
signalProp = 'Has control signal format'
end
local countWikitext =
'{{#ask:\n' ..
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
' [[' .. signalProp .. '::+]]\n' ..
locationFilter ..
' |format=count\n' ..
'}}'
local result = frame:preprocess(countWikitext)
return tonumber(trim(result)) or 0
end
-- Helper to build location-grouped I/O content
-- Returns HTML string with stripe groups per location, or nil if empty
local function buildLocationGroupedIO(frame, fullPageName, ioType, locations, locationLabels)
local html = ''
for _, loc in ipairs(locations) do
local count = countIOByLocation(frame, fullPageName, ioType, loc)
if count > 0 then
local locContent = queryIOByLocation(frame, fullPageName, ioType, loc)
if locContent and locContent ~= '' then
html = html ..
'<div class="infobox-io-location-group">' ..
'<div class="infobox-io-location-header">' .. locationLabels[loc] .. '</div>' ..
'<div class="infobox-io-location-content">' .. locContent .. '</div>' ..
'</div>'
end
end
end
if html == '' then return nil end
return html
end
end


Line 537: Line 664:
end
end


-- Inputs section: query ALL inputs with location shown inline
-- Connectivity section: Inputs, Outputs, and Control Ports grouped by location
local inputsCountWikitext =
-- Uses the same visual pattern as Module:AVDevice for consistency
'{{#ask:\n' ..
local locations = {'front', 'rear', 'side'}
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'}
' [[Has video signal format::+]]\n' ..
 
' |format=count\n' ..
local inputsHtml = buildLocationGroupedIO(frame, fullPageName, 'input', locations, locationLabels)
'}}'
local outputsHtml = buildLocationGroupedIO(frame, fullPageName, 'output', locations, locationLabels)
local inputCount = frame:preprocess(inputsCountWikitext)
local controlPortsHtml = buildLocationGroupedIO(frame, fullPageName, 'control', locations, locationLabels)
local hasInputs = inputCount and tonumber(trim(inputCount)) and tonumber(trim(inputCount)) > 0
 
if inputsHtml or outputsHtml or controlPortsHtml then
if hasInputs then
addSectionRow(container, 'Connectivity')
local askWikitext =
 
'{{#ask:\n' ..
if inputsHtml then
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
local labelDiv = container:tag('div')
' [[Has video signal format::+]]\n' ..
labelDiv:addClass('infobox-label')
' |?Has video signal format=signal\n' ..
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
' |?Has connector type=connector\n' ..
labelDiv:wikitext('Inputs')
' |?Has input count=count\n' ..
 
' |?Has input location=location\n' ..
local valueDiv = container:tag('div')
' |?Has audio type=audio\n' ..
valueDiv:addClass('infobox-value')
' |?Has audio connector=audio_connector\n' ..
css(valueDiv, 'padding:0;')
' |?Has audio shared with=audio_shared\n' ..
valueDiv:node(mw.html.create('span'):wikitext(inputsHtml))
' |format=ul\n' ..
end
' |template=CRT input inline\n' ..
 
' |named args=yes\n' ..
if outputsHtml then
' |link=none\n' ..
local labelDiv = container:tag('div')
' |searchlabel=\n' ..
labelDiv:addClass('infobox-label')
'}}'
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
local askHtml = frame:preprocess(askWikitext)
labelDiv:wikitext('Outputs')
 
addSectionRow(container, 'Inputs')
local valueDiv = container:tag('div')
addFullRow(container, askHtml, 'padding:0.2em 0.4em;', true)
valueDiv:addClass('infobox-value')
end
css(valueDiv, 'padding:0;')
valueDiv:node(mw.html.create('span'):wikitext(outputsHtml))
end


-- Outputs section: query ALL outputs with location shown inline
if controlPortsHtml then
local outputsCountWikitext =
local labelDiv = container:tag('div')
'{{#ask:\n' ..
labelDiv:addClass('infobox-label')
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;')
' [[Has output signal format::+]]\n' ..
labelDiv:wikitext('Control')
' |format=count\n' ..
'}}'
local outputCount = frame:preprocess(outputsCountWikitext)
local hasOutputs = outputCount and tonumber(trim(outputCount)) and tonumber(trim(outputCount)) > 0
if hasOutputs then
local outputsAskWikitext =
'{{#ask:\n' ..
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
' [[Has output signal format::+]]\n' ..
' |?Has output type=type\n' ..
' |?Has output signal format=signal\n' ..
' |?Has output connector=connector\n' ..
' |?Has output count=count\n' ..
' |?Has output label=label\n' ..
' |?Has output location=location\n' ..
' |format=ul\n' ..
' |template=CRT output inline\n' ..
' |named args=yes\n' ..
' |link=none\n' ..
' |searchlabel=\n' ..
'}}'
local outputsHtml = frame:preprocess(outputsAskWikitext)
addSectionRow(container, 'Outputs')
addFullRow(container, outputsHtml, 'padding:0.2em 0.4em;', true)
end


-- Control Ports section: query for control port subobjects
local valueDiv = container:tag('div')
local controlPortsCountWikitext =
valueDiv:addClass('infobox-value')
'{{#ask:\n' ..
css(valueDiv, 'padding:0;')
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
valueDiv:node(mw.html.create('span'):wikitext(controlPortsHtml))
' [[Has control signal format::+]]\n' ..
end
' |format=count\n' ..
'}}'
local controlPortCount = frame:preprocess(controlPortsCountWikitext)
local hasControlPorts = controlPortCount and tonumber(trim(controlPortCount)) and tonumber(trim(controlPortCount)) > 0
if hasControlPorts then
local controlPortsAskWikitext =
'{{#ask:\n' ..
' [[Has CRT model::' .. fullPageName .. ']]\n' ..
' [[Has control signal format::+]]\n' ..
' |?Has control signal format=signal\n' ..
' |?Has control port connector=connector\n' ..
' |?Has control port direction=direction\n' ..
' |?Has control port count=count\n' ..
' |?Has control port label=label\n' ..
' |?Has control port location=location\n' ..
' |format=ul\n' ..
' |template=CRT control port inline\n' ..
' |named args=yes\n' ..
' |link=none\n' ..
' |searchlabel=\n' ..
'}}'
local controlPortsHtml = frame:preprocess(controlPortsAskWikitext)
addSectionRow(container, 'Control Ports')
addFullRow(container, controlPortsHtml, 'padding:0.2em 0.4em;', true)
end
end


MediaWiki Appliance - Powered by TurnKey Linux