Module:AVBrandList: Difference between revisions

Increase query limit and suppress "further results" link for consistency (via update-page on MediaWiki MCP Server)
Revert to category-based approach for consistency with CRT brands - requires brand category pages but is more reliable and scalable (via update-page on MediaWiki MCP Server)
Tag: Manual revert
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- Module:AVBrandList
-- Module:AVBrandList
-- Dynamically generates a list of AV device brand buttons by querying
-- Dynamically generates a list of AV device brand buttons by querying
-- all unique brands from the AV devices category.
-- pre-computed brand category pages with semantic properties.
-- Much faster than scanning all AV device pages.


local p = {}
local p = {}
Line 14: Line 15:


function p.list(frame)
function p.list(frame)
-- Query all AV devices and get their brands
local args = frame.args
-- Use high limit and searchlabel= to suppress "further results"
local linkType = trim(args.link)
 
-- Query brand category pages (fast - only queries category pages, not all AV devices)
local queryWikitext =
local queryWikitext =
'{{#ask:\n' ..
'{{#ask:\n' ..
' [[Category:AV devices]]\n' ..
' [[Is AV brand category::Yes]]\n' ..
' |?Has brand\n' ..
' |?Brand name\n' ..
' |format=broadtable\n' ..
' |format=broadtable\n' ..
' |headers=hide\n' ..
' |headers=hide\n' ..
' |link=none\n' ..
' |link=none\n' ..
' |mainlabel=-\n' ..
' |mainlabel=-\n' ..
' |limit=5000\n' ..
' |limit=500\n' ..
' |searchlabel=\n' ..
' |searchlabel=\n' ..
'}}'
'}}'
Line 30: Line 33:
local queryResult = frame:preprocess(queryWikitext)
local queryResult = frame:preprocess(queryWikitext)
-- Extract unique brands from the result
-- Extract brand names from result
local brandsSet = {}
local brandsList = {}
local brandsList = {}
Line 37: Line 39:
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do
local brand = trim(cellContent:gsub('<[^>]+>', ''))
local brand = trim(cellContent:gsub('<[^>]+>', ''))
if brand and brand ~= '' and not brandsSet[brand] then
if brand and brand ~= '' then
brandsSet[brand] = true
table.insert(brandsList, brand)
table.insert(brandsList, brand)
end
end
Line 54: Line 55:
local output = {}
local output = {}
for _, brand in ipairs(brandsList) do
for _, brand in ipairs(brandsList) do
local templateCall = '{{AV brand entry|brand=' .. brand .. '}}'
local templateCall
if linkType then
templateCall = '{{AV brand entry|brand=' .. brand .. '|link=' .. linkType .. '}}'
else
templateCall = '{{AV brand entry|brand=' .. brand .. '}}'
end
table.insert(output, frame:preprocess(templateCall))
table.insert(output, frame:preprocess(templateCall))
end
end
MediaWiki Appliance - Powered by TurnKey Linux