Module:MapLocation: Difference between revisions
From HOPE Wiki
getting ready to add a map |
mNo edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local function | local function clean(value) | ||
if | if value == nil then | ||
return "" | |||
end | |||
return mw.text.trim(tostring(value)) | |||
end | end | ||
function p.infobox(frame) | function p.infobox(frame) | ||
local | local args = frame:getParent().args | ||
local name = | |||
local lat = | local name = clean(args.name) | ||
local lon = | if name == "" then | ||
local category = | name = mw.title.getCurrentTitle().text | ||
local description = | end | ||
local hours = | |||
local url = | local lat = clean(args.lat) | ||
local lon = clean(args.lon) | |||
local category = clean(args.category) | |||
local description = clean(args.description) | |||
local hours = clean(args.hours) | |||
local url = clean(args.url) | |||
if category == "" then | |||
category = "Other" | |||
end | |||
local out = {} | local out = {} | ||
table.insert(out, '<div class="hope-map-location" style="border:1px solid #aaa; padding:0.75em; margin:0.75em 0; max-width:32em;">') | |||
table.insert(out, | |||
'<div class="hope-map-location" ' .. | |||
'style="border:1px solid #aaa; padding:0.75em; ' .. | |||
'margin:0.75em 0; max-width:32em;">' | |||
) | |||
table.insert(out, "'''" .. name .. "'''<br />") | table.insert(out, "'''" .. name .. "'''<br />") | ||
table.insert(out, "'''Category:''' " .. category .. "<br />") | table.insert(out, "'''Category:''' " .. category .. "<br />") | ||
if lat ~= "" and lon ~= "" then | |||
table.insert(out, | |||
"'''Coordinates:''' " .. lat .. ", " .. lon .. "<br />" | |||
) | |||
else | |||
table.insert(out, "'''Coordinates:''' Missing<br />") | |||
end | |||
if description ~= "" then | |||
table.insert(out, | |||
"'''Description:''' " .. description .. "<br />" | |||
) | |||
end | |||
if hours ~= "" then | |||
table.insert(out, | |||
"'''Hours:''' " .. hours .. "<br />" | |||
) | |||
end | |||
if url ~= "" then | |||
table.insert(out, | |||
"'''Website:''' [" .. url .. " Official website]<br />" | |||
) | |||
end | |||
table.insert(out, "</div>") | |||
table.insert(out, "[[Category:HOPE 26 Map Locations]]") | |||
table.insert(out, "[[Category:HOPE 26 " .. category .. "]]") | |||
return | return table.concat(out, "\n") | ||
end | end | ||
return p | return p | ||
Latest revision as of 22:36, 9 July 2026
Documentation for this module may be created at Module:MapLocation/doc
local p = {}
local function clean(value)
if value == nil then
return ""
end
return mw.text.trim(tostring(value))
end
function p.infobox(frame)
local args = frame:getParent().args
local name = clean(args.name)
if name == "" then
name = mw.title.getCurrentTitle().text
end
local lat = clean(args.lat)
local lon = clean(args.lon)
local category = clean(args.category)
local description = clean(args.description)
local hours = clean(args.hours)
local url = clean(args.url)
if category == "" then
category = "Other"
end
local out = {}
table.insert(out,
'<div class="hope-map-location" ' ..
'style="border:1px solid #aaa; padding:0.75em; ' ..
'margin:0.75em 0; max-width:32em;">'
)
table.insert(out, "'''" .. name .. "'''<br />")
table.insert(out, "'''Category:''' " .. category .. "<br />")
if lat ~= "" and lon ~= "" then
table.insert(out,
"'''Coordinates:''' " .. lat .. ", " .. lon .. "<br />"
)
else
table.insert(out, "'''Coordinates:''' Missing<br />")
end
if description ~= "" then
table.insert(out,
"'''Description:''' " .. description .. "<br />"
)
end
if hours ~= "" then
table.insert(out,
"'''Hours:''' " .. hours .. "<br />"
)
end
if url ~= "" then
table.insert(out,
"'''Website:''' [" .. url .. " Official website]<br />"
)
end
table.insert(out, "</div>")
table.insert(out, "[[Category:HOPE 26 Map Locations]]")
table.insert(out, "[[Category:HOPE 26 " .. category .. "]]")
return table.concat(out, "\n")
end
return p
