Module:AVDevice: Difference between revisions
Replace Connectivity section with separate Inputs/Outputs sections matching CRT model style. Uses discoverLocations() for dynamic location discovery and renderIOSection() for consistent rendering. Removes countIOByLocation and buildLocationGroupedIO functions. (via update-page on MediaWiki MCP Server) |
Restore pre-compression source from rev 8199 (with comments, formatting, safe gsub patterns). Only change: args.oem_manufacturer → args.oem (the intended rename from rev 8313, without the destructive compression) (via update-page on MediaWiki MCP Server) |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 108: | Line 108: | ||
end | end | ||
return '$' .. formatted | return '$' .. formatted | ||
end | |||
-- Helper to format related models as wiki links, stripping brand prefix | |||
local function formatRelatedModels(value, deviceBrand) | |||
if not value then return nil end | |||
local items = {} | |||
for item in value:gmatch('[^,]+') do | |||
local trimmed = trim(item) | |||
if trimmed then | |||
local displayText = getDisplayTextWithoutBrand(trimmed, deviceBrand) | |||
table.insert(items, '[[' .. trimmed .. '|' .. displayText .. ']]') | |||
end | |||
end | |||
if #items == 0 then return nil end | |||
return table.concat(items, '<br>') | |||
end | end | ||
| Line 236: | Line 251: | ||
local brand = trim(args.brand) | local brand = trim(args.brand) | ||
local model_code = trim(args.model_code) | local model_code = trim(args.model_code) | ||
local oem_manufacturer = trim(args.oem) | |||
local device_type = trim(args.device_type) | local device_type = trim(args.device_type) | ||
local format_family = trim(args.format_family) | local format_family = trim(args.format_family) | ||
local market = trim(args.market) | |||
local supported_formats = trim(args.supported_formats) | local supported_formats = trim(args.supported_formats) | ||
local recording_formats = trim(args.recording_formats) | local recording_formats = trim(args.recording_formats) | ||
| Line 254: | Line 271: | ||
local depth = trim(args.depth) | local depth = trim(args.depth) | ||
local weight = trim(args.weight) | local weight = trim(args.weight) | ||
local related_models = trim(args.related_models) | |||
-- Use frame:extensionTag to create a proper <style> tag | -- Use frame:extensionTag to create a proper <style> tag | ||
| Line 301: | Line 319: | ||
local brandHtml = frame:preprocess(brandWikitext) | local brandHtml = frame:preprocess(brandWikitext) | ||
addRow(container, 'Brand', brandHtml, true) | addRow(container, 'Brand', brandHtml, true) | ||
end | |||
-- OEM row (shown only when set) | |||
if oem_manufacturer then | |||
local oemWikitext = string.format( | |||
'{{#formredlink: target=%s |form=Manufacturer |existing page link text=%s }}', | |||
oem_manufacturer, oem_manufacturer | |||
) | |||
local oemHtml = frame:preprocess(oemWikitext) | |||
addRow(container, 'OEM', oemHtml, true) | |||
end | end | ||
| Line 307: | Line 335: | ||
end | end | ||
-- Market row | |||
if market then | |||
addRow(container, 'Market', market, false) | |||
end | |||
-- Type row: link to AV Device Search with filter, not to a (possibly non-existent) article | |||
if device_type then | if device_type then | ||
local typeSearchUrl = tostring(mw.uri.fullUrl('AV Device Search', {device_type = device_type})) | |||
local typeWikitext = '<span class="plainlinks">[' .. typeSearchUrl .. ' ' .. device_type .. ']</span>' | |||
addRow(container, 'Type', typeWikitext, true) | |||
end | end | ||
| Line 339: | Line 375: | ||
if formattedAV then | if formattedAV then | ||
addRow(container, 'AV system', formattedAV, false) | addRow(container, 'AV system', formattedAV, false) | ||
end | |||
end | |||
-- Related models | |||
if related_models then | |||
local formattedRelated = formatRelatedModels(related_models, brand) | |||
if formattedRelated then | |||
addRow(container, 'Related', formattedRelated, true) | |||
end | end | ||
end | end | ||
| Line 562: | Line 606: | ||
) | ) | ||
-- Query for | -- Query for accessories linked via Has related AV device | ||
-- Unlike CRT models which have a dedicated remote_control field, | |||
-- AV devices show all accessory types including remote controls here. | |||
local accessoriesCountWikitext = | local accessoriesCountWikitext = | ||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
' [[Category:Accessories]]\n' .. | ' [[Category:Accessories]]\n' .. | ||
' [[Has related AV device::' .. fullPageName .. ']]\n' .. | ' [[Has related AV device::' .. fullPageName .. ']]\n' .. | ||
' |format=count\n' .. | ' |format=count\n' .. | ||
'}}' | '}}' | ||
| Line 582: | Line 627: | ||
' [[Category:Accessories]]\n' .. | ' [[Category:Accessories]]\n' .. | ||
' [[Has related AV device::' .. fullPageName .. ']]\n' .. | ' [[Has related AV device::' .. fullPageName .. ']]\n' .. | ||
' |?Has accessory type=type\n' .. | ' |?Has accessory type=type\n' .. | ||
' |?Has model code=model\n' .. | ' |?Has model code=model\n' .. | ||