FANDOM


-- <nowiki>
-- Implements {{Lore navbox}}
 
local p = {}
local navbox = require( 'Module:Navbox' )._navbox
 
function p.main(frame)
	local args = frame:getParent().args
	local groupnr = 1
	nArgs = {}
 
	nArgs.doc = (isNotEmptyOrNil(args.doc) and args.doc or 'yes')
	nArgs.footer = args.footer
	nArgs.title = (isNotEmptyOrNil(args.title) and args.title or '[[Transcript:'..args.name..'|'..args.name..']]')
	nArgs.name = args.name
 
	groupnr = showGroup(args, 'characters', 'Characters', groupnr)
	groupnr = showGroup(args, 'locations', 'Locations', groupnr)
	groupnr = showGroup(args, 'conflicts', 'Conflicts', groupnr)
	groupnr = showGroup(args, 'related', 'Miscellaneous', groupnr)
 
	local cats = ''
	if string.lower(nArgs.doc) == 'yes' then
		cats = frame:expandTemplate{ title = 'Ctg', args = { args.name } }
		local templatecats = (isNotEmptyOrNil(categories(args)) and categories(args) or '')
		cats = cats..(isNotEmptyOrNil(templatecats) and frame:expandTemplate{title = 'Template only', args = {templatecats}} or '')
	end
 
	return navbox(nArgs)..cats
end
 
function showGroup(args, groupname, title, groupnr)
	if isNotEmptyOrNil(args[groupname]) then
		nArgs['gtitle'..groupnr] = (isNotEmptyOrNil(args[groupname..' title']) and args[groupname..' title'] or title)
		nArgs['gtype'..groupnr] = 'subgroup'
		nArgs['group'..groupnr] = args[groupname]
		groupnr = groupnr + 1
	end
	return groupnr
end
 
function categories(args)
	local cats = ''
	local namewithoutarticle = string.match(args.name,'The (.+)') or
					string.match(args.name,'An? (.+)') or
					args.name
 
	cats = '[[Category:Lore templates|'..namewithoutarticle..']]'
 
	return cats
end
 
function isNotEmptyOrNil(s)
        local bool = false
        bool = (s ~= nil and s ~= '')
        return bool
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.