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().subpageText
local page_type = 'Marvel Staff'
local value
local top_message = ''
local categories = {}
local output_categories = {}
local output_infobox = {}
local output = {}
table.insert(output, '{{DEFAULTSORT:'..pagename..'|noerror}}')
table.insert(output_categories, 'Marvel Staff')
if h.exists(pagename..' (Disambiguation)')
then
value = 'See '..h.Link(pagename..' (Disambiguation)', 'disambiguation page')..' for versions of "'
value = value..pagename..'" adapted in comic books and other mediums.'
top_message = design.messagebox({value})
end
-- infobox
value, categories = design.add_infobox_page_title_and_image(args, pagename, page_type)
output_categories = h.join_tables(output_categories, categories)
table.insert(output_infobox, value)
value = args.RealName
if not h.isempty(value)
then
table.insert(output_infobox, design.add_infobox_row('Real Name', value) )
if value ~= pagename
then table.insert(output_categories, 'Mismatched Staff Names')
end
else
table.insert(output_infobox, design.add_infobox_row('Real Name', pagename) )
end
table.insert(output_infobox, design.add_infobox_row('Pseudonyms', args.Pseudonyms) )
value, categories = p.group_personal_information(args)
output_categories = h.join_tables(output_categories, categories)
table.insert(output_infobox, value)
value, categories = p.group_professional_information(args)
output_categories = h.join_tables(output_categories, categories)
table.insert(output_infobox, value)
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) )
value = args.OfficialWebsite
if not h.isempty(value)
then table.insert(output, '\n*'..value)
end
--
output_infobox = design.create_infobox( table.concat(output_infobox) )
output_categories = h.add_categories(output_categories)
output = table.concat(output)
return top_message..frame:preprocess(output_infobox..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)
then output = 'Outdated Fields/Marvel Staff'
end
return output
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
--------------------------------------------------------------------------------------------------
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, args.RealName)
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
table.insert(list_of_names, pagename)
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(title_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
-- ********************* GROUPS *********************
--------------------------------------------------------------------------------------------------
function p.group_personal_information(args)
local header = 'Personal Information'
local value
local category
local output_categories = {}
local output = {}
value = args.Gender
if not h.isempty(value)
then
category = value..' Staff Members'
value = h.LinkToCategory(category, value)
table.insert(output_categories, category)
table.insert(output, design.add_infobox_row('Gender', value) )
else
table.insert(output_categories, 'Staff Gender Needed')
end
value = args.DateOfBirth
if not h.isempty(value)
then table.insert(output, design.add_infobox_row('Date of Birth', value) )
else table.insert(output_categories, 'Staff DOB Needed')
end
table.insert(output, design.add_infobox_row('Place of Birth', args.PlaceOfBirth) )
value = args.DateOfDeath
if h.isempty(value)
then table.insert(output_categories, 'Living Staff Members')
else
table.insert(output, design.add_infobox_row('Date of Death', 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
table.insert(output, design.add_infobox_row('Place of Death', args.PlaceOfDeath) )
return design.add_infobox_group(output, header), output_categories
end
--------------------------------------------------------------------------------------------------
function p.group_professional_information(args)
local header = 'Professional Information'
local value
local category
local list = {}
local s
local i
local output_categories = {}
local output = {}
table.insert(output, design.add_infobox_row('Employers', args.Employers) )
value = args.Titles
if not h.isempty(value)
then
value = h.explode(';', value)
for i = 1, #value do
s, category = p.lue_get_titles( h.trim(value[i]) )
table.insert(output_categories, category)
table.insert(list, s)
end
list = mw.text.listToText(list, ', ', ', ')
table.insert(output, design.add_infobox_row('Titles', list) )
end
value = args.First
if not h.isempty(value)
then value = standard.lua_standardized_link(value)
else value = 'Unknown'
end
table.insert(output, design.add_infobox_row('Last released work', value) )
value = args.Last
if not h.isempty(value)
then value = standard.lua_standardized_link(value)
end
table.insert(output, design.add_infobox_row('Last released work', value) )
table.insert(output, design.add_infobox_row('Notable Creations', args.NotableCreations) )
return design.add_infobox_group(output, header), output_categories
end
return p