Difference between revisions of "Module:Lighthouse tracking"
Jump to navigation
Jump to search
blackwiki>Plastikspork (False positives, moving to sortkey for you!) |
blackwiki>Frietjes |
||
| Line 3: | Line 3: | ||
local res = '' | local res = '' | ||
local isNRHP = false | local isNRHP = false | ||
| + | local hasNRHPbox = false | ||
local heritage = frame.args.heritage or '' | local heritage = frame.args.heritage or '' | ||
if heritage == '' then | if heritage == '' then | ||
| − | elseif (heritage:match(' | + | elseif (heritage:match('National Register of Historic Places') or |
| − | heritage:match('NRHP | + | heritage:match('NRHP') ) then |
res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage]]' | res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage]]' | ||
isNRHP = true | isNRHP = true | ||
else | else | ||
| − | res = res .. '[[Category:Pages using infobox lighthouse with non-NRHP heritage]]' | + | res = res .. '[[Category:Pages using infobox lighthouse with non-NRHP heritage|' .. mw.uri.encode(heritage) .. ']]' |
end | end | ||
| Line 16: | Line 17: | ||
if k and k == 'module' then | if k and k == 'module' then | ||
if v and v:match('<tr') then | if v and v:match('<tr') then | ||
| − | res = res .. '[[Category:Pages using infobox lighthouse with NRHP embedded]]' | + | if v:match('National Register of Historic Places') or v:match('NRHP') then |
| − | + | res = res .. '[[Category:Pages using infobox lighthouse with NRHP embedded]]' | |
| − | res = res .. '[[Category:Pages using infobox lighthouse with NRHP | + | hasNRHPbox = true |
| + | else | ||
| + | res = res .. '[[Category:Pages using infobox lighthouse with non-NRHP embedded]]' | ||
end | end | ||
if v:match('<div style="position') then | if v:match('<div style="position') then | ||
| Line 32: | Line 35: | ||
end | end | ||
end | end | ||
| + | end | ||
| + | if hasNRHPbox == false and isNRHP == true then | ||
| + | res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage|‽]]' | ||
| + | end | ||
| + | if hasNRHPbox == true and isNRHP == false then | ||
| + | res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage|¶]]' | ||
end | end | ||
return res | return res | ||
end | end | ||
return p | return p | ||
Revision as of 17:44, 25 November 2018
This modules produces the tracking categories for Template:Infobox lighthouse
local p = {}
function p.tracking(frame)
local res = ''
local isNRHP = false
local hasNRHPbox = false
local heritage = frame.args.heritage or ''
if heritage == '' then
elseif (heritage:match('National Register of Historic Places') or
heritage:match('NRHP') ) then
res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage]]'
isNRHP = true
else
res = res .. '[[Category:Pages using infobox lighthouse with non-NRHP heritage|' .. mw.uri.encode(heritage) .. ']]'
end
for k, v in pairs( frame:getParent().args ) do
if k and k == 'module' then
if v and v:match('<tr') then
if v:match('National Register of Historic Places') or v:match('NRHP') then
res = res .. '[[Category:Pages using infobox lighthouse with NRHP embedded]]'
hasNRHPbox = true
else
res = res .. '[[Category:Pages using infobox lighthouse with non-NRHP embedded]]'
end
if v:match('<div style="position') then
local pushpin_map = frame:getParent().args.pushpin_map
if pushpin_map and pushpin_map ~= '' then
res = res .. '[[Category:Pages using infobox lighthouse with two location maps]]'
end
end
end
elseif type(k) == 'string' then
if v and v:match('<tr') then
res = res .. '[[Category:Pages using infobox lighthouse with NRHP embedded outside the module parameter]]'
end
end
end
if hasNRHPbox == false and isNRHP == true then
res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage|‽]]'
end
if hasNRHPbox == true and isNRHP == false then
res = res .. '[[Category:Pages using infobox lighthouse with NRHP heritage|¶]]'
end
return res
end
return p