Module:Portal parent
Appearance
This module depends on the following other modules: |
This module provides the logic for {{portal parent}}.
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local classification = require('Module:Library of Congress Classification')._classification
function p._portal_parent(args)
local current_title = mw.title.getCurrentTitle()
local pagename = current_title.text
local class = args.class
local subclass1 = args.subclass1
local subclass2 = args.subclass2
local midclass = yesno(args.midclass) or false
local class_link = ''
local subclass1_link = ''
local subclass2_link = ''
if class then
if class ~= 'none' then
local class_text = classification({class = class})
if class_text == pagename then
class_link = '[[Portal:Portals]]'
else
class_link = 'Class ' .. string.upper(class) .. ' - [[Portal:' .. class_text .. '|' .. class_text .. ']]'
end
end
elseif current_title.nsText == 'Portal' then
class_link = '[[Portal:Index]][[Category:Unclassified portals]]'
else
class_link = '[[Portal:Index]]'
end
if (subclass1 and subclass2 and midclass) or (subclass1 and not subclass2) then
local class_text = classification({class = class, subclass1 = subclass1})
if class_text ~= pagename then
subclass1_link = '<br/>Subclass ' .. string.upper(subclass1) .. ' - [[Portal:' .. class_text .. '|' .. class_text .. ']]'
end
end
if subclass2 then
local class_text = classification({class = class, subclass1 = subclass1, subclass2 = subclass2})
if class_text ~= pagename then
local subclass_prefix = ''
if subclass1 and not midclass then
subclass_prefix = string.upper(subclass1)
end
subclass2_link = '<br/>Subclass ' .. subclass_prefix .. string.upper(subclass2) .. ' - [[Portal:' .. class_text .. '|' .. class_text .. ']]'
end
end
return class_link .. subclass1_link .. subclass2_link
end
function p.portal_parent(frame)
return p._portal_parent(getArgs(frame))
end
return p