Module:Jct/city and Module:Jct/city/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
rm space as there already is one |
No edit summary |
||
Line 4: | Line 4: | ||
local insert = table.insert |
local insert = table.insert |
||
local city |
|||
local location |
|||
⚫ | |||
⚫ | |||
local state |
local state |
||
local pageContainsLink |
|||
local function stateName(args) |
local function stateName(args) |
||
Line 19: | Line 25: | ||
end |
end |
||
local function |
local function generateText(num, insertPrefix) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local parts |
local parts |
||
if |
if insertPrefix then |
||
if num == 1 then |
|||
parts = {"– "} |
|||
⚫ | |||
parts = {", "} |
else |
||
parts = {", "} |
|||
end |
|||
end |
end |
||
Line 41: | Line 40: | ||
end |
end |
||
if not pageContainsLink then |
|||
insert(parts, "[[" .. city) |
|||
⚫ | |||
insert(parts, " (" .. areadab .. ")") |
if areadab then |
||
insert(parts, " (" .. areadab .. ")") |
|||
end |
|||
⚫ | |||
⚫ | |||
end |
|||
if state then |
|||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
insert(parts, city) |
|||
return concat(parts) |
|||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
local function _location(args, num, page) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
⚫ | |||
if pageContainsLink == false then |
|||
⚫ | |||
local place = city or location |
|||
local jctString = "{{jct/sandbox|" .. ".+" .. place .. ".+" .. "}}" |
|||
local linkString = generateText(num, false) |
|||
local firstPosition = strfind(page, linkString) |
|||
if firstPosition then |
|||
local secondPosition = strfind(page, linkString, firstPosition) |
|||
if secondPosition or string.find(page, jctString) then |
|||
pageContainsLink = true |
|||
end |
|||
end |
|||
end |
end |
||
return generateText(num, true) |
|||
⚫ | |||
⚫ | |||
end |
end |
||
function p.city(args) |
function p.city(args, page) |
||
state = stateName(args) |
state = stateName(args) |
||
local cities = {} |
local cities = {} |
||
local locationCount = 1 |
local locationCount = 1 |
||
repeat |
repeat |
||
local location = |
local location = _location(args, locationCount, page) |
||
insert(cities, location) |
insert(cities, location) |
||
local empty = (location == '') |
local empty = (location == '') |