Module:CRTModel: Difference between revisions

Add audio properties to input queries and group inputs/outputs by location (Front, Rear, Side) (via update-page on MediaWiki MCP Server)
Add support for non-standard location values (e.g. "rear/front") by querying for "Other" locations that don't match front/rear/side exactly (via update-page on MediaWiki MCP Server)
Line 58: Line 58:
end
end


-- Helper to query inputs for a specific location
-- Helper to query inputs for a specific location (or non-standard locations)
local function queryInputsByLocation(frame, fullPageName, location)
local function queryInputsByLocation(frame, fullPageName, location, isOther)
local locationFilter = ''
local locationFilter = ''
if location then
if isOther then
-- Query for inputs that don't have standard locations
locationFilter = ' [[Has input location::!front]]\n' ..
' [[Has input location::!rear]]\n' ..
' [[Has input location::!side]]\n'
elseif location then
locationFilter = ' [[Has input location::' .. location .. ']]\n'
locationFilter = ' [[Has input location::' .. location .. ']]\n'
end
end
Line 76: Line 81:
' |?Has audio connector=audio_connector\n' ..
' |?Has audio connector=audio_connector\n' ..
' |?Has audio shared with=audio_shared\n' ..
' |?Has audio shared with=audio_shared\n' ..
' |?Has input location=location\n' ..
' |format=ul\n' ..
' |format=ul\n' ..
' |template=CRT input inline\n' ..
' |template=CRT input inline\n' ..
Line 87: Line 93:
end
end


-- Helper to count inputs for a specific location
-- Helper to count inputs for a specific location (or non-standard locations)
local function countInputsByLocation(frame, fullPageName, location)
local function countInputsByLocation(frame, fullPageName, location, isOther)
local locationFilter = ''
local locationFilter = ''
if location then
if isOther then
-- Count inputs that don't have standard locations
locationFilter = ' [[Has input location::!front]]\n' ..
' [[Has input location::!rear]]\n' ..
' [[Has input location::!side]]\n'
elseif location then
locationFilter = ' [[Has input location::' .. location .. ']]\n'
locationFilter = ' [[Has input location::' .. location .. ']]\n'
end
end
Line 107: Line 118:
end
end


-- Helper to query outputs for a specific location
-- Helper to query outputs for a specific location (or non-standard locations)
local function queryOutputsByLocation(frame, fullPageName, location)
local function queryOutputsByLocation(frame, fullPageName, location, isOther)
local locationFilter = ''
local locationFilter = ''
if location then
if isOther then
-- Query for outputs that don't have standard locations
locationFilter = ' [[Has output location::!front]]\n' ..
' [[Has output location::!rear]]\n' ..
' [[Has output location::!side]]\n'
elseif location then
locationFilter = ' [[Has output location::' .. location .. ']]\n'
locationFilter = ' [[Has output location::' .. location .. ']]\n'
end
end
Line 124: Line 140:
' |?Has output count=count\n' ..
' |?Has output count=count\n' ..
' |?Has output label=label\n' ..
' |?Has output label=label\n' ..
' |?Has output location=location\n' ..
' |format=ul\n' ..
' |format=ul\n' ..
' |template=CRT output inline\n' ..
' |template=CRT output inline\n' ..
Line 135: Line 152:
end
end


-- Helper to count outputs for a specific location
-- Helper to count outputs for a specific location (or non-standard locations)
local function countOutputsByLocation(frame, fullPageName, location)
local function countOutputsByLocation(frame, fullPageName, location, isOther)
local locationFilter = ''
local locationFilter = ''
if location then
if isOther then
-- Count outputs that don't have standard locations
locationFilter = ' [[Has output location::!front]]\n' ..
' [[Has output location::!rear]]\n' ..
' [[Has output location::!side]]\n'
elseif location then
locationFilter = ' [[Has output location::' .. location .. ']]\n'
locationFilter = ' [[Has output location::' .. location .. ']]\n'
end
end
Line 563: Line 585:
end
end


-- Inputs section: grouped by location
-- Inputs section: grouped by location (front, rear, side, other)
local locations = {'front', 'rear', 'side'}
local locations = {'front', 'rear', 'side'}
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'}
local locationLabels = {front = 'Front', rear = 'Rear', side = 'Side'}
-- Count total inputs
-- Count total inputs across all standard locations plus "other"
local totalInputs = 0
local totalInputs = 0
for _, loc in ipairs(locations) do
for _, loc in ipairs(locations) do
totalInputs = totalInputs + countInputsByLocation(frame, fullPageName, loc)
totalInputs = totalInputs + countInputsByLocation(frame, fullPageName, loc, false)
end
end
-- Also count inputs with non-standard locations
local otherInputCount = countInputsByLocation(frame, fullPageName, nil, true)
totalInputs = totalInputs + otherInputCount
local hasInputs = totalInputs > 0
local hasInputs = totalInputs > 0
Line 578: Line 604:
local inputsContent = ''
local inputsContent = ''
-- Standard locations
for _, loc in ipairs(locations) do
for _, loc in ipairs(locations) do
local count = countInputsByLocation(frame, fullPageName, loc)
local count = countInputsByLocation(frame, fullPageName, loc, false)
if count > 0 then
if count > 0 then
local locInputs = queryInputsByLocation(frame, fullPageName, loc)
local locInputs = queryInputsByLocation(frame, fullPageName, loc, false)
if locInputs and locInputs ~= '' then
if locInputs and locInputs ~= '' then
inputsContent = inputsContent .. "<div style='margin-bottom:0.3em;'><strong>" .. locationLabels[loc] .. "</strong><br/>" .. locInputs .. "</div>"
inputsContent = inputsContent .. "<div style='margin-bottom:0.3em;'><strong>" .. locationLabels[loc] .. "</strong><br/>" .. locInputs .. "</div>"
end
end
end
end
-- Non-standard locations (e.g., "rear/front", "multiple", etc.)
if otherInputCount > 0 then
local otherInputs = queryInputsByLocation(frame, fullPageName, nil, true)
if otherInputs and otherInputs ~= '' then
inputsContent = inputsContent .. "<div style='margin-bottom:0.3em;'><strong>Multiple</strong><br/>" .. otherInputs .. "</div>"
end
end
end
end
Line 595: Line 629:
local totalOutputs = 0
local totalOutputs = 0
for _, loc in ipairs(locations) do
for _, loc in ipairs(locations) do
totalOutputs = totalOutputs + countOutputsByLocation(frame, fullPageName, loc)
totalOutputs = totalOutputs + countOutputsByLocation(frame, fullPageName, loc, false)
end
end
-- Also count outputs with non-standard locations
local otherOutputCount = countOutputsByLocation(frame, fullPageName, nil, true)
totalOutputs = totalOutputs + otherOutputCount
local hasOutputs = totalOutputs > 0
local hasOutputs = totalOutputs > 0
Line 603: Line 641:
local outputsContent = ''
local outputsContent = ''
-- Standard locations
for _, loc in ipairs(locations) do
for _, loc in ipairs(locations) do
local count = countOutputsByLocation(frame, fullPageName, loc)
local count = countOutputsByLocation(frame, fullPageName, loc, false)
if count > 0 then
if count > 0 then
local locOutputs = queryOutputsByLocation(frame, fullPageName, loc)
local locOutputs = queryOutputsByLocation(frame, fullPageName, loc, false)
if locOutputs and locOutputs ~= '' then
if locOutputs and locOutputs ~= '' then
outputsContent = outputsContent .. "<div style='margin-bottom:0.3em;'><strong>" .. locationLabels[loc] .. "</strong><br/>" .. locOutputs .. "</div>"
outputsContent = outputsContent .. "<div style='margin-bottom:0.3em;'><strong>" .. locationLabels[loc] .. "</strong><br/>" .. locOutputs .. "</div>"
end
end
end
end
-- Non-standard locations
if otherOutputCount > 0 then
local otherOutputs = queryOutputsByLocation(frame, fullPageName, nil, true)
if otherOutputs and otherOutputs ~= '' then
outputsContent = outputsContent .. "<div style='margin-bottom:0.3em;'><strong>Multiple</strong><br/>" .. otherOutputs .. "</div>"
end
end
end
end
MediaWiki Appliance - Powered by TurnKey Linux