Jump to content

Module:Person/sandbox

From Wikisource
require('strict')

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local error_message = require('Module:Error')['error']
local portal_header = require('Module:Portal header')._portal_header

local authorModule = require('Module:Author')
local author_dates = authorModule._dates
local get_author_image = authorModule._get_image
local construct_defaultsort = authorModule._construct_defaultsort

local p = {}

function p._person(args)
	local name = args.title
	if not name then
		if args.firstname and args.lastname then
			if yesno(args.invert_names) then
				name = args.lastname .. ' ' .. args.firstname
			else
				name = args.firstname .. ' ' .. args.lastname
			end
		else
			name = args.firstname or args.lastname or error_message({'[[Module:Person]] error: name needed'})
		end
	end
	
	args.name_text = name
	args.template_ns = 'Portal'
	args.nocat = false
	local image = get_author_image(args)
	
	local dates = author_dates(args)
	args.title = name .. ((dates and tostring(mw.html.create('span'):css({['font-weight'] = 'normal'}):wikitext(dates))) or '')
	
	args.class = args.class or 'C'
	args.subclass1 = args.subclass1 or 'T'
	args.parent = 'People'
	args.notes = args.notes or args.description
	args.nocat = true
	
	local header = portal_header(args)
	local defaultsort = construct_defaultsort(args)
	
	local cats = {}
	if args.shortcut then
		table.insert(cats, '[[Category:' .. 'Portals with shortcuts' .. ']]')
	end
	if not yesno(args.reviewed) then
		table.insert(cats, '[[Category:' .. 'Portals needing review' .. ']]')
	end
	
	return header .. image .. defaultsort .. table.concat(cats)
end

function p.person(frame)
	return p._person(getArgs(frame))
end

return p