Module:AVDevice: Difference between revisions
Add format_family, supported_formats, recording_formats to infobox display (via update-page on MediaWiki MCP Server) |
Major update: Add semantic queries for structured inputs, outputs, voltage ranges, archival links; add TV system and power spec display (via update-page on MediaWiki MCP Server) |
||
| Line 100: | Line 100: | ||
local year_released = trim(args.year_released) | local year_released = trim(args.year_released) | ||
local year_discontinued = trim(args.year_discontinued) | local year_discontinued = trim(args.year_discontinued) | ||
local | local av_system = trim(args.av_system) | ||
local | local tuner_system = trim(args.tuner_system) | ||
local | local frequency = trim(args.frequency) | ||
local | local power_avg = trim(args.power_avg) | ||
local | local power_max = trim(args.power_max) | ||
local features = trim(args.features) | local features = trim(args.features) | ||
local height = trim(args.height) | local height = trim(args.height) | ||
| Line 110: | Line 110: | ||
local depth = trim(args.depth) | local depth = trim(args.depth) | ||
local weight = trim(args.weight) | local weight = trim(args.weight) | ||
-- Use frame:extensionTag to create a proper <style> tag | -- Use frame:extensionTag to create a proper <style> tag | ||
| Line 179: | Line 177: | ||
end | end | ||
if | -- AV System support | ||
addRow(container, ' | if av_system then | ||
local formattedAV = formatList(av_system, true) | |||
if formattedAV then | |||
addRow(container, 'AV system', formattedAV, false) | |||
end | |||
end | end | ||
| Line 206: | Line 208: | ||
end | end | ||
-- | -- Connectivity section - query structured inputs and outputs | ||
if | local inputsQueryWikitext = | ||
'{{#ask:\n' .. | |||
' [[Has AV device::' .. fullPageName .. ']]\n' .. | |||
' [[Has video signal format::+]]\n' .. | |||
' |?Has input label=Label\n' .. | |||
' |?Has video signal format=Signal\n' .. | |||
' |?Has connector type=Connector\n' .. | |||
' |?Has input count=Count\n' .. | |||
' |?Has input location=Location\n' .. | |||
' |?Has audio type=Audio\n' .. | |||
' |format=count\n' .. | |||
'}}' | |||
local inputCount = frame:preprocess(inputsQueryWikitext) | |||
local hasInputs = inputCount and tonumber(trim(inputCount)) and tonumber(trim(inputCount)) > 0 | |||
local outputsQueryWikitext = | |||
'{{#ask:\n' .. | |||
' [[Has AV device::' .. fullPageName .. ']]\n' .. | |||
' [[Has output signal format::+]]\n' .. | |||
' |format=count\n' .. | |||
'}}' | |||
local outputCount = frame:preprocess(outputsQueryWikitext) | |||
local hasOutputs = outputCount and tonumber(trim(outputCount)) and tonumber(trim(outputCount)) > 0 | |||
if hasInputs or hasOutputs then | |||
addSectionRow(container, 'Connectivity') | addSectionRow(container, 'Connectivity') | ||
if | if hasInputs then | ||
addRow(container, ' | local inputsListWikitext = | ||
'{{#ask:\n' .. | |||
' [[Has AV device::' .. fullPageName .. ']]\n' .. | |||
' [[Has video signal format::+]]\n' .. | |||
' |?Has input count=\n' .. | |||
' |?Has video signal format=\n' .. | |||
' |?Has connector type=\n' .. | |||
' |?Has input location=\n' .. | |||
' |format=template\n' .. | |||
' |template=AV device input row\n' .. | |||
' |named args=yes\n' .. | |||
' |link=none\n' .. | |||
'}}' | |||
local inputsResult = frame:preprocess(inputsListWikitext) | |||
if inputsResult and trim(inputsResult) then | |||
addRow(container, 'Inputs', inputsResult, true) | |||
end | |||
end | end | ||
if | |||
if hasOutputs then | |||
local outputsListWikitext = | |||
'{{#ask:\n' .. | |||
' [[Has AV device::' .. fullPageName .. ']]\n' .. | |||
' [[Has output signal format::+]]\n' .. | |||
' |?Has output count=\n' .. | |||
' |?Has output signal format=\n' .. | |||
' |?Has output connector=\n' .. | |||
' |?Has output location=\n' .. | |||
' |format=template\n' .. | |||
' |template=AV device output row\n' .. | |||
' |named args=yes\n' .. | |||
' |link=none\n' .. | |||
'}}' | |||
local outputsResult = frame:preprocess(outputsListWikitext) | |||
if outputsResult and trim(outputsResult) then | |||
addRow(container, 'Outputs', outputsResult, true) | |||
end | |||
end | end | ||
end | end | ||
| Line 247: | Line 300: | ||
end | end | ||
-- Power section | -- Power section - query voltage ranges and display power specs | ||
if | local voltageQueryWikitext = | ||
'{{#ask:\n' .. | |||
' [[Has AV device::' .. pageName .. ']]\n' .. | |||
' [[Voltage min::+]]\n' .. | |||
' |?Voltage min\n' .. | |||
' |?Voltage max\n' .. | |||
' |format=template\n' .. | |||
' |template=AV device voltage row\n' .. | |||
' |named args=yes\n' .. | |||
' |link=none\n' .. | |||
'}}' | |||
local voltageResult = frame:preprocess(voltageQueryWikitext) | |||
local hasVoltage = voltageResult and trim(voltageResult) and trim(voltageResult) ~= '' | |||
if hasVoltage or frequency or power_avg or power_max then | |||
addSectionRow(container, 'Power') | addSectionRow(container, 'Power') | ||
if | |||
addRow(container, 'Voltage', | if hasVoltage then | ||
addRow(container, 'Voltage', voltageResult, true) | |||
end | end | ||
if | |||
addRow(container, ' | if frequency then | ||
local formattedFreq = formatList(frequency, true) | |||
if formattedFreq then | |||
addRow(container, 'AC frequency', formattedFreq, false) | |||
end | |||
end | |||
if power_avg or power_max then | |||
local powerStr = '' | |||
if power_avg and power_max then | |||
powerStr = power_avg .. 'W (avg) / ' .. power_max .. 'W (max)' | |||
elseif power_avg then | |||
powerStr = power_avg .. 'W' | |||
elseif power_max then | |||
powerStr = power_max .. 'W (max)' | |||
end | |||
addRow(container, 'Power', powerStr, false) | |||
end | end | ||
end | |||
-- Archival Links section - query AV link subobjects | |||
local linksQueryWikitext = | |||
'{{#ask:\n' .. | |||
' [[AV device::' .. fullPageName .. ']]\n' .. | |||
' [[Model link URL::+]]\n' .. | |||
' |?Model link type\n' .. | |||
' |?Model link source\n' .. | |||
' |?Model link URL\n' .. | |||
' |format=count\n' .. | |||
'}}' | |||
local linkCount = frame:preprocess(linksQueryWikitext) | |||
local hasLinks = linkCount and tonumber(trim(linkCount)) and tonumber(trim(linkCount)) > 0 | |||
if hasLinks then | |||
addSectionRow(container, 'Links') | |||
local linksListWikitext = | |||
'{{#ask:\n' .. | |||
' [[AV device::' .. fullPageName .. ']]\n' .. | |||
' [[Model link URL::+]]\n' .. | |||
' |?Model link type\n' .. | |||
' |?Model link source\n' .. | |||
' |?Model link URL\n' .. | |||
' |format=template\n' .. | |||
' |template=AV device link row\n' .. | |||
' |named args=yes\n' .. | |||
' |link=none\n' .. | |||
'}}' | |||
local linksResult = frame:preprocess(linksListWikitext) | |||
local linksDiv = container:tag('div') | |||
css(linksDiv, 'grid-column: 1 / -1; padding:0.2em 0.4em;') | |||
linksDiv:wikitext(linksResult) | |||
end | end | ||