Module:AVBrandList: Difference between revisions

Arclight changed the content model of the page Module:AVBrandList from "wikitext" to "Scribunto module"
Increase query limit and suppress "further results" link for consistency (via update-page on MediaWiki MCP Server)
Line 15: Line 15:
function p.list(frame)
function p.list(frame)
-- Query all AV devices and get their brands
-- Query all AV devices and get their brands
-- Using broadtable format for easier parsing
-- Use high limit and searchlabel= to suppress "further results"
local queryWikitext =
local queryWikitext =
'{{#ask:\n' ..
'{{#ask:\n' ..
Line 24: Line 24:
' |link=none\n' ..
' |link=none\n' ..
' |mainlabel=-\n' ..
' |mainlabel=-\n' ..
' |limit=500\n' ..
' |limit=5000\n' ..
' |searchlabel=\n' ..
'}}'
'}}'
Line 34: Line 35:
if queryResult then
if queryResult then
-- Parse each row from the broadtable
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('<[^>]+>', ''))
Line 47: Line 47:
table.sort(brandsList)
table.sort(brandsList)
-- If no brands found, return a message
if #brandsList == 0 then
if #brandsList == 0 then
return '<p><em>No AV device brands found.</em></p>'
return '<p><em>No AV device brands found.</em></p>'
MediaWiki Appliance - Powered by TurnKey Linux