|
|
| (7 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| local p = {}
| | <includeonly> |
| | {{#cargo_store: |
| | _table=MapLocations |
| | |Name={{{name|{{PAGENAME}}}}} |
| | |Location={{{lat|}}},{{{lon|}}} |
| | |Category={{{category|Other}}} |
| | |Description={{{description|}}} |
| | |Hours={{{hours|}}} |
| | |URL={{{url|}}} |
| | }} |
|
| |
|
| local categoryStyles = {
| | {{#invoke:MapLocation|infobox}} |
| Hotel = {
| | </includeonly> |
| symbol = "lodging",
| |
| color = "#7b1fa2"
| |
| },
| |
| Conference = {
| |
| symbol = "star",
| |
| color = "#d32f2f"
| |
| },
| |
| Food = {
| |
| symbol = "restaurant",
| |
| color = "#e65100"
| |
| },
| |
| Coffee = {
| |
| symbol = "cafe",
| |
| color = "#795548"
| |
| },
| |
| Transit = {
| |
| symbol = "rail",
| |
| color = "#1565c0"
| |
| },
| |
| Pharmacy = {
| |
| symbol = "pharmacy",
| |
| color = "#2e7d32"
| |
| },
| |
| Grocery = {
| |
| symbol = "grocery",
| |
| color = "#558b2f"
| |
| },
| |
| ATM = {
| |
| symbol = "bank",
| |
| color = "#00695c"
| |
| },
| |
| Shipping = {
| |
| symbol = "post",
| |
| color = "#455a64"
| |
| },
| |
| Quiet = {
| |
| symbol = "library",
| |
| color = "#5d4037"
| |
| },
| |
| Hardware = {
| |
| symbol = "hardware",
| |
| color = "#616161"
| |
| },
| |
| Emergency = {
| |
| symbol = "hospital",
| |
| color = "#c62828"
| |
| },
| |
| Other = {
| |
| symbol = "marker",
| |
| color = "#555555"
| |
| }
| |
| }
| |
|
| |
|
| local function clean(value)
| | <noinclude> |
| if value == nil then
| | {{#cargo_declare: |
| return ""
| | _table=MapLocations |
| end
| | |Name=String |
| | |Location=Coordinates |
| | |Category=String |
| | |Description=Text |
| | |Hours=String |
| | |URL=URL |
| | }} |
|
| |
|
| return mw.text.trim(tostring(value))
| | Use this template on HOPE 26 map-location pages. |
| end
| |
|
| |
|
| local function getArgs(frame)
| | == Instructions == |
| return frame:getParent().args
| |
| end
| |
|
| |
|
| local function getData(frame)
| | '''To add a new location to the map, create a wiki page for the location, and add its data using the format illustrated below.''' |
| local args = getArgs(frame)
| |
| local title = mw.title.getCurrentTitle()
| |
|
| |
|
| local category = clean(args.category)
| | As soon as you save your new location's wiki page, it should be added to the map. |
| if category == "" then
| |
| category = "Other"
| |
| end
| |
|
| |
|
| local lat = tonumber(clean(args.lat))
| | == Example == |
| local lon = tonumber(clean(args.lon))
| |
|
| |
|
| return {
| | [[The New Yorker Hotel]] |
| name = clean(args.name) ~= "" and clean(args.name) or title.text,
| |
| lat = lat,
| |
| lon = lon,
| |
| category = category,
| |
| description = clean(args.description),
| |
| hours = clean(args.hours),
| |
| url = clean(args.url),
| |
| page = title.prefixedText
| |
| }
| |
| end
| |
|
| |
|
| function p.infobox(frame)
| | <pre> |
| local data = getData(frame)
| | {{Map Location |
| local out = {}
| | |name=The New Yorker Hotel |
| | |lat=40.7527316 |
| | |lon=-73.9936287 |
| | |category=Hotel |
| | |description=HOPE 26 conference hotel. |
| | |hours= |
| | |url=https://www.newyorkerhotel.com/ |
| | }} |
| | </pre> |
|
| |
|
| table.insert(
| | == Fields == |
| out,
| |
| '<div class="hope-map-location" ' ..
| |
| 'style="border:1px solid #aaa; padding:0.75em; ' ..
| |
| 'margin:0.75em 0; max-width:32em;">'
| |
| )
| |
|
| |
|
| table.insert(out, "'''" .. data.name .. "'''<br />")
| | ; name |
| table.insert(out, "'''Category:''' " .. data.category .. "<br />")
| | : Location name. Defaults to the page title. |
|
| |
|
| if data.lat and data.lon then
| | ; lat |
| table.insert(
| | : Required latitude in decimal degrees. |
| out,
| |
| "'''Coordinates:''' " ..
| |
| tostring(data.lat) .. ", " .. tostring(data.lon) .. "<br />"
| |
| )
| |
| else
| |
| table.insert(out, "'''Coordinates:''' Missing or invalid<br />")
| |
| end
| |
|
| |
|
| if data.description ~= "" then
| | ; lon |
| table.insert(
| | : Required longitude in decimal degrees. |
| out,
| |
| "'''Description:''' " .. data.description .. "<br />"
| |
| )
| |
| end
| |
|
| |
|
| if data.hours ~= "" then
| | ; category |
| table.insert(
| | : Hotel, Food, Coffee, Transit, Pharmacy, Grocery, ATM, Shipping, Quiet, Hardware, Emergency, or Other. |
| out,
| |
| "'''Hours:''' " .. data.hours .. "<br />"
| |
| )
| |
| end
| |
|
| |
|
| if data.url ~= "" then
| | ; description |
| table.insert(
| | : Short description for the location page and map popup. |
| out,
| |
| "'''Website:''' [" .. data.url .. " Official website]<br />"
| |
| )
| |
| end
| |
|
| |
|
| table.insert(out, "</div>")
| | ; hours |
| | : Optional hours or availability note. |
|
| |
|
| table.insert(out, "[[Category:HOPE 26 Map Locations]]")
| | ; url |
| table.insert(
| | : Optional official website. |
| out,
| | </noinclude> |
| "[[Category:HOPE 26 " .. data.category .. "]]"
| |
| )
| |
| | |
| return table.concat(out, "\n")
| |
| end
| |
| | |
| function p.geojson(frame)
| |
| local data = getData(frame)
| |
| | |
| if not data.lat or not data.lon then
| |
| return ""
| |
| end
| |
| | |
| local style = categoryStyles[data.category] or categoryStyles.Other
| |
| | |
| local description = data.description
| |
| | |
| if data.hours ~= "" then
| |
| if description ~= "" then
| |
| description = description .. " "
| |
| end
| |
| description = description .. "Hours: " .. data.hours
| |
| end
| |
| | |
| local feature = {
| |
| type = "Feature",
| |
| properties = {
| |
| title = data.name,
| |
| description = description,
| |
| ["marker-symbol"] = style.symbol,
| |
| ["marker-color"] = style.color
| |
| },
| |
| geometry = {
| |
| type = "Point",
| |
| coordinates = {
| |
| data.lon,
| |
| data.lat
| |
| }
| |
| }
| |
| }
| |
| | |
| return mw.text.jsonEncode(feature)
| |
| end
| |
| | |
| return p
| |
This template defines the table "MapLocations". View table.
Use this template on HOPE 26 map-location pages.
Instructions
To add a new location to the map, create a wiki page for the location, and add its data using the format illustrated below.
As soon as you save your new location's wiki page, it should be added to the map.
Example
The New Yorker Hotel
{{Map Location
|name=The New Yorker Hotel
|lat=40.7527316
|lon=-73.9936287
|category=Hotel
|description=HOPE 26 conference hotel.
|hours=
|url=https://www.newyorkerhotel.com/
}}
Fields
- name
- Location name. Defaults to the page title.
- lat
- Required latitude in decimal degrees.
- lon
- Required longitude in decimal degrees.
- category
- Hotel, Food, Coffee, Transit, Pharmacy, Grocery, ATM, Shipping, Quiet, Hardware, Emergency, or Other.
- description
- Short description for the location page and map popup.
- hours
- Optional hours or availability note.
- url
- Optional official website.