Module:Staff Template

-- module for Harvey 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 list_of_names = {} local pseudonyms = {} 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' table.insert(list_of_names, pagename) value = args.Name 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 pseudonyms = h.explode(';', value) for i = 1, #pseudonyms do				value = h.trim(pseudonyms[i]) if not h.isempty(value) and value ~= pagename and value ~= args.Name and frame:preprocess(p.lua_dpl_list(value)) ~= 'no_result' then table.insert(list_of_names, value) end end end value, categories = p.lua_get_links_to_subcategories(list_of_names, 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)	value, categories = design.add_links_to_standard_subpages(pagename, 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.PlaceOfBirth) 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) or not h.isempty(args.RealName) then output = 'Outdated Fields/Harvey Staff' end

return output end

-- function p.lua_get_links_to_subcategories(list_of_names, 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 = 'MHarvey Staff/'..subcategory..'s'					elseif h.in_list(list1, subcategory) then category = 'Harvey Staff/'..string.gsub(subcategory, ' Images', '')..'s'					elseif subcategory == 'Editor-in-Chief' then category = 'Harvey Staff/Editors-in-Chief' end end return output, category end local i	local n	local category local value local title_categories = {} local image_categories = {} local titles = { {'Creator', 'subject(s) created by', ''}, {'Editor-in-Chief', 'work(s) that were produced while', 'was Editor-in-Chief'}, {'Cover Artist', 'work(s) where', 'worked on a cover'}, {'Editor', 'work(s) that', 'edited'}, {'Writer', 'work(s) that', 'wrote'}, {'Penciler', 'work(s) that', 'penciled'}, {'Inker', 'work(s) that', 'inked'}, {'Colorist', 'work(s) that', 'colored'}, {'Letterer', 'work(s) that', 'lettered'}, {'Director', 'work(s) that', 'directed'}, {'Producer', 'work(s) that', 'worked as Producer'},

}	local images = { {'Cover Artist Images', 'cover(s)', 'worked on'}, {'Penciler Images', 'image(s)', 'worked on as penciler'}, {'Inker Images', 'image(s)', 'worked on as inker'}, {'Colorist Images', 'image(s)', 'worked on as colorist'}, {'Letterer Images', 'image(s)', 'worked on as letterer'}, }	local output_categories = {} local output = ''

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 if table.concat(title_categories) ==  and table.concat(image_categories) ==  then table.insert(output_categories, 'Staff Articles with no Subcategories') end

title_categories = design.add_section('Work History', mw.text.listToText(title_categories, , ), 2) image_categories = design.add_section('Images', mw.text.listToText(image_categories, , ), 2)

output = title_categories..image_categories return output, output_categories end

-- -- DPL query to check if any subcategories (for example, 'Stan Lee/Penciler') exists at all function p.lua_dpl_list(name) local output = '' 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, visit '..h.Link(name..' (Disambiguation)', 'this disambiguation page')..'.' return design.messagebox({message})

end

return output end

-- function p.get_name(frame) local args = getArgs(frame) local pagename = mw.title.getCurrentTitle.text local value = args.Name 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_birth(frame) local args = getArgs(frame) local value = args.DateOfBirth local year = '' local month = '' local day = '' local output_categories = {} local output = ''

if not h.isempty(value) then month, day, year = string.match(value, '(%D+) (%d+), (%d%d%d%d)') if month == nil then month, year = string.match(value, '(%D+), (%d%d%d%d)') if month == nil then year = string.match(value, '(%d%d%d%d)') if year ~= nil then category = 'Born in '..year output = h.LinkToCategory(category, year) table.insert(output_categories, category) table.insert(output_categories, 'Incomplete Date of Birth') else output = value month, day = string.match(value, '(%D+) (%d+)') if month ~= nil then table.insert(output_categories, 'Incomplete Date of Birth') else table.insert(output_categories, 'Wrong Date Format') end end else category = 'Born in '..year table.insert(output_categories, 'Born in '..year) table.insert(output_categories, 'Born in '..year..', '..month) table.insert(output_categories, 'Incomplete Date of Birth') output = h.LinkToCategory(category..', '..month, month)..', '..h.LinkToCategory(category, year) end else category = 'Born in '..year table.insert(output_categories, 'Born in '..year) table.insert(output_categories, 'Born in '..year..', '..month) output = h.LinkToCategory(category..', '..month, month..' '..day)..', '..h.LinkToCategory(category, year) end else category = 'Staff DOB Needed' output = h.LinkToCategory(category, 'Unknown') table.insert(output_categories, category) end

return output..h.add_categories(output_categories) 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, 'Died in '..value) else table.insert(output_categories, 'Wrong Date Format') end end

return output..h.add_categories(output_categories) end

-- function p.get_place_of_birth(frame) local args = getArgs(frame) local country = args.CountryOfBirth local state = args.StateOfBirth local city = args.CityOfBirth local category = '' local output_categories = {} local output = ''

if not h.isempty(country) then country = h.break_link(country, 1) category = 'Staff Members Born in '..country if country == 'United States of America' then country = 'USA' end output = h.LinkToCategory(category, country) table.insert(output_categories, category) if not h.isempty(state) then output = output..', '..state end if not h.isempty(city) then output = output..', '..city 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 = 'Harvey Staff/Editors-in-Chief' output = h.LinkToCategory(category, 'Editor-in-Chief') elseif value_lower == 'cover artist' then category = 'Harvey Staff/Cover Artists' output = h.LinkToCategory(category, 'Cover Artist') elseif h.in_list({'designer', 'producer', 'production'}, value_lower) then category = 'Harvey Staff/Producers' output = h.LinkToCategory(category, first_upper) elseif h.in_list({'colorist', 'colourist'}, value_lower) then category = 'Harvey Staff/Colorists' output = h.LinkToCategory(category, 'Colorist') elseif h.in_list({'director', 'editor', 'inker', 'letterer', 'penciler', 'writer'}, value_lower) then category = 'Harvey Staff/'..first_upper..'s'				output = h.LinkToCategory(category, first_upper) end return output, category end

return p