Module:AutoHeader: Difference between revisions
Appearance
Intcreator (talk | contribs) No edit summary Tag: Manual revert |
Intcreator (talk | contribs) No edit summary |
||
Line 14: | Line 14: | ||
local phoneResult = mw.visualdata.query( 'Phone', tostring(mw.title.getCurrentTitle()), {'manufacturer'}, {} ) | local phoneResult = mw.visualdata.query( 'Phone', tostring(mw.title.getCurrentTitle()), {'manufacturer'}, {} ) | ||
if(phoneResult ~= nil) then | if(phoneResult ~= nil) then | ||
phoneResult.classification = 'phone' | -- phoneResult.classification = 'phone' | ||
return phoneResult | return phoneResult | ||
end | end |
Revision as of 21:10, 6 January 2025
Documentation for this module may be created at Module:AutoHeader/doc
local p = {}
p.getQuery = function(frame)
return mw.title.getCurrentTitle()
end
p.getData = function(frame)
-- local ret = mw.visualdata.query( schema ("inventory_item"), query (string), printouts (list or table), params (table) )
local inventoryItemResult = mw.visualdata.query( 'Inventory_item', tostring(mw.title.getCurrentTitle()), {''}, {} )
if(inventoryItemResult ~= nil) then
inventoryItemResult.classification = 'inventory item'
return inventoryItemResult
end
local phoneResult = mw.visualdata.query( 'Phone', tostring(mw.title.getCurrentTitle()), {'manufacturer'}, {} )
if(phoneResult ~= nil) then
-- phoneResult.classification = 'phone'
return phoneResult
end
-- local result = mw.visualdata.query( 'Phone', "Model 500", {'manufacturer'}, {} )
-- return result
end
p.getJson = function(frame)
-- local newObj = {}
-- for k in pairs(frame) do newObj[k] = "value" end
-- return mw.text.jsonEncode(newObj)
local data = p.getData(frame)
return mw.text.jsonEncode(data)
end
p.getIntroParagraph = function(frame)
local data = p.getData(frame)
local obj = data
local title = obj.title
local classification = obj.classification
local manufacturer = obj.data.manufacturer
return string.format('The %s is a % that was manufactured by %s', title, classification, manufacturer)
end
return p