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 | ||
-- | -- Connectivity section: Inputs, Outputs, and Control Ports grouped by location | ||
local | -- Uses the same visual pattern as Module:AVDevice for consistency | ||
local locations = {'front', 'rear', 'side'} | |||
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'} | |||
local inputsHtml = buildLocationGroupedIO(frame, fullPageName, 'input', locations, locationLabels) | |||
local outputsHtml = buildLocationGroupedIO(frame, fullPageName, 'output', locations, locationLabels) | |||
local | local controlPortsHtml = buildLocationGroupedIO(frame, fullPageName, 'control', locations, locationLabels) | ||
local | |||
if inputsHtml or outputsHtml or controlPortsHtml then | |||
if | addSectionRow(container, 'Connectivity') | ||
local | |||
' | if inputsHtml then | ||
' | local labelDiv = container:tag('div') | ||
labelDiv:addClass('infobox-label') | |||
' | css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;') | ||
' | labelDiv:wikitext('Inputs') | ||
' | |||
' | local valueDiv = container:tag('div') | ||
valueDiv:addClass('infobox-value') | |||
css(valueDiv, 'padding:0;') | |||
' | valueDiv:node(mw.html.create('span'):wikitext(inputsHtml)) | ||
' | end | ||
' | |||
if outputsHtml then | |||
' | local labelDiv = container:tag('div') | ||
labelDiv:addClass('infobox-label') | |||
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;') | |||
labelDiv:wikitext('Outputs') | |||
local valueDiv = container:tag('div') | |||
valueDiv:addClass('infobox-value') | |||
css(valueDiv, 'padding:0;') | |||
valueDiv:node(mw.html.create('span'):wikitext(outputsHtml)) | |||
end | |||
if controlPortsHtml then | |||
local labelDiv = container:tag('div') | |||
labelDiv:addClass('infobox-label') | |||
css(labelDiv, 'padding:0.2em 0.4em; font-weight:bold; text-align:left;') | |||
labelDiv:wikitext('Control') | |||
local valueDiv = container:tag('div') | |||
valueDiv:addClass('infobox-value') | |||
css(valueDiv, 'padding:0;') | |||
valueDiv:node(mw.html.create('span'):wikitext(controlPortsHtml)) | |||
end | |||
end | end | ||