Module:Sandbox/Ahecht: Difference between revisions

Content deleted Content added
small doesn't work anyway, no need to support. Support ride and auto-cat
test
 
(18 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
local dots = ...
 
function p.main(frame)
local output = {}
Line 8 ⟶ 11:
output[2] = ''
end
output[3] = '\<br />frame.args: ' .. type(frame.args) .. ' '
if frame.args[1] then
output[4] = frame.args[1]
Line 28 ⟶ 31:
end
local thisframe = mw.getCurrentFrame()
if thisframe then
output[8] = "<br />mw.getCurrentFrame():getTitle(): "
output[9] = thisframe:getTitle()
thisframe = thisframe:getParent()
if thisframe then
output[10] = "<br />mw.getCurrentFrame():getParent():getTitle(): "
output[11] = thisframe:getTitle()
thisframe = thisframe:getParent()
if thisframe then
output[12] = "<br />mw.getCurrentFrame():getParent():getParent():getTitle(): "
output[13] = thisframe:getTitle()
end
end
end
return table.concat(output)
end
 
function p.infoboxattractionisnumeric(frame)
local s = frame.args[1] or frame:getParent().args[1]
local keys = {
local boolean = (frame.args.boolean or frame:getParent().args.boolean) == 'true'
"name",
if type(s) == 'string' and mw.getContentLanguage():parseFormattedNumber( s ) then
"logo",
return boolean and 1 or s
"logo_width",
"logodimensions",
"logo_dimensions",
"image",
"image_width",
"imagedimensions",
"image_dimensions",
"caption",
"locationarticle",
"___location",
"child",
"altname",
"section",
"coordinates",
"status",
"Status",
"multiple",
"auto-cat",
"cost",
"soft_opened",
"opened",
"closed",
"year",
"previousattraction",
"replacement",
"type",
"manufacturer",
"manufacturers",
"designer",
"model",
"theme",
"music",
"height_m",
"height_ft",
"drop_m",
"drop_ft",
"length_m",
"length_ft",
"speed_km/h",
"speed_mph",
"speed_rpm",
"sitearea_sqm",
"sitearea_sqft",
"gforce",
"capacity",
"vehicle_type",
"vehicles",
"riders_per_vehicle",
"rows",
"riders_per_row",
"participants_per_group",
"audience_capacity",
"duration",
"restraint",
"restriction_cm",
"restriction_ft",
"restriction_in",
"sponsor",
"custom_label_1",
"custom_value_1",
"custom_label_2",
"custom_value_2",
"custom_label_3",
"custom_value_3",
"custom_label_4",
"custom_value_4",
"custom_label_5",
"custom_value_5",
"custom_label_6",
"custom_value_6",
"custom_label_7",
"custom_value_7",
"custom_label_8",
"custom_value_8",
"website",
"homepage",
"virtual_queue_image",
"virtual_queue_name",
"virtual_queue_status",
"virtual_queue_image2",
"virtual_queue_name2",
"virtual_queue_status2",
"single_rider",
"pay_per_use",
"accessible",
"transfer_accessible",
"assistive_listening",
"cc",
}
local output = {"{{Infobox attraction/section/sandbox"}
local args = {[0]={}}
for k, v in pairs(frame:getParent().args) do
local val = mw.text.trim(v)
if (val or "") ~= "" then
-- val exists and isn't blank
local loc = tonumber(mw.ustring.sub(k,-1))
if (loc) and (loc > 0) and (loc <= 10)
and (not mw.ustring.match(k, "^location_%d+$"))
and (not mw.ustring.match(k, "^custom_")) then
-- last character is a number 1-10, and it's not "location_#" or "custom_"
if not args[loc] then args[loc] = {} end
-- strip "location_" and number from key
local key = mw.ustring.gsub(mw.ustring.gsub(k, "_?%d+$", ""), "^location_", "")
args[loc][key] = val
elseif (not loc) and (mw.ustring.match(k, "^location_%D")) then
-- default to ___location 1
if (not args[1]) then args[1] = {} end
-- strip "location_" from key
local key = mw.ustring.gsub(k, "^location_", "")
args[1][key] = v
else
args[0][k] = val
end
end
end
return boolean and 0 or ''
end
if string.lower(string.gsub((args[0].type or ""),".*%s","")) == "show" then
 
args[0].ride = "no"
function error(frame, key)
end
return "Error! Missing function " .. key
end
for _, k in ipairs(keys) do
 
if args[0][k] then
metatable = {['__index'] = error}
table.insert(output, "| " .. k .. " = " .. args[0][k])
 
setmetatable(p, metatable)
 
function p.dots()
return dots
end
 
function p.prefix(frame)
local args = {}
for k,v in pairs(frame.args) do
if k ~= '_prefix' and k ~= '_template' then
table.insert(args, '| ' .. (frame.args['_prefix'] or '') .. k .. " = " .. v)
end
end
return table.concat(args, '\n')
for i, a in ipairs(args) do
if not args[0]["location_" .. i] then
-- ___location subtemplate isn't defined
table.insert(output, "| location_" .. i .. " = {{Infobox attraction/section/sandbox | child=yes")
for _, k in ipairs(keys) do
if a[k] then
table.insert(output, "| " .. k .. " = " .. a[k])
end
end
table.insert(output,"| ride = " .. (args[0].ride or ""))
table.insert(output,"| auto-cat = " .. (args[0].auto-cat or ""))
table.insert(output,"}}")
end
end
table.insert(output, "}}")
return frame:preprocess(table.concat(output, "\n"))
end
 
return setmetatable(p, {__index =
function(_, key) -- this anonymous function called as function(TABLE, KEY)
return function (frame) return error (frame, key) end; -- which in turn returns a function that calls cite() with the KEY name
end
})