Module:RepairServicesMap

Revision as of 01:25, 13 January 2026 by Arclight-MCP-Bot (talk | contribs) (Create Lua module for repair services map (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

-- Module:RepairServicesMap -- Generates a map of all repair services using SMW queries

local p = {}

function p.map(frame)

   local args = frame.args
   local height = args.height or '500'
   local zoom = args.zoom or '2'
   local filter = args.filter or 
   
   -- Build the SMW query
   local query = 'The following coordinate was not recognized: +.'
   if filter ~=  then
       query = query .. '~*' .. filter .. '*'
   end
   
   -- Get results using SMW
   local smw = mw.smw
   if not smw then
       return 'Semantic MediaWiki not available'
   end
   
   local results = smw.ask({
       query,
       '?Has coordinates',
       '?Has name',
       '?Has city',
       '?Has device types',
       '?Has mail-in service',
       limit = 500
   })
   
   if not results or #results == 0 then

return '

No repair services with coordinates found.

'

   end
   
   -- Build coordinate string for display_map
   local coords = {}
   for _, result in ipairs(results) do
       local coord = result['Has coordinates']
       local name = result['Has name'] or result[1] or 'Unknown'
       local city = result['Has city'] or 
       local devices = result['Has device types'] or 
       local mailin = result['Has mail-in service'] or 
       
       if coord then
           -- Handle if coord is a table (SMW sometimes returns tables)
           if type(coord) == 'table' then
               coord = coord[1]
           end
           
           -- Build popup text
           local popup = "" .. name .. ""
           if city ~=  then
               popup = popup .. '
' .. city end if devices ~= then if type(devices) == 'table' then devices = table.concat(devices, ', ') end popup = popup .. '
Repairs: ' .. devices end if mailin == 'Yes' then popup = popup .. '
✓ Mail-in available' end table.insert(coords, coord .. '~' .. popup) end end if #coords == 0 then

return '

No valid coordinates found.

'

   end
   
   -- Use frame:preprocess to call #display_map
   local coordString = table.concat(coords, ';')

local mapWikitext = '

Loading map...

'

   return frame:preprocess(mapWikitext)

end

function p.count(frame)

   local smw = mw.smw
   if not smw then return '0' end
   
   local results = smw.ask({
       ,
       limit = 500
   })
   
   return results and #results or 0

end

return p

MediaWiki Appliance - Powered by TurnKey Linux