Documentation for this module may be created at Module:Staff Template/doc
-- module for Marvel Database:Staff Template
local p = {}
local getArgs = require('Dev:Arguments').getArgs
local h = require("Module:HF")
local design = require('Module:Design')
local standard = require("Module:StandardizedName")
function p.main(frame)
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().text
local page_type = 'Staff'
local value
local categories = {}
local output_categories = {}
local output_infobox = {}
local output = {}
table.insert(output_categories, p.lua_get_outdated_fields(args) )
-- sections
value, categories = design.add_quote(args)
output_categories = h.join_tables(output_categories, categories)
table.insert(output, value)
value = args.PersonalHistory
if h.isempty(value)
then table.insert(output_categories, 'Personal History Needed')
else table.insert( output, design.add_section('Personal History', value, 2) )
end
value = args.ProfessionalHistory
if h.isempty(value)
then table.insert(output_categories, 'Professional History Needed')
else table.insert( output, design.add_section('Professional History', value, 2) )
end
-- add links to categories like '/Writer' and '/Penciler Images'
value, categories = p.lua_get_links_to_subcategories(args, pagename)
output_categories = h.join_tables(output_categories, categories)
table.insert(output, value)
table.insert( output, design.add_section('Notes', args.Notes, 2) )
table.insert( output, design.add_section('Trivia', args.Trivia, 2) )
table.insert( output, design.add_header('See Also', 2) )
--add links to standard sub-pages/categories - "Appearances", "Minor Appearances", Mentions", "Images", "Quotes" and "Gallery"
value, categories = design.add_links_to_standard_subpages(pagename..' (Earth-1218)', page_type)
output_categories = h.join_tables(output_categories, categories)
output = h.join_tables(output, value)
table.insert( output, design.add_links_and_references(args, pagename) )
--
output_categories = h.add_categories(output_categories)
output = table.concat(output)
return frame:preprocess(output)..output_categories
end
--------------------------------------------------------------------------------------------------
function p.lua_get_outdated_fields(args)
local output = ''
if not h.isempty(args.Custom)
or not h.isempty(args.CustomLabel)
or not h.isempty(args.YearOfBirth)
or not h.isempty(args.MonthOfBirth)
or not h.isempty(args.DayOfBirth)
or not h.isempty(args.CountryOfBirth)
or not h.isempty(args.StateOfBirth)
or not h.isempty(args.CityOfBirth)
or not h.isempty(args.Creations)
or not h.isempty(args.PersonalHistoryHeader)
or not h.isempty(args.ProfessionalHistoryHeader)
or not h.isempty(args.WorkHistoryHeader)
or not h.isempty(args.ImageLinksHeader)
or not h.isempty(args.NotesHeader)
or not h.isempty(args.TriviaHeader)
or not h.isempty(args.CustomSection1)
or not h.isempty(args.CustomText1)
or not h.isempty(args.CustomSection2)
or not h.isempty(args.CustomText2)
or not h.isempty(args.SeeAlsoHeader)
or not h.isempty(args.LinksHeader)
or not h.isempty(args.NotesHeader)
or not h.isempty(args.CustomRole1)
or not h.isempty(args.CustomRole2)
or not h.isempty(args.OfficialWebsiteHeader)
then output = 'Outdated Fields/Marvel Staff'
end
return output
end
--------------------------------------------------------------------------------------------------
function p.lua_get_links_to_subcategories(args, pagename)
local function add_link(name, s_type, subcategory, text1, text2)
local list1 = {'Editor', 'Cover Artist', 'Writer', 'Penciler', 'Inker', 'Colorist', 'Letterer', 'Director', 'Producer'}
local list2 = {'Penciler Images', 'Inker Images', 'Colorist Images', 'Letterer Images'}
local category = ''
local n = h.pages_in_category(name..'/'..subcategory, s_type)
local output = ''
if n > 0
then
output = '\n*'..h.LinkToCategory(name..'/'..subcategory, n..' '..text1..' "'..name..'" '..text2)
if h.in_list(list1, subcategory)
then category = 'Marvel Staff/'..subcategory..'s'
elseif h.in_list(list1, subcategory)
then category = 'Marvel Staff/'..string.gsub(subcategory, ' Images', '')..'s'
elseif subcategory == 'Editor-in-Chief'
then category = 'Marvel Staff/Editors-in-Chief'
end
end
return output, category
end
local i
local n
local category
local value
local list_of_names = {}
local title_categories = {}
local image_categories = {}
local titles = {
{'Creator', 'subject(s) created by', ''},
{'Editor-in-Chief', 'comic(s) that were produced while', 'was Editor-in-Chief'},
{'Cover Artist', 'comic(s) where', 'created the cover'},
{'Editor', 'comic(s) that', 'edited'},
{'Writer', 'comic(s) that', 'wrote'},
{'Penciler', 'comic(s) that', 'penciled'},
{'Inker', 'comic(s) that', 'inked'},
{'Colorist', 'comic(s) that', 'colored'},
{'Letterer', 'comic(s) that', 'lettered'},
{'Director', 'work(s) that', 'directed'},
{'Producer', 'work(s) that', 'worked as Producer'},
}
local images = {
{'Cover Artist Images', 'covers drawn by', ''},
{'Penciler Images', 'images penciled by', ''},
{'Inker Images', 'images inked by', ''},
{'Colorist Images', 'images colored by', ''},
{'Letterer Images', 'images lettered by', ''},
}
local output_categories = {}
local output = ''
table.insert(list_of_names, pagename)
value = args.RealName
if not h.isempty(value) and value ~= pagename
then table.insert(list_of_names, value)
end
value = args.Pseudonyms
if not h.isempty(value)
then
value = h.explode(';', value)
for i = 1, #value do
table.insert(list_of_names, h.trim(value[i]))
end
end
for i = 1, #list_of_names do
for j = 1, #titles do
value, category = add_link(list_of_names[i], 'pages', titles[j][1], titles[j][2], titles[j][3])
table.insert(title_categories, value)
table.insert(output_categories, category)
end
for j = 1, #images do
value, category = add_link(list_of_names[i], 'files', images[j][1], images[j][2], images[j][3])
table.insert(image_categories, value)
table.insert(output_categories, category)
end
end
title_categories = design.add_section('Work History', mw.text.listToText(title_categories, '', ''), 2)
image_categories = design.add_section('Images Drawn by '..pagename, mw.text.listToText(image_categories, '', ''), 2)
output = title_categories..image_categories
return output, output_categories
end
--------------------------------------------------------------------------------------------------
function p.lua_get_sort_name(pagename)
local s
local output = pagename
s = h.explode(' ', pagename)
if tonumber(s[#s]) == nil
then output = s[#s]..' '..string.gsub(pagename, ' '..s[#s], '')
else output = pagename
end
return output
end
--------------------------------------------------------------------------------------------------
function p.top_message(frame)
local function add_message(name)
local message = 'For fictional versions of '..name..' as a character within comic books or other media,<br>visit '..h.Link(name..' (Disambiguation)', 'this disambiguation page')..'.'
return design.messagebox({message})
end
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().text
local sort_name = '{{DEFAULTSORT:'..p.lua_get_sort_name(pagename)..'|noerror}}'
local output = ''
if h.exists(pagename..' (Disambiguation)')
then output = add_message(pagename)
elseif not h.isempty(args.Title) or not h.isempty(args.Name) or not h.isempty(args.RealName)
then
if not h.isempty(args.Title)
then value = h.break_link(args.Title, 1)
elseif not h.isempty(args.Name)
then value = h.break_link(args.Name, 1)
else value = h.break_link(args.RealName, 1)
end
value = string.gsub(value, ' (Disambiguation)', '')
if h.exists(value..' (Disambiguation)')
then output = add_message(value)
end
end
return frame:preprocess(output..sort_name)..h.Category('Marvel Staff')
end
--------------------------------------------------------------------------------------------------
function p.get_name(frame)
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().text
local value = args.Name or args.RealName
local output = ''
if not h.isempty(value)
then
output = value
if value ~= pagename
then output = output..h.Category('Mismatched Staff Names')
end
else
output = pagename
end
return output
end
--------------------------------------------------------------------------------------------------
function p.get_gender(frame)
local args = getArgs(frame)
local value = args.Gender
local category = value..' Staff Members'
local output = h.LinkToCategory(category, value)
return output..h.Category(category)
end
--------------------------------------------------------------------------------------------------
function p.get_date_of_death(frame)
local args = getArgs(frame)
local value = args.DateOfDeath
local output_categories = {}
local output = ''
if h.isempty(value)
then table.insert(output_categories, 'Living Staff Members')
else
output = value
table.insert(output_categories, 'Deceased Staff Members')
value = string.match(value, '(%d%d%d%d)')
if not h.isempty(value)
then table.insert(output_categories, 'Year of Death - '..value)
end
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------------------------
function p.get_titles(frame)
local args = getArgs(frame)
local list = h.explode(';', args.Titles)
local i
local value
local category
local output_categories = {}
local output = {}
for i = 1, #list do
value, category = p.lue_get_titles( h.trim(list[i]) )
table.insert(output_categories, category)
table.insert(output, value)
end
output = mw.text.listToText(output, ', ', ', ')
return output..h.add_categories(output_categories)
end
function p.lue_get_titles(value)
local category = ''
local value_lower = string.lower(value)
local first_upper = string.upper( string.sub(value, 1, 1) )..string.sub(value_lower, 2, #value_lower)
local output = value
if h.in_list({'editor in chief', 'editor-in-chief'}, value_lower)
then
category = 'Marvel Staff/Editors-in-Chief'
output = h.LinkToCategory(category, 'Editor-in-Chief')
elseif value_lower == 'cover artist'
then
category = 'Marvel Staff/Cover Artists'
output = h.LinkToCategory(category, 'Cover Artist')
elseif h.in_list({'designer', 'producer', 'production'}, value_lower)
then
category = 'Marvel Staff/Producers'
output = h.LinkToCategory(category, first_upper)
elseif h.in_list({'colorist', 'colourist'}, value_lower)
then
category = 'Marvel Staff/Colorists'
output = h.LinkToCategory(category, 'Colorist')
elseif h.in_list({'director', 'editor', 'inker', 'letterer', 'penciler', 'writer'}, value_lower)
then
category = 'Marvel Staff/'..first_upper..'s'
output = h.LinkToCategory(category, first_upper)
end
return output, category
end
return p