Documentation for this module may be created at Module:Category Message Templates/doc
-- module for message template placed in categories
local p = {}
local h = require("Module:HF")
local design = require('Module:Design')
local getArgs = require('Dev:Arguments').getArgs
local g_list_of_months = {'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'}
function p.test()
local basepagename = mw.title.getCurrentTitle().baseText
local subpagename = mw.title.getCurrentTitle().subpageText
local root = mw.title.getCurrentTitle().rootText
local full = mw.title.getCurrentTitle().fullText
local prefixed = mw.title.getCurrentTitle().prefixedText
local text = mw.title.getCurrentTitle().text
return 'base='..basepagename..'<br>subpage='..subpagename..'<br>root='..root..'<br>prefixed='..prefixed..'<br>full='..full..'<br>text='..text
end
--------------------------------------------------------------------------------
-- work-in-progress
function p.appearance_tags(pagename)
local function add_links_from_list(list)
local i
local value
local output = {}
for i = 1, #list do
value = list[i]
value = h.Link('Template:'..value, value)
table.insert(output, value)
end
return p.lua_add_navigation(output)
end
--local pagename = mw.title.getCurrentTitle().text
local list = {}
local death_destruction = {'ApDeath', 'Death', 'Deceased', 'Destruction', 'Destroyed', 'Only Dies', 'Only Destruction', 'Corpse', 'Ruins', 'Grave'}
local message = ''
local header = ''
local help = ''
local code = ''
local output_categories = {}
local output = ''
if h.in_list(death_destruction, pagename)
then
header = design.span('An appearance tag indicating what character clearly died.').bold
help = add_links_from_list(death_destruction)
message = design.messagebox({header..help})
code = '<pre>{{'..pagename..'|[[subject_name]]}} or {{'..pagename..'}}</pre> Where <code>subject_name</code> is page name of the subject that appears in this medium (comic issue, episode, movie, game, novel, etc.). Parameter can be omitted when another appearance tag was already used with link and this one is added to indicate additional information.'
code = code..'\nThis is a '..h.LinkToCategory('Major Appearance Templates', design.span('major appearance template').bold)
code = code..'.If used with parameter it would add page into <code>Category:subject_name/Appearances</code>.'
code = code.." If subject's appearance is actually "..h.LinkToCategory('Minor Appearance Templates', design.span('minor').bold)
code = code..', then use '..h.Link('Template:Minor', 'Template:Minor')..' and this template without parameter (<pre>{{Minor|[[subject_name]]}} {{'..pagename..'}}</pre>'
code = design.add_section('Code', code, 2)
output = message..code
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
function p.homage_main_category(frame)
local function sort_by_pages_number(a, b)
return a.link < b.link
--[[if a.count == b.count
then return a.link < b.link
else return a.count < b.count
end ]]--
end
local m_date = require('Module:Date')
local volume = require('Module:Volume_Template')
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().baseText
local dpl_string = frame:preprocess('{{#dpl:|category = Homages by Internal Source|namespace = Category|format = ,%PAGE%,@@@,}}')
local dpl_list = mw.text.split(dpl_string, '@@@', true)
local value
local image_content
local issue_content
local year
local month
local list = {}
local output = {}
for i = 1, #dpl_list-1 do
local item = {}
value = dpl_list[i]
value = string.gsub(value, ':Category:', '')
--item.count = h.pages_in_category(value, 'files')
item.image = string.gsub(value, '/Homages', '')
item.link = h.LinkToCategory(value, item.image) --..'<br>'..item.count..' images'
--[[
image_content = h.get_content(value)
issue_content = h.get_content(h.get_field_value(image_content, 'Source'))
year = h.get_field_value(issue_content, 'Year')
month = h.get_field_value(issue_content, 'Month')
if not h.isempty(year)
then
if not h.isempty(month)
then item.date = '<br>('..m_date.get_month_name({month})..', '..year..')'
else item.date = '<br>('..year..')'
end
else item.date = ''
end
item.sort_date = volume.lua_get_sort_date(year, month)
]]--
table.insert(list, item)
end
table.sort(list, sort_by_pages_number)
for i = 1, #list do
table.insert(output, '\n'..list[i].image..'|'..list[i].link)
end
output = '<gallery position="center" captionalign="center" widths="200px" >'..table.concat(output)..'</gallery>'
return frame:preprocess(output)
end
--------------------------------------------------------------------------------
-- used in Template:Homage Category and Template:Reprinted Image Category
function p.homage_and_reprinted_image_category(frame)
local function sort_issues_by_date(a, b)
if a.sort_date == b.sort_date
then return a.issue < b.issue
else return a.sort_date < b.sort_date
end
end
local m_date = require('Module:Date')
local standard = require('Module:StandardizedName')
local volume = require('Module:Volume_Template')
local pagename = mw.title.getCurrentTitle().baseText
local args = getArgs(frame)
local original = args.original
local category_type = args['type']
local message = ''
local source
local dpl_string = frame:preprocess('{{#dpl:|category = '..mw.title.getCurrentTitle().text..'|namespace = File|include = {Marvel Database:Image Template}:Source|mode = userformat|secseparators = %PAGE%~,@@@}}')
local dpl_list = mw.text.split(dpl_string, '@@@', true)
local list = {}
local value
local issue
local list_of_unique_issues = {}
local unique_issue = true
local issue_content
local file_content
local year
local month
local main_image = ''
local textless_image = ''
local navigation = {p.lua_add_navigation_link(pagename..'/Homages', 'Homages', 'files') , p.lua_add_navigation_link(pagename..'/Reprints', 'Reprints', 'files')}
local gallery = {}
local output_categories = {}
local output = ''
for i = 1, #dpl_list-1 do
value = mw.text.split(dpl_list[i], '~', true)
issue = {
image = string.gsub(value[1], ':File:', ''),
issue = value[2]
}
table.insert(list, issue)
unique_issue = true
for j = 1, #list_of_unique_issues do
if list_of_unique_issues[j] == value[2]
then unique_issue = false
end
end
if unique_issue
then table.insert(list_of_unique_issues, value[2])
end
end
for j = 1, #list_of_unique_issues do
issue_content = h.get_content(list_of_unique_issues[j])
year = h.get_field_value(issue_content, 'Year')
month = h.get_field_value(issue_content, 'Month')
for i = 1, #list do
if list[i].issue == list_of_unique_issues[j]
then
list[i].sort_date = volume.lua_get_sort_date(year, month)
if not h.isempty(year)
then
if not h.isempty(month)
then list[i].date = '<br>('..m_date.get_month_name({month})..', '..year..')'
else list[i].date = '<br>('..year..')'
end
else list[i].date = ''
end
end
end
end
table.sort(list, sort_issues_by_date)
for i = 1, #list do
table.insert(gallery, '\n'..list[i].image..'|'..standard.lua_standardized_link(list[i].issue)..list[i].date)
end
gallery = '<gallery position="center" captionalign="center" widths="200px" >'..table.concat(gallery)..'</gallery>'
if not h.isempty(original)
then -- external homage
message = original
table.insert(output_categories, 'Homages by External Source')
output = design.add_section('Homages', gallery, 2)
else
file_content = h.get_content('File:'..pagename)
original = h.get_field_value(file_content, 'Source')
if string.find(pagename, ' Textless.', 1, true) ~= nil
then
textless_image = '\n'..pagename
main_image = string.gsub(pagename, ' Textless', '')
if not h.exists('File:'..main_image)
then main_image = ''
else main_image = '\n'..main_image
end
else
main_image = '\n'..pagename
textless_image = string.gsub(pagename, '%.%a+$', '')
mw.log(textless_image)
if h.exists('File:'..textless_image..' Textless.jpg')
then textless_image = '\n'..textless_image..' Textless.jpg'
else textless_image = ''
end
end
if not h.isempty(original)
then
table.insert(output_categories, original..'/Images')
message = standard.lua_get_link_and_release_date(original)
end
message = message..p.lua_add_navigation(navigation, ' · ', true)
message = design.messagebox({message})
message = message..design.add_section('Original Image', '<gallery position="center" captionalign="center" widths="250px">'..main_image..textless_image..'</gallery>', 2)
if category_type == 'reprint'
then
output = design.add_section('Reprints', gallery, 2)
table.insert(output_categories, 'Reprinted Images by Source')
value = h.get_field_value(file_content, 'HomageOf')
if not h.isempty(value)
then table.insert(output_categories, value..'/Homages')
end
else
output = design.add_section('Homages', gallery, 2)
table.insert(output_categories, 'Homages by Internal Source')
end
end
return frame:preprocess(message..output)..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Unseen Subjects
function p.unseen_subjects(frame)
local pagename = mw.title.getCurrentTitle().text
local subject = string.match(pagename, 'Unseen (.+)')
local subjects = {'Characters', 'Events', 'Items', 'Locations', 'Organizations', 'Teams', 'Races', 'Realities', 'Vehicles'}
local list_of_subpages = {}
local message = subject..' that have been referenced but have never appeared in any media.'
local output = ''
for i = 1, #subjects do
table.insert(list_of_subpages, h.LinkToCategory('Unseen '..subjects[i], subjects[i]))
end
output = message..p.lua_add_navigation(list_of_subpages)
return design.messagebox({output})..h.Category(subject)
end
--------------------------------------------------------------------------------
-- used in Template:TPB by Series Category
function p.tpb_by_series_category(frame)
local pagename = mw.title.getCurrentTitle().text
local series = ''
local series_page = ''
local link = ''
local output_categories = {}
local output = ''
series = string.match(pagename, '(.+) Trade Paperbacks')
if not h.isempty(series)
then
series_page = series..' Comic Books'
table.insert(output_categories, 'TPB by Series')
if h.pages_in_category(series_page, 'all') > 0
then table.insert(output_categories, series_page)
end
if h.exists(pagename)
then link = h.Link(pagename, series)
elseif h.exists(series_page)
then link = h.Link(series_page, series)
else link = series
end
output = design.span('List of trade paperbacks about '..link..'.').bold
output = design.messagebox({output})
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Cover Date Category
function p.cover_date_category(frame)
local function get_months(year)
local i
local category
local link
local output = {}
for i = 1, 12 do
category = year..', '..g_list_of_months[i]..' Cover Date'
link = string.sub(g_list_of_months[i], 1, 3)
table.insert(output, p.lua_add_navigation_link(category, link, 'pages'))
end
output = p.lua_add_navigation(output, ' ')
output = mw.html.create('div'):css('display', 'flex'):css('flex-wrap', 'wrap'):css('justify-content' , 'center'):wikitext(output)
return tostring(output)
end
local pagename = mw.title.getCurrentTitle().text
local year
local previous_year = ''
local next_year = ''
local month
local month_number = ''
local headers = {}
local message = ''
local dpl_string = ''
local gallery = {}
local image
local link
local output_categories = {}
local output = ''
year, month = string.match(pagename, '(%d%d%d%d), (.+) Cover Date')
if year ~= nil
then
for i = 1, 12 do
if g_list_of_months[i] == month
then month_number = ' '..h.AddZeros(i, 2)
end
end
table.insert(output_categories, {year..', '..month, 'Cover Date'})
table.insert(output_categories, {year..' Cover Date', month_number})
dpl_string = '{{#dpl:|category = '..pagename..'|notnamespace = Category|mode = userformat|ordermethod = title|allowcachedresults = true'
dpl_string = dpl_string..'|includepage = {Marvel Database:Comic Template}:Image1|secseparators = %TITLE%~,@@@}}'
dpl_string = frame:preprocess(dpl_string)
dpl_string = mw.text.split(dpl_string, '@@@')
for i = 1, #dpl_string-1 do
link = mw.text.split(dpl_string[i], '~', true)
image = link[2]
link = require('Module:StandardizedName').lua_get_title_volume_issue(link[1], 'Vol').link.all
table.insert(gallery, '\n'..image..'|'..link)
end
gallery = frame:preprocess('<gallery widths="200" position="center" captionalign="center" navigation="true">'..table.concat(gallery)..'</gallery>')
gallery = design.show_hide({header = 'Gallery of comic issues', body = gallery})
if h.pages_in_category((year-1)..' Cover Date', 'all') > 0
then table.insert(headers, h.LinkToCategory((year-1)..' Cover Date', (year-1) ) )
else table.insert(headers, (year-1) )
end
table.insert(headers, 'Comic issues with cover date of '..month..' of '..h.LinkToCategory(year..' Cover Date', year))
if h.pages_in_category((year+1)..' Cover Date', 'all') > 0
then table.insert(headers, h.LinkToCategory((year+1)..' Cover Date', (year+1) ) )
else table.insert(headers, (year+1) )
end
for i = 1, 3 do
headers[i] = tostring( mw.html.create('div'):css('font-weight', 'bold'):wikitext(headers[i]) )
end
headers = table.concat(headers)
previous_year = get_months(year-1)
next_year = get_months(year+1)
year = get_months(year)
message = mw.html.create('div'):css('display', 'grid'):css('grid-template-columns', '1fr 1fr 1fr'):wikitext(headers..previous_year..year..next_year)
message = tostring(message)
output = design.messagebox({message})..gallery
else
year = string.match(pagename, '(%d%d%d%d) Cover Date')
if year ~= nil
then
table.insert(output_categories, {year, 'Cover Date'})
header = design.span('Comic issues with '..year..' year in cover date.').bold
message = {}
for i = 1939, tonumber(mw.language.new('en'):formatDate('Y')) + 1 do
table.insert(message, h.LinkToCategory(i..' Cover Date', i) )
end
message = p.lua_add_navigation(message, ' ')
output = design.messagebox({ header..message})
end
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Month Category
function p.month_category(frame)
local pagename = mw.title.getCurrentTitle().text
local i
local year
local month
local month_number = ''
local navigation_months = {}
local output_categories = {}
local output = ''
year, month = string.match(pagename, '(%d%d%d%d), (.+)')
if year ~= nil
then
output = design.span('List of various events that happened in '..month..' of '..h.LinkToCategory(year, year)..'.').bold
for i = 1, 12 do
month = g_list_of_months[i]
table.insert(navigation_months, p.lua_add_navigation_link(year..', '..month, month, 'all') )
end
navigation_months = p.lua_add_navigation(navigation_months)
output = design.messagebox({ output..navigation_months })
for i = 1, 12 do
if g_list_of_months[i] == month
then month_number = ' '..h.AddZeros(i, 2)
end
end
table.insert(output_categories, {year, month_number})
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Year Category
function p.year_category(frame)
local i
local current_year = require("Module:Date").get_current_year()
local check_years = {1800,1801,1803,1804,1805,1806,1807,1808,1809,1811,1812,1813,1815,1816,1817,1818,1821,1822,1823,1825,1826,1827,1829,1830,1831,1833,1834,1836,1837,1838,1839,1840,1841,1843,1844,1845,1846,1848,1849,1852,1853,1854,1855,1858,1860,1861,1862,1863,1864,1865,1867,1868,1872,1873,1874,1876,1877,1879,1881,1882,1883,1886}
local include_years = {1660,1667,1731,1745,1771,1789}
local output = {}
for i = 1660, 1799 do
if h.in_list(include_years, i)
then table.insert(output, h.LinkToCategory(i, i))
else table.insert(output, p.nonexistent_page(i))
end
end
for i = 1800, 1886 do
if h.in_list(check_years, i)
then table.insert(output, p.lua_add_navigation_link(i, i, 'all'))
else table.insert(output, h.LinkToCategory(i, i))
end
end
for i = 1887, current_year do
table.insert(output, h.LinkToCategory(i, i))
end
current_year = current_year + 1
if h.pages_in_category(current_year, 'all') > 0
then table.insert(output, h.LinkToCategory(current_year, current_year))
end
output = mw.text.listToText(output, ' ', ' ')
output = design.messagebox({ Message=output, extrastyle="font-family: monospace;" })
return output..h.Category('Years')
end
--------------------------------------------------------------------------------
-- used in Template:Marvel Staff Dates of Birth or Death Category
function p.marvel_staff_dates_of_birth_or_death_category(frame)
local pagename = mw.title.getCurrentTitle().text
local i
local value
local year
local month
local month_number = ''
local navigation_months = {}
local navigation_birth_death = {}
local output_categories = {}
local output = ''
year, month = string.match(pagename, 'Born in (%d%d%d%d), (.+)')
if year ~= nil
then
month_number = require('Module:Date').get_month_number({month})
month_number = ' '..h.AddZeros(month_number, 2)
table.insert(output_categories, {'Born in '..year, month_number} )
if h.exists('Category:'..year..', '..month)
then
table.insert(output_categories, year..', '..month)
month = h.LinkToCategory(year..', '..month, month)
end
output = 'Members of Marvel staff who were born in '..month..' of '..h.LinkToCategory(year, year)..'.'
output = design.span(output).bold
for i = 1, 12 do
month = p.lua_add_navigation_link('Born in '..year..', '..g_list_of_months[i], g_list_of_months[i], 'pages')
table.insert(navigation_months, month)
end
navigation_months = p.lua_add_navigation(navigation_months)
output = design.messagebox({ output..navigation_months })
else
value, year = string.match(pagename, '(.+) in (%d%d%d%d)')
if year ~= nil and h.in_list({'Born', 'Died'}, value)
then
navigation_birth_death = p.lua_add_year_of_birth_death_navigation(year)
if value == 'Born'
then
table.insert(output_categories, {'Marvel Staff by Year of Birth', year})
output = 'Members of Marvel staff who were born in '..h.LinkToCategory(year, year)..'.'
else
table.insert(output_categories, {'Marvel Staff by Year of Death', year})
output = 'Members of Marvel staff who died in '..h.LinkToCategory(year, year)..'.'
end
table.insert(output_categories, year)
output = design.span(output).bold
output = design.messagebox({ output..navigation_birth_death })
end
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Nationality Category
function p.nationality_category(frame)
local function get_flag_image(nation, frame)
local output = ''
local dpl_string = '{{#dpl:|titlematch = Flag of '..nation..'%|namespace = File|format = ,%TITLE%,|count = 1|noresultsheader = no_results}}'
dpl_string = frame:preprocess(dpl_string)
if dpl_string ~= 'no_results'
then output = '[[File:'..dpl_string..'|130px]]'
end
return output
end
local citizenship = require("Module:Citizenship")
local pagename = mw.title.getCurrentTitle().text
local args = getArgs(frame)
local name = args[1]
local n = h.pages_in_category(pagename, 'pages')
local flag = ''
local nation = ''
local header = ''
local help = ''
local navigation = ''
local output_categories = {}
local output = ''
if not h.isempty(name)
then name = mw.text.trim(name)
else
name = pagename
name = string.gsub(name, ' Staff Members', '')
end
nation = citizenship.countries[name]
if nation == nil
then
if string.find(name, "ians")
then nation = mw.ustring.sub(name, 0, -5)
else nation = mw.ustring.sub(name, 0, -3)
end
end
if not h.isempty(nation)
then
if string.find(pagename, ' Staff Members') == nil
then
header = 'List of characters who are from '
help = "If you find character in the database that is not shown here, please edit their page and add "
table.insert(output_categories, 'Characters by Nationality')
if h.pages_in_category(nation, 'all') > 0
then table.insert(output_categories, nation)
end
table.insert(output_categories, args[2])
table.insert(output_categories, args[3])
else
header = 'List of staff members of Marvel who are from '
help = "If you find person in the database that is not shown here, please edit their page and add "
table.insert(output_categories, 'Marvel Staff Members by Nationality')
if h.pages_in_category(nation, 'all') > 0
then table.insert(output_categories, nation)
end
end
navigation = p.lua_add_nation_navigation(name)
flag = get_flag_image(nation, frame)
flag = tostring( mw.html.create('div'):wikitext(flag) )
if n >=500
then n = frame:expandTemplate{title = 'CategoryTOC'}
else n = ''
end
header = header..h.Link(nation, nation)..'.'
header = design.span(header).bold
help = help..'"'..nation..'"'..' into <code>Citizenship</code> field.'
help = p.add_help(help)
output = tostring( mw.html.create('div'):wikitext(header..help..navigation) )
output = mw.html.create('div'):css('display', 'grid'):css('grid-template-columns', '140px 1fr'):wikitext(flag..output)
output = tostring(output)
output = design.messagebox({output})..n
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Week Category
function p.week_of_release_category(frame)
local m_date = require('Module:Date')
local standard = require('Module:StandardizedName')
local function week_category(date_info)
local week_number = h.AddZeros(date_info.week_number, 2)
local category = 'Week '..week_number..', '..date_info.year
local value = h.AddZeros(date_info.day, 2)..' (W'..week_number..')'
if date_info.week_number == 1 and date_info.month == 'December'
then value = 'Dec '..value
end
return p.lua_add_navigation_link(category, value)
end
local function month_of_release(month_number, year)
local month_name = m_date.get_month_name({month_number})
local category = 'Comics Released in '..month_name..', '..year
local value = string.sub(month_name, 1, 3)..', '..year
local output = p.lua_add_navigation_link(category, value, 'all')
return tostring( mw.html.create('td'):wikitext(output) )
end
local function dpl_list(category, template)
local output = '{{#dpl:|category = '..category..'|mode = userformat|noresultsheader = no_results|allowcachedresults = true'
return output..'|includepage = {Marvel Database:'..template..'}:Image1|secseparators = %PAGE%~,@@@}}'
end
local function dpl_list2(category, offset)
return '{{#dpl:|category = '.. category ..'|namespace = |mode = userformat|listseparators = ,%PAGE%,@@@| offset = '..offset..'}}'
end
local function sort_by_issue(a, b)
return a.info.sortname.all < b.info.sortname.all
end
local release_week = getArgs(frame).release_week
local pagename = release_week or mw.title.getCurrentTitle().text
local week_number = ''
local week_year = ''
local year = ''
local month = ''
local day = ''
local last_week_in_year = 52
local i
local j
local category
local value
local date_from_week_number
local navigation_weeks = {}
local navigation_weeks_headers = {}
local navigation_weeks_temp1 = {}
local navigation_weeks_temp2 = {}
local date_info = {}
local tag_table = mw.html.create('table'):css('width', '100%'):css('font-family', 'monospace'):css('font-size', '80%'):css('text-align', 'center')
local tag_tr1 = mw.html.create('tr'):css('font-weight', 'bold')
local tag_tr2 = mw.html.create('tr'):css('vertical-align', 'top')
local dpl
local info
local list_of_issues = {}
local image
local gallery = ''
local output_categories = {}
local output = ''
if string.find(pagename, 'Week') ~= nil
then
week_number, week_year = string.match(pagename, 'Week (.+), (.+)')
date_from_week_number = m_date.lua_get_date_from_week_number(tonumber(week_number), week_year)
month, day, year = string.match(date_from_week_number, '(.+) (.+), (%d+)')
category = 'Comics Released in '..month..', '..year
table.insert(output_categories, category)
output = 'Comics issues released on '..h.LinkToCategory(category, date_from_week_number)..'.'
value = frame:preprocess(dpl_list(pagename, 'Comic Template')..dpl_list(pagename, 'Handbook Template'))
value = string.gsub(value, 'no_results', '')
if not h.isempty(value)
then
dpl = mw.text.split(value, '@@@')
for i = 1, #dpl-1 do
value = h.explode('~', dpl[i])
image = value[2]
if image ~= nil
then
info = standard.lua_get_title_volume_issue(value[1], 'Vol')
table.insert(list_of_issues, {info = info, image = image})
end
end
table.sort(list_of_issues, sort_by_issue)
local list_of_handbooks = frame:preprocess(dpl_list2('Handbooks', 0))
local list_of_infinity = frame:preprocess(dpl_list2('Infinity Comics', 0))
local list_of_reprints = frame:preprocess(dpl_list2('Active Reprinted Volumes', 0))
--[[
local list_of_tpbs = {}
for i = 0, 3000, 500 do
table.insert(list_of_reprints, dpl_list2('Reprint Series', i))
table.insert(list_of_tpbs, dpl_list2('Trade Paperbacks', i))
end
list_of_reprints = frame:preprocess(table.concat(list_of_reprints))
list_of_tpbs = frame:preprocess(table.concat(list_of_tpbs))
]]--
local all_lists = {list_of_handbooks, list_of_infinity, list_of_reprints} --, list_of_tpbs}
all_lists = string.gsub(table.concat(all_lists), 'no_results', '')
all_lists = mw.text.split(all_lists, '@@@', true)
local main_gallery = {}
local additional_gallery = {}
for i = 1, #list_of_issues do
if h.in_list(all_lists, list_of_issues[i].info.noissue)
then table.insert(additional_gallery, '\n'..list_of_issues[i].image..'|'..list_of_issues[i].info.link.all)
else table.insert(main_gallery, '\n'..list_of_issues[i].image..'|'..list_of_issues[i].info.link.all)
end
end
if #main_gallery > 0
then main_gallery = frame:preprocess('<gallery widths="200" position="center" captionalign="center" navigation="true">'..table.concat(main_gallery)..'</gallery>')
else main_gallery = ''
end
if #additional_gallery > 0
then
additional_gallery = frame:preprocess('<gallery widths="200" position="center" captionalign="center" navigation="true">'..table.concat(additional_gallery)..'</gallery>')
additional_gallery = design.add_section('Handbooks, Reprints and Infinity Comics', additional_gallery, 2)
else
additional_gallery = ''
end
gallery = main_gallery..additional_gallery
end
elseif string.find(pagename, 'Comics Released in') ~= nil
then
month, week_year = string.match(pagename, 'Comics Released in (.+), (.+)')
category = week_year..', '..month
table.insert(output_categories, category)
output = 'Comics issues released in '..h.LinkToCategory(category, month..', '..week_year)..'.'
end
if not h.isempty(release_week)
then
return gallery
else
-- previous/next years and links to month of release categories
table.insert( navigation_weeks_headers, tostring( mw.html.create('td'):css('font-size', '90%'):wikitext(week_year-1) ))
for i = 1, 12 do
table.insert( navigation_weeks_headers, month_of_release(i, week_year) )
end
table.insert( navigation_weeks_headers, tostring( mw.html.create('td'):css('font-size', '90%'):wikitext(week_year+1) ))
navigation_weeks_headers = table.concat(navigation_weeks_headers)
tag_tr1 = tostring( tag_tr1:wikitext(navigation_weeks_headers) )
-- adding links to months of the previous year
for i = 1, 12 do
month = m_date.get_month_name({i})
category = 'Comics Released in '..month..', '..(week_year-1)
value = string.sub(month, 1, 3)
table.insert(navigation_weeks_temp2, p.lua_add_navigation_link(category, value, 'subcats'))
end
value = mw.text.listToText(navigation_weeks_temp2, ' ', ' ')
value = tostring( mw.html.create('td'):css('width', '5%'):css('font-size', '90%'):wikitext(value) )
table.insert(navigation_weeks, value)
navigation_weeks_temp2 = {}
-- adding weeks of the current year
last_week_in_year = m_date.lua_get_last_week_of_year2(week_year)
for i = 1, last_week_in_year do
date_from_week_number = m_date.lua_get_date_from_week_number(i, week_year)
month, day, year = string.match(date_from_week_number, '(.+) (.+), (%d+)')
date_info = {week_number = i, year = tonumber(week_year), month = month, day = day}
table.insert(navigation_weeks_temp1, date_info)
end
for i = 1, #navigation_weeks_temp1 do
date_info = navigation_weeks_temp1[i]
table.insert(navigation_weeks_temp2, week_category(date_info))
if i == #navigation_weeks_temp1
or (
date_info.month ~= navigation_weeks_temp1[i+1].month
and not (date_info.week_number == 1 and date_info.month == 'December')
)
then
value = mw.text.listToText(navigation_weeks_temp2, '<br>', '<br>')
value = tostring( mw.html.create('td'):wikitext(value) )
table.insert(navigation_weeks, value)
navigation_weeks_temp2 = {}
end
end
-- adding links to months of the next year
navigation_weeks_temp2 = {}
for i = 1, 12 do
month = m_date.get_month_name({i})
category = 'Comics Released in '..month..', '..(week_year+1)
value = string.sub(month, 1, 3)
table.insert(navigation_weeks_temp2, p.lua_add_navigation_link(category, value, 'subcats'))
end
value = mw.text.listToText(navigation_weeks_temp2, ' ', ' ')
value = tostring( mw.html.create('td'):css('width', '5%'):css('font-size', '90%'):wikitext(value) )
table.insert(navigation_weeks, value)
tag_tr2 = tostring( tag_tr2:wikitext( table.concat(navigation_weeks) ) )
tag_table = tag_table:wikitext(tag_tr1..tag_tr2)
output = design.span(output).bold..'\n----'..tostring(tag_table)
return design.messagebox({output})..gallery..h.add_categories(output_categories)
end
end
--------------------------------------------------------------------------------
-- used in Template:Power Category
function p.power_category(frame)
local list_of_powers = mw.loadData('Module:List of Powers')
local pagename = mw.title.getCurrentTitle().text
local power_info = {}
local related = {}
local related2 = {}
local value = ''
local help = ''
local i
local output_categories = {}
local output = string.lower(pagename)
power_info = list_of_powers[pagename]
if power_info ~= nil
then
if power_info.related ~= nil
then
for i = 1, 20 do
value = power_info.related[i]
if not h.isempty(value)
then table.insert(related, h.LinkToCategory(value, value) )
end
end
end
if power_info.related2 ~= nil
then
for i = 1, 20 do
value = power_info.related2[i]
if not h.isempty(value)
then table.insert(related2, h.LinkToCategory(value, value) )
end
end
end
for i = 1, 20 do
value = power_info.categories[i]
if not h.isempty(value)
then table.insert(output_categories, value)
end
end
output = design.span(power_info.description).bold
if not h.isempty(power_info.additional_description)
then output = output .. '<br>' .. power_info.additional_description
end
if not h.isempty(power_info.help)
then output = output .. p.add_help(power_info.help)
end
if #related + #related2 > 0
then output = output .. '\n----'
end
end
related = p.lua_add_navigation(related, _, false)
if #related2 > 0
then
related2 = p.lua_add_navigation(related2)
related2 = '<br>'..tostring( mw.html.create('span')
:addClass('messagebox__help')
:css('width', '100%')
:css('font-size', '150%')
:css('text-align', 'center')
:css('letter-spacing', '20px')
:wikitext('···') ) .. related2
related = tostring( mw.html.create('div'):css('line-height', '0.9'):wikitext(related..related2) )
end
return design.messagebox({output .. related})..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Physical Features Category
function p.physical_features_category(frame)
local args = getArgs(frame)
local matter_type = args['type'] or ''
local pagename = mw.title.getCurrentTitle().text
local navigation = {}
local body = string.match(pagename, '(.+) Body')
local form = string.match(pagename, '(.+) Form')
local value_lower = ''
local output_categories = {}
local output = ''
table.insert(output_categories, 'Characters by Physical Features')
if body ~= nil
then
if matter_type == 'Inorganic'
then
if body == 'Inorganic'
then
output = 'Characters born with a body made of inorganic matter.'
else
table.insert(output_categories, 'Inorganic Body')
output = 'Characters born with a body made of '..string.lower(body)..'.'
end
else
if body == 'Non-Humanoid'
then output = 'Characters born with a non-humanoid body or features.'
else
table.insert(output_categories, 'Non-Humanoid Body')
output = 'Characters born with '..string.lower(body)..' body or features.'
end
end
table.insert(navigation, p.lua_add_navigation_link(body..' Body', body..' Body', 'all') )
table.insert(navigation, p.lua_add_navigation_link(body..' Form', body..' Form', 'all') )
table.insert(navigation, p.lua_add_navigation_link(body..' Mimicry', body..' Mimicry', 'all') )
elseif form ~= nil
then
if matter_type == 'Inorganic'
then
if form == 'Inorganic'
then
output = 'Characters whose body was originally made of organic matter'
value_lower = 'inorganic matter'
else
table.insert(output_categories, 'Inorganic Form')
output = 'Characters whose body was originally made of different kind of matter (organic or inorganic)'
value_lower = string.lower(form)
end
output = output..', but later due to some reason it was turned into '..value_lower..' without ability to transform back.'
else
if form == 'Non-Humanoid'
then output = 'Characters who originally had not had non-humanoid features'
else
table.insert(output_categories, 'Non-Humanoid Form')
output = 'Characters who originally had not had '..string.lower(form)..' features'
end
output = output..', but later due to some reason got them without ability to transform back.'
end
table.insert(navigation, p.lua_add_navigation_link(form..' Body', form..' Body', 'all') )
table.insert(navigation, p.lua_add_navigation_link(form..' Form', form..' Form', 'all') )
table.insert(navigation, p.lua_add_navigation_link(form..' Mimicry', form..' Mimicry', 'all') )
end
navigation = p.lua_add_navigation(navigation)
output = design.span(output).bold
return design.messagebox({output..navigation})..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Eye Category
function p.eye_category(frame)
local function navigation_message(value)
local list = {}
local i
local category
local eye_color = ''
local output = {}
if string.find(value, 'No Visible') ~= nil
then list = {'No Visible Irises or Pupils', 'Formerly No Visible Irises or Pupils'}
elseif string.find(value, 'No Eyes') ~= nil
then list = {'No Eyes', 'Formerly No Eyes', 'Races with No Eyes'}
else
eye_color = string.match(string.gsub(value, 'Formerly ', ''), '(.+) Eye.+')
list = {eye_color..' Eyes', 'Formerly '..eye_color..' Eyes', eye_color..' Eyeballs', 'Formerly '..eye_color..' Eyeballs', 'Races with '..eye_color..' Eyes'}
end
for i = 1, #list do
category = list[i]
if string.find(category, 'Races') ~= nil
then value = category
elseif category == 'No Eyes'
then value = 'No Eyes At All'
elseif category == 'Formerly No Eyes'
then value = 'Formerly No Eyes At All'
else value = string.gsub(category, ' Eyes', '')
end
table.insert(output, p.lua_add_navigation_link(category, value) )
end
return output
end
local pagename = mw.title.getCurrentTitle().text
local list = {}
local navigation = ''
local help = ''
local value = ''
local category = pagename
local output_categories = {}
local output = ''
if string.find(pagename, 'Formerly ') ~= nil
then
category = string.match(pagename, 'Formerly (.+)')
table.insert(output_categories, category)
if category == 'No Visible Irises or Pupils'
then output = 'Characters whose eyes had formerly had no visible irises (pupils), but now gained color due to some reason.'
elseif category == 'No Eyes'
then output = 'Characters who formerly had no eyes at all, until they gained them for some reason.'
elseif string.find(category, 'Eyeballs') ~= nil
then
value = string.lower( string.match(category, '(.+) Eyeballs') )
if value == 'Variable'
then output = 'Characters whose eyes had formerly had variable color of eyeballs (sclera); normally due to the power to change their physical appearance.'
else output = 'Characters whose eyes had formerly had '..string.lower(value)..' color of eyeballs (sclera), but later the color changed due to some reason.'
end
elseif string.find(category, 'Eyes') ~= nil
then
value = string.lower( string.match(category, '(.+) Eyes') )
if value == 'Variable'
then output = 'Characters whose eyes had formerly had variable color of irises (pupils); normally due to the power to change their physical appearance.'
else output = 'Characters whose eyes had formerly had '..string.lower(value)..' color of irises (pupils), but later the color changed due to some reason.'
end
end
navigation = p.lua_add_navigation( navigation_message(pagename) )
elseif string.find(pagename, 'Races ') ~= nil
then
category = string.match(pagename, 'Races with (.+)')
if category == 'No Eyes'
then
table.insert(output_categories, {'Races by Eyes', category})
output = "Races with no eyes at all."
else
table.insert(output_categories, {'Races by Eye Color', category})
output = 'Races with '..string.lower(category)..'.'
end
navigation = p.lua_add_navigation( navigation_message(category) )
elseif category == 'No Visible Irises or Pupils'
then
output = 'Characters whose eyes do not have any visible eye irises (pupils).'
help = 'Such eyes often have a different from norm '..h.LinkToCategory('Characters by Eyeball Color', 'coloration of eyeballs (sclera)')
help = help..'.<br>(these characters should not be confused with '..h.LinkToCategory('No Eyes', 'characters that do not have any eyes at all')..')'
table.insert(output_categories, 'Characters by Eyes')
navigation = p.lua_add_navigation( navigation_message(category) )
elseif category == 'No Eyes'
then
output = "Characters who don't have any eyes at all"
help = '(these characters should not be confused with characters who have eyes, but they '
help = help..h.LinkToCategory('No Visible Irises or Pupils', 'do not have any visible eye irises (pupils)')..')'
table.insert(output_categories, 'Characters by Eyes')
navigation = p.lua_add_navigation( navigation_message(category) )
elseif string.find(pagename, 'Eyeballs') ~= nil
then
value = string.lower( string.match(pagename, '(.+) Eyeballs') )
if value == 'white'
then
output = 'Characters with white color of eyeballs (sclera) and '..h.LinkToCategory('No Visible Irises or Pupils', 'no Visible irises (pupils)')
help = ''
elseif value == 'variable'
then output = 'Characters whose eyes have variable color of eyeballs (sclera); normally due to the power to change their physical appearance.'
else
output = 'Characters with '..value..' color of eyeballs (sclera).'
help = 'Often such characters '..h.LinkToCategory('No Visible Irises or Pupils', 'do not have any visible eye irises (pupils)')..'.<br>'
end
help = help..'(These characters should not be confused with characters who have '
category = string.gsub(pagename, ' Eyeballs', ' Eyes')
if h.pages_in_category(category) > 0
then help = help..h.LinkToCategory(category, value..' color of eye irises (pupils)')..')'
else help = help..value..' color of eye irises (pupils))'
end
table.insert(output_categories, 'Characters by Eyeball Color')
navigation = p.lua_add_navigation( navigation_message(pagename) )
else
value = string.lower( string.match(pagename, '(.+) Eyes') )
if value == 'variable'
then
output = 'Characters whose eyes have variable color of irises (pupils); normally due to the power to change their physical appearance.'
else
output = 'Characters with '..value..' color of eye irises (pupils).'
help = '(These characters should not be confused with characters whose eyes actually have '
category = string.gsub(pagename, ' Eyes', ' Eyeballs')
if h.pages_in_category(category) > 0
then help = help..h.LinkToCategory(category, value..' color of eyeballs (sclera)')
else help = help..value..' color of eyeballs (sclera)'
end
help = help..' with '..h.LinkToCategory('No Visible Irises or Pupils', 'no Visible irises')..')'
end
table.insert(output_categories, 'Characters by Eye Color')
navigation = p.lua_add_navigation( navigation_message(pagename) )
end
help = p.add_help(help)
output = design.span(output).bold..help..navigation
return design.messagebox({output})..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Hair Category
function p.hair_category(frame)
local function navigation_message(hair_color)
local list = {hair_color, 'Dyed '..hair_color, 'Formerly '..hair_color, 'Races with '..hair_color}
local list2 = {'Shaved Hair', 'Balding', 'Bald', 'Formerly Bald', 'No Hair', 'Formerly No Hair', 'Races with No Hair'}
local list3 = {'Variable Hair', 'Formerly Variable Hair', 'Races with Variable Hair'}
local i
local category
local value
local output = {}
if hair_color ~= 'Grey-haired'
then
if h.in_list(list2, hair_color)
then list = list2
elseif string.find(hair_color, 'Variable') ~= nil
then list = list3
end
for i = 1, #list do
category = list[i]
if string.find(category, 'Races') ~= nil
then value = category
elseif category == 'No Hair' or category == 'Formerly No Hair'
then value = category..' At All'
else value = string.gsub(category, ' Hair', '')
end
table.insert(output, p.lua_add_navigation_link(category, value) )
end
end
return output
end
local pagename = mw.title.getCurrentTitle().text
local list = {}
local help = ''
local navigation = ''
local value = ''
local category = pagename
local output_categories = {}
local output = ''
if string.find(pagename, 'Formerly ') ~= nil
then
category = string.match(pagename, 'Formerly (.+)')
table.insert(output_categories, category)
navigation = p.lua_add_navigation( navigation_message(category) )
if category == 'No Hair'
then
output = 'Characters who formerly had no hair at all, until they gained them for some reason.'
elseif category == 'Bald'
then output = 'Characters who formerly went bald, until they regained their hair for some reason.'
else
value = string.lower( string.match(category, '(.+) Hair') )
if value == 'variable'
then output = 'Characters who formerly had variable color of hair; normally due to the power to change their physical appearance.'
else output = 'Characters who formerly had '..value..' color of hair, but later the color changed, they went bald, greyed or dyed hair to some other color.'
end
end
elseif string.find(pagename, 'Dyed ') ~= nil
then
category = string.match(pagename, 'Dyed (.+)')
table.insert(output_categories, category)
table.insert(output_categories, {'Dyed Hair', category})
navigation = p.lua_add_navigation( navigation_message(category) )
output = 'Characters who dyed their hair to '..string.lower( string.gsub(category, ' Hair', '') )..' color.'
elseif string.find(pagename, 'Races ') ~= nil
then
category = string.match(pagename, 'Races with (.+)')
navigation = p.lua_add_navigation( navigation_message(category) )
if category == 'No Hair'
then
table.insert(output_categories, {'Races by Hair', category})
output = "Races with no hair at all on their head; for example, they can have feathers or fur instead, or be inorganic beings, etc."
else
value = string.lower( string.match(category, '(.+) Hair') )
if value == 'Variable'
then output = 'Races whose individual members normally have variable color of hair; normally due to the power to change their physical appearance.'
else output = 'Races whose individual members normally have '..string.lower(category)..' color of hair.'
end
table.insert(output_categories, {'Races by Hair Color', category})
end
elseif category == 'Grey-haired'
then
navigation = p.lua_add_navigation( navigation_message(category) )
output = 'Characters whose hair turned grey (lost their pigmentation and melanin) due to age or some other reason.'
help = 'Such hairs look grey, white or silver not because they trully have grey or white pigment, but due to how the light is reflected in them.<br>'
help = help..'See categories '..h.LinkToCategory('Grey Hair', 'Grey Hair')..', '..h.LinkToCategory('White Hair', 'White Hair')..' and '..h.LinkToCategory('Silver Hair', 'Silver Hair')
help = help..' for characters whose hair have such color naturally or were dyed.'
table.insert(output_categories, 'Characters by Hair')
elseif category == 'Bald'
then
navigation = p.lua_add_navigation( navigation_message(category) )
output = 'Characters who lost their hair due to some natural reasons.'
table.insert(output_categories, 'Characters by Hair')
elseif category == 'Balding'
then
navigation = p.lua_add_navigation( navigation_message(category) )
output = 'Characters who partially lost their hair due to some natural reasons.'
table.insert(output_categories, 'Characters by Hair')
elseif category == 'Shaved Hair'
then
navigation = p.lua_add_navigation( navigation_message(category) )
output = 'Characters who shaved their hair.'
table.insert(output_categories, 'Characters by Hair')
elseif category == 'No Hair'
then
navigation = p.lua_add_navigation( navigation_message(category) )
output = "Characters who don't have any hair at all on their head. Such characters, for example, can have feathers or fur instead, or be inorganic being, etc."
table.insert(output_categories, 'Characters by Hair')
else
navigation = p.lua_add_navigation( navigation_message(category) )
value = string.lower( string.match(pagename, '(.+) Hair') )
if value == 'variable'
then output = 'Characters who have variable color of hair; normally due to the power to change their physical appearance.'
else output = 'Characters who have '..value..' color of hair.'
end
if h.in_list({'Grey Hair', 'Silver Hair', 'White Hair'}, pagename)
then
help = '(Characters whose hair turned '..value..' due to natural reason should be placed into '..h.LinkToCategory('Grey-haired', 'Category:Grey-haired')
help = help..' instead. If you found such a character in this category, please make the appropriate changes to its page and place it into '
help = help..h.LinkToCategory('Grey-haired', 'correct category')..'.)'
end
table.insert(output_categories, 'Characters by Hair Color')
end
help = p.add_help(help)
output = design.span(output).bold..help..navigation
return design.messagebox({output})..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Identity Category
function p.categories_by_identity(frame)
local page_types = {'Characters', 'Organizations', 'Races', 'Teams'}
local identity_types = {'No Dual', 'Public', 'Known to Authorities', 'Secret'}
local pagename = mw.title.getCurrentTitle().text
local identity
local page_type
local i
local category
local list_of_subpages = {}
local navigation_by_type = {}
local navigation_by_subject = {}
local help = ''
local output_categories = {}
local output = ''
if string.find(pagename, ' by ', 1, true) == nil
then
identity, page_type = string.match(pagename, '(.+ Identity)(.*)')
if h.isempty(page_type)
then
for i = 1, #identity_types do
table.insert(navigation_by_type, p.lua_add_navigation_link(identity_types[i]..' Identity', identity_types[i], 'all') )
end
for i = 1, #page_types do
table.insert(navigation_by_subject, p.lua_add_navigation_link(page_types[i]..' by Identity', page_types[i], 'all') )
end
output = 'List of subjects, '
else
page_type = h.trim(page_type)
for i = 1, #identity_types do
table.insert(navigation_by_type, p.lua_add_navigation_link(identity_types[i]..' Identity '..page_type, identity_types[i], 'all') )
end
for i = 1, #page_types do
table.insert(navigation_by_subject, p.lua_add_navigation_link(identity..' '..page_types[i], page_types[i], 'all') )
end
output = 'List of '..string.lower(page_type)..', '
end
navigation_by_type = p.lua_add_navigation(navigation_by_type)
navigation_by_subject = p.lua_add_navigation(navigation_by_subject)
if identity == 'No Dual Identity'
then
output = output..' who do not currently have any other identity, alter ego, or alias.'
help = '(Subjects with an alias whose identities are known to the public belong in '
if h.isempty(page_type)
then help = help..h.LinkToCategory('Public Identity', 'the category for subjects with a public identity')
else help = help..h.LinkToCategory('Public Identity '..page_type, 'the category for '..string.lower(page_type)..' with a public identity')
end
help = help..'. If there is a subject in that category who actually has no dual identity, please make the appropriate changes.)'
elseif identity == 'Public Identity'
then
output = output..' whose true identity is known to the general populace.'
help = '(Some of the subjects listed with a public identity actually have no other identity and should be placed into '
if h.isempty(page_type)
then help = help..h.LinkToCategory('No Dual Identity', 'the respective category')
else help = help..h.LinkToCategory('No Dual Identity '..page_type, 'the respective category')
end
help = help..' instead. If this appears to be the case, please make the appropriate changes.)'
elseif identity == 'Secret Identity'
then
output = output..' whose true identity is not known to the general populace and authorities.'
help = '(Secret identity is often used to avoid any legal ramifications (e.g. lawsuits), pressure or public scrutiny.)'
elseif identity == 'Known to Authorities Identity'
then
output = output..' whose identities are secret to the general populace, but known to some authorities (police forces, governments, [[S.H.I.E.L.D.]], etc).'
end
help = p.add_help(help)
if h.isempty(page_type)
then
table.insert(output_categories, 'Identity by Type')
else
table.insert(output_categories, {page_type..' by Identity', identity})
table.insert(output_categories, {identity, page_type})
if identity == 'Known to Authorities Identity'
then table.insert(output_categories, {'Secret Identity '..page_type, identity})
end
end
output = design.span(output).bold..help..navigation_by_type..navigation_by_subject
else
page_type = string.match(pagename, '(.+) by Identity')
for i = 1, #page_types do
table.insert(navigation_by_subject, p.lua_add_navigation_link(page_types[i]..' by Identity', page_types[i], 'all') )
end
output = p.lua_add_navigation(navigation_by_subject)
table.insert(output_categories, 'Identity by Subject')
table.insert(output_categories, {page_type, 'Identity'})
end
return design.messagebox({output})..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
function p.marvel_staff_categories(frame)
local args = getArgs(frame)
local basepagename = mw.title.getCurrentTitle().baseText
local subpagename = mw.title.getCurrentTitle().subpageText
local list1 = {'Editor', 'Editor-in-Chief', 'Cover Artist', 'Writer', 'Penciler', 'Inker', 'Colorist', 'Letterer', 'Director', 'Producer'}
local list2 = {'Creator', 'Cover Artist Images', 'Penciler Images', 'Inker Images', 'Colorist Images', 'Letterer Images'}
local list3 = {
{'Editor-in-Chief', 'List of all known comic(s) that were produced while ', ' was Editor-in-Chief.', 'Marvel Staff/Editors-in-Chief'},
{'Cover Artist', 'List of all known comic(s) where ', ' created the cover.', 'Marvel Staff/Cover Artists'},
{'Editor', 'List of all known work(s) that ', ' edited.', 'Marvel Staff/Editors'},
{'Writer', 'List of all known work(s) that ', ' wrote.', 'Marvel Staff/Writers'},
{'Penciler', 'List of all known comic(s) that ', ' penciled.', 'Marvel Staff/Pencilers'},
{'Inker', 'List of all known comic(s) that ', ' inked.', 'Marvel Staff/Inkers'},
{'Colorist', 'List of all known comic(s) that ', ' colored.', 'Marvel Staff/Colorists'},
{'Letterer', 'List of all known comic(s) that ', ' lettered.', 'Marvel Staff/Letterers'},
{'Director', 'List of all known work(s) directed by ', '.', 'Marvel Staff/Directors'},
{'Producer', 'List of all known work(s) produced by ', '.', 'Marvel Staff/Producers'},
{'Creator', 'List of all known subject(s) created by ', '.', 'Subjects by Creator'},
{'Cover Artist Images', 'List of all known covers drawn by ', '.', 'Images by Cover Artist'},
{'Penciler Images', 'List of all images on the database penciled by ', '.', 'Images by Penciler'},
{'Inker Images', 'List of all images on the database inked by ', '.', 'Images by Inker'},
{'Colorist Images', 'List of all images on the database colored by ', '.', 'Images by Colorist'},
{'Letterer Images', 'List of all images on the database lettered by ', '.', 'Images by Letterer'},
}
local i
local category
local message = ''
local subcategories1 = {}
local subcategories2 = {}
local help = ''
local output_categories = {}
local output = ''
for i = 1, #list1 do
table.insert(subcategories1, p.lua_add_navigation_link(basepagename..'/'..list1[i], list1[i]) )
end
subcategories1 = p.lua_add_navigation(subcategories1)
for i = 1, #list2 do
category = basepagename..'/'..list2[i]
if h.pages_in_category(category, 'files')>0 or (list2[i] == 'Creator' and h.pages_in_category(category, 'pages')>0)
then table.insert(subcategories2, h.LinkToCategory(category, list2[i]))
else table.insert(subcategories2, p.nonexistent_page(list2[i]))
end
end
subcategories2 = p.lua_add_navigation(subcategories2)
if not h.exists(basepagename)
then table.insert(output_categories, 'Marvel Staff Categories with Articles Needed')
end
if subpagename ~= basepagename
then
for i = 1, #list3 do
if subpagename == list3[i][1]
then
message = list3[i][2]..h.Link(basepagename)..list3[i][3]
table.insert(output_categories, list3[i][4])
if h.in_list(list1, subpagename)
then help = '(If you find an article that is not shown here, please add "'..basepagename..'" into "'..string.gsub(subpagename, ' ', '')..'" field of said article.)'
elseif subpagename == 'Creator'
then help = '(If you find an article that is not shown here, please add "'..basepagename..'" into "Creators" field of said article.)'
else
help = '(If you find an image in the database that is not shown here, please add "'..basepagename
help = help..'" into "'..string.gsub(string.gsub(subpagename, ' ', ''), 'Images', '')..'" field of said image.)'
end
break
end
end
if message ~= ''
then
message = design.span(message).bold
help = p.add_help(help)
output = design.messagebox({message..help..subcategories1..subcategories2})
end
end
return output..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- used in Template:Weight Category
function p.weight_category(frame)
local units = require('Module:Units')
local pagename = mw.title.getCurrentTitle().text
local function lbs_to_kg(weightLbs)
return h.round(tonumber(weightLbs) * units['lbs'].kg, 2)
end
local i
local value1
local value2
local value3
local sortname
local category
local help = {}
local output_categories = {'Weight'}
local output = 'List of characters with '
value1, value2 = string.match(pagename, 'Weight (%d+)%-(%d+) lbs')
if value1 ~= nil and value2 ~= nil
then
sortname = lbs_to_kg(value1) * 1000
if value2 == '9'
then output = output..'weight below 10 lbs ('..lbs_to_kg(10)..' kg)'
else output = output..'weight between '..value1..' lbs ('..lbs_to_kg(value1)..' kg) and '..value2..' lbs ('..lbs_to_kg(value2)..' kg)'
end
else
output = output..string.lower(pagename)
sortname = lbs_to_kg(1000) * 1000
end
output = design.span(output..'.').bold
sortname = ' '..string.rep('0', 10-#tostring(sortname))..sortname
value1 = lbs_to_kg(10)
category = 'Weight 0-9 lbs ('..value1..' kg)'
text = '< 10 lbs ('..value1..' kg)'
table.insert(help, h.LinkToCategory(category, text))
value1 = lbs_to_kg(10)
value2 = lbs_to_kg(20)
category = 'Weight 10-19 lbs ('..value1..'-'..value2..' kg)'
text = '10-19 lbs ('..value1..'-'..value2..' kg)'
table.insert(help, h.LinkToCategory(category, text))
i = 20
while i <= 280 do
value1 = lbs_to_kg(i)
value2 = lbs_to_kg(i+20)
text = i..'-'..(i+19)..' lbs ('..value1..'-'..value2..' kg)'
category = 'Weight '..text
table.insert(help, h.LinkToCategory(category, text))
i = i + 20
end
i = 300
while i <= 900 do
value1 = lbs_to_kg(i)
value2 = lbs_to_kg(i+100)
text = i..'-'..(i+99)..' lbs ('..value1..'-'..value2..' kg)'
category = 'Weight '..text
table.insert(help, h.LinkToCategory(category, text))
i = i + 100
end
value1 = lbs_to_kg(1000)
category = 'Weight above 1000 lbs ('..value1..' kg)'
text = '> 1000 lbs ('..value1..' kg)'
table.insert(help, h.LinkToCategory(category, text))
table.insert(help, h.LinkToCategory('Variable Weight', 'Variable'))
help = p.lua_add_navigation(help)
output = design.messagebox({output..help})
return output..h.add_categories(output_categories, sortname)
end
--------------------------------------------------------------------------------
-- used in Template:Height Category
function p.height_category(frame)
local units = require('Module:Units')
local pagename = mw.title.getCurrentTitle().text
local function ft_to_m(heightFt)
return tonumber( string.format("%.2f", tonumber(heightFt) * units['ft'].m) )
end
local i
local j
local value1
local value2
local value3
local sortname
local category
local help = {}
local output_categories = {'Height'}
local output = 'List of characters with '
value1, value2 = string.match(pagename, 'Height (%d)%-(%d) ft')
if value1 ~= nil and value2 ~= nil
then
sortname = ft_to_m(value1) * 1000
if value2 == '1'
then output = output..'height below 1 ft. ('..ft_to_m(1)..' m)'
else output = output..'height between '..value1..' ft. ('..ft_to_m(value1)..' m) and '..value2..' ft. ('..ft_to_m(value2)..' m)'
end
else
output = output..string.lower(pagename)
if string.find(pagename, ' above 8 ') ~= nil
then sortname = ft_to_m(8) * 1000
elseif string.find (pagename, 'Variable') ~= nil
then sortname = '9999'
else
value1, value2 = string.match(pagename, '(%d+) ft%. (%d+) in')
sortname = ft_to_m(tonumber(value1) + tonumber(value2)/12) * 1000
end
end
output = design.span(output..'.').bold
sortname = ' '..string.rep('0', 4-#tostring(sortname))..sortname
value1 = ft_to_m(1)
category = 'Height 0-1 ft. ('..value1..' m)'
text = '< 1 ft. ('..value1..' m)'
table.insert(help, h.LinkToCategory(category, text))
for i = 1, 4 do
value1 = ft_to_m(i)
value2 = ft_to_m(i+1)
text = i..'-'..(i+1)..' ft. ('..value1..'-'..value2..' m)'
category = 'Height '..text
table.insert(help, h.LinkToCategory(category, text))
end
for j = 5, 6 do
for i = 0, 11 do
value1 = ft_to_m(j + i/12)
text = j..' ft. '..i..' in. ('..value1..' m)'
category = 'Height '..text
table.insert(help, h.LinkToCategory(category, text))
end
end
i = 7
value1 = ft_to_m(i)
value2 = ft_to_m(i+1)
text = i..'-'..(i+1)..' ft. ('..value1..'-'..value2..' m)'
category = 'Height '..text
table.insert(help, h.LinkToCategory(category, text))
value1 = ft_to_m(8)
category = 'Height above 8 ft. ('..value1..' m)'
text = '> 8 ft. ('..value1..' m)'
table.insert(help, h.LinkToCategory(category, text))
table.insert(help, h.LinkToCategory('Variable Height', 'Variable'))
help = p.lua_add_navigation(help)
output = design.messagebox({output..help})
return output..h.add_categories(output_categories, sortname)
end
--------------------------------------------------------------------------------
-- currently not working
function p.chronological_sort(frame)
local pagename = "Xavier's School for Gifted Youngsters/Appearances" --mw.title.getCurrentTitle().text
local CS = require('Module:Chronological Sort')
return design.messagebox({CS.main(frame, pagename)})
end
--------------------------------------------------------------------------------
-- used in Template:Power Grid Category
function p.power_grid_category(frame)
local description = mw.loadData('Module:Power Grid/Description')
local args = getArgs (frame)
local subpageText = mw.title.getCurrentTitle().subpageText
local baseText = mw.title.getCurrentTitle().baseText
local rootText = mw.title.getCurrentTitle().rootText
local i
local j
local navigation_types = {}
local navigation_values = {}
local value
local category
local output_category = ''
local output = ''
for i = 1,6 do
category = 'Power Grid/'..description[i].label
table.insert(navigation_types, h.LinkToCategory(category, description[i].label))
end
navigation_types = 'This category is a part of the power ratings presented in official Marvel handbooks.'..p.lua_add_navigation(navigation_types)
if baseText == rootText
then
output_category = h.Category(baseText, subpageText)
for i = 1,6 do
if description[i].label == subpageText
then output = design.span(string.upper(description[i].label)).bold..' — '..description[i].tooltip
end
end
output = navigation_types..'\n----'..output
else
for i = 1,6 do
if description[i].label == string.match(baseText, '/(.+)')
then
output = design.span(description[i].label).bold..' — '..description[i].tooltip
for j = 1,7 do
category = description[i].values[j].category
table.insert(navigation_values, h.LinkToCategory(category, j))
if category == baseText..'/'..subpageText
then
value = design.span(string.upper(description[i].values[j].tooltip)).bold
output_category = h.Category(baseText, j)
end
end
navigation_values = mw.text.listToText(navigation_values, ' · ', ' · ')
output = navigation_types..'\n----'..output..'<br>'..navigation_values..'<br>'..value
end
end
end
output = design.messagebox({output})
return output..output_category
end
--------------------------------------------------------------------------------
-- used in Template:Races by Location
function p.races_by_location(frame)
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().baseText
local page_content = h.get_content(pagename)
local galaxy = h.get_field_value(page_content, 'Galaxy')
local dimension = h.get_field_value(page_content, 'Dimension')
local star_system = h.get_field_value(page_content, 'StarSystem')
local planet = h.get_field_value(page_content, 'Planet')
local page_type = args[1]
local place = args[2]
local output_categories = {}
local output = ''
if (not h.isempty(galaxy) and pagename == galaxy) or (not h.isempty(page_type) and string.lower(page_type) == 'galaxy')
then
output = 'galaxy'
table.insert(output_categories, 'Races by Galaxy')
elseif (not h.isempty(dimension) and pagename == dimension) or (not h.isempty(page_type) and string.lower(page_type) == 'dimension')
then
output = 'dimension'
table.insert(output_categories, 'Races by Dimension')
elseif (not h.isempty(star_system) and pagename == star_system) or (not h.isempty(page_type) and string.lower(page_type) == 'star system')
then
output = 'star system'
table.insert(output_categories, 'Races by Star System')
if not h.isempty(galaxy)
then table.insert(output_categories, galaxy..'/Races')
elseif not h.isempty(dimension)
then table.insert(output_categories, dimension..'/Races')
elseif not h.isempty(place)
then table.insert(output_categories, place..'/Races')
end
elseif (not h.isempty(planet) and pagename == planet) or (not h.isempty(page_type) and string.lower(page_type) == 'planet')
then
output = 'planet'
table.insert(output_categories, 'Races by Planet')
if not h.isempty(star_system)
then table.insert(output_categories, star_system..'/Races')
elseif not h.isempty(galaxy)
then table.insert(output_categories, galaxy..'/Races')
elseif not h.isempty(dimension)
then table.insert(output_categories, dimension..'/Races')
elseif not h.isempty(place)
then table.insert(output_categories, place..'/Races')
end
else table.insert(output_categories, 'Races by Place of Origin')
end
table.insert(output_categories, pagename)
output = 'Races which originated from '..h.Link(pagename, pagename)..' '..output..'.'
output = design.span(output).bold
output = design.messagebox({output})
return output..h.add_categories(output_categories, pagename)
end
--------------------------------------------------------------------------------
-- used in:
-- Template:Appearances Category
-- Template:Mentions Category
-- Template:Minor Appearances Category
-- Template:Images Category
-- Template:Quotes
-- Template:Items by User
function p.standard_subcategories_and_subpages(frame)
local m_pagetype = require('Module:PageType')
local basepagename = mw.title.getCurrentTitle().baseText
local subpagename = mw.title.getCurrentTitle().subpageText
local pagetype = getArgs(frame)[1]
local s
if string.find(basepagename, 'Killed by ') ~= nil
then s = string.match(basepagename, 'Killed by (.+)')
else s = basepagename
end
if h.isempty(pagetype)
then
if string.find(basepagename, ' Season ') ~= nil and string.find(basepagename, ' Vol ') == nil and m_pagetype.get_page_type(s) ~= 'Episode'
then pagetype = 'Season'
else
pagetype = m_pagetype.get_page_type(s)
if (h.isempty(pagetype) or pagetype == 'Unknown') and not h.in_list({'Appearances', 'Handbook Appearances', 'Minor Appearances', 'Mentions', 'Handbook Mentions', 'Invocations', 'Items', 'Quotes', 'Images', 'Gallery'}, subpagename)
then
basepagename = mw.title.getCurrentTitle().text
pagetype = m_pagetype.get_page_type(basepagename)
end
end
end
if h.in_list({'Comic', 'Volume', 'Novel', 'Episode', 'Season', 'Series', 'Film', 'Video Game', 'Board Game'}, pagetype)
then return p.lua_standard_subcategories_and_subpages2(basepagename, subpagename, pagetype)
else return p.lua_standard_subcategories_and_subpages(basepagename, subpagename, pagetype)
end
end
-- for sources - 'Comic', 'Volume', 'Novel', 'Episode', 'Season', 'Series', 'Film', 'Video Game', 'Board Game'
function p.lua_standard_subcategories_and_subpages2(basepagename, subpagename, pagetype)
local standard = require('Module:StandardizedName')
local m_pagetype = require('Module:PageType')
local sortname = ''
local i
local category
local list = {}
local list1 = {'Images', 'Reprints'}
local list2 = {'Images'}
local list3 = {'Issues', 'Images', 'Reprints', 'TPB', 'Annuals', 'Specials'}
local list_of_subpages = {}
local help = ''
local info = ''
local output_categories = {}
local output = ''
if string.find(basepagename, ' Season ') ~= nil and string.find(basepagename, ' Vol ') == nil and m_pagetype.get_page_type(basepagename) ~= 'Episode'
then pagetype = 'Season'
else pagetype = pagetype or m_pagetype.get_page_type(basepagename)
end
if pagetype == 'Volume' or pagetype == 'Comic'
then
info = standard.lua_get_title_volume_issue(basepagename, 'Vol')
sortname = info.sortname.all
if pagetype == 'Volume'
then list = list3
else list = list1
end
elseif h.in_list({'Episode', 'Season'}, pagetype)
then
if subpagename == basepagename
then list = list2
end
info = standard.lua_get_title_volume_issue(basepagename, 'Season')
sortname = info.sortname.all
--elseif h.in_list({'Novel', 'Film', 'Video Game', 'Board Game'}, pagetype)
-- then list = list2
elseif h.in_list({'Video Game', 'Series'}, pagetype)
then
list = list2
sortname = standard.lua_standardized_name_for_sorting(basepagename, pagetype)
else sortname = standard.lua_standardized_name_for_sorting(basepagename, pagetype)
end
for i = 1, #list do
if list[i] == 'Issues'
then
category = basepagename
s = 'pages'
else
category = basepagename..'/'..list[i]
if list[i] == 'Images'
then s = 'files'
elseif list[i] == 'Reprints'
then
if pagetype == 'Comic'
then s = 'pages'
else s = 'subcats'
end
else s = 'pages'
end
end
table.insert(list_of_subpages, p.lua_add_navigation_link(category, list[i], s) )
end
if h.in_list({'Video Game', 'Series'}, pagetype)
then
category = basepagename..'/Gallery'
if h.exists(category)
then table.insert(list_of_subpages, h.Link(category, 'Gallery') )
else table.insert(list_of_subpages, p.nonexistent_page('Gallery') )
end
end
list_of_subpages = p.lua_add_navigation(list_of_subpages)
if h.in_list({'Reprints', 'TPB', 'Annuals', 'Specials', 'Images', 'Gallery'}, subpagename) and subpagename ~= basepagename
then
if subpagename == 'Reprints'
then
if pagetype == 'Comic'
then
output = 'List of all known reprints of '..h.Link(basepagename, basepagename)..'.'
help = '(If you find an issue that is not shown here, please add "'
help = help..basepagename..'" into "ReprintOf_" field of said issue.)'
table.insert(output_categories, 'Comic Reprints by Issue')
table.insert(output_categories, info.noissue..'/Reprints')
else
output = 'List of reprints of issues from '..h.Link(basepagename, basepagename)..' volume.'
help = '(If you find reprint of an issue from this volume that is not shown here, please add'
help = help..' original source into "ReprintOf_" field of said issue.)'
table.insert(output_categories, 'Comic Reprints by Volume')
end
elseif subpagename == 'TPB'
then
output = 'List of all known TPB editions that focus on comic issues from '..h.Link(basepagename, basepagename)..' volume.'
help = '(If you have found a volume that is not shown here, please add "'..basepagename..'" into <code>main_volume</code> field of said volume.)'
table.insert(output_categories, 'TPBs by Source')
elseif subpagename == 'Annuals' or subpagename == 'Specials'
then
output = 'List of all known '..string.lower(subpagename)..' that focus on comic issues from '..h.Link(basepagename, basepagename)..' volume.'
help = '(If you have found a volume that is not shown here, please add "'..basepagename..'" into <code>main_volume</code> field of said volume.)'
table.insert(output_categories, subpagename..' by Source')
elseif subpagename == 'Images'
then
if pagetype == 'Season'
then output = 'List of all notable images from '..h.Link(info.title..'#Season '..info.volume, basepagename)..'.'
else output = 'List of all notable images from '..h.Link(basepagename, basepagename)..'.'
end
if pagetype == 'Volume'
then help = '(If you find an image that is not shown here, please add an issue of "'
elseif pagetype == 'Season' or pagetype == 'Series'
then help = '(If you find an image that is not shown here, please add an episode of "'
else help = '(If you find an image that is not shown here, please add "'
end
help = help..basepagename..'" into "Source" field of said image.)'
if pagetype == 'Comic'
then
table.insert(output_categories, 'Images by Comic Issue')
table.insert(output_categories, info.noissue..'/Images')
elseif pagetype == 'Volume'
then table.insert(output_categories, 'Images by Comic Volume')
elseif pagetype == 'Episode'
then
table.insert(output_categories, 'Images by TV Episode')
table.insert(output_categories, info.noissue..'/Images')
elseif pagetype == 'Season'
then
table.insert(output_categories, 'Images by TV Season')
table.insert(output_categories, info.title..'/Images')
elseif pagetype == 'Series'
then table.insert(output_categories, 'Images by TV Series')
else -- 'Novel', 'Film', 'Video Game', 'Board Game'
table.insert(output_categories, 'Images by '..pagetype)
end
elseif subpagename == 'Gallery'
then
output = 'Gallery of all notable images (or videos) from '..h.Link(basepagename, basepagename)..'.'
help = h.Link('Marvel Database:Gallery Guidelines', 'Gallery Guidelines')
help = '(If you create a gallery or add image (or video) to existing one, please follow our '..help..').'
table.insert(output_categories, pagetype..' Galleries')
end
else
--basepagename = mw.title.getCurrentTitle().text
--pagetype = m_pagetype.get_page_type(basepagename)
if pagetype == 'Volume'
then
output = 'List of all known comic issues from '..h.Link(basepagename, basepagename)..' volume.'
help = h.Link('Marvel Database:Comic Template', 'Comic Template')
help = '(If you find an issue that is not shown here, please add the '..help..' to it.)'
table.insert(output_categories, 'Volumes')
end
end
help = p.add_help(help)
output = design.span(output).bold..help..list_of_subpages
return design.messagebox({output})..h.add_categories(output_categories, sortname)
end
-- for articles - characters, teams, etc.
function p.lua_standard_subcategories_and_subpages(basepagename, subpagename, pagetype)
local m_pagetype = require('Module:PageType')
local sortname
local i
local category
local list = {'Appearances', 'Handbook Appearances', 'Minor Appearances', 'Mentions', 'Handbook Mentions', 'Invocations', 'Items', 'Quotes', 'Images'}
local list_of_subpages = {}
local help = ''
local s
local killed_by = false
local output_categories = {}
local output = ''
if string.find(basepagename, 'Killed by ') ~= nil
then
basepagename = string.match(basepagename, 'Killed by (.+)')
killed_by = true
end
sortname = require('Module:StandardizedName').name_for_sorting({basepagename})
pagetype = pagetype or m_pagetype.get_page_type(basepagename)
if pagetype == 'Staff'
then pagetype = 'Marvel Staff'
end
for i = 1, #list do
category = basepagename..'/'..list[i]
if list[i] == 'Images'
then s = 'files'
else s = 'pages'
end
table.insert(list_of_subpages, p.lua_add_navigation_link(category, list[i], s))
end
category = basepagename..'/Gallery'
if h.exists(category)
then table.insert(list_of_subpages, h.Link(category, 'Gallery') )
else table.insert(list_of_subpages, p.nonexistent_page('Gallery') )
end
if h.in_list({'Character', 'Team', 'Organization', 'Race', 'Item', 'Vehicle'}, pagetype)
then
category = 'Killed by '..basepagename
table.insert(list_of_subpages, p.lua_add_navigation_link(category, 'Victims', 'pages'))
end
list_of_subpages = p.lua_add_navigation(list_of_subpages)
if subpagename ~= basepagename
then
if h.in_list({'Appearances', 'Handbook Appearances', 'Minor Appearances', 'Mentions', 'Handbook Mentions', 'Invocations'}, subpagename)
then
if h.in_list({ 'Handbook Appearances', 'Handbook Mentions' }, subpagename)
then output = 'List of all known '..string.lower(string.gsub(subpagename, 'Handbook ', ''))..' of '..h.Link(basepagename, basepagename)..' in '..h.LinkToCategory('Handbooks', 'handbooks')..'.'
else output = 'List of all known '..string.lower(subpagename)..' of '..h.Link(basepagename, basepagename)..'.'
end
for i = 1,6 do
if subpagename == list[i]
then
if h.in_list({ 'Invocations', 'Handbook Mentions', 'Handbook Appearances' }, list[i])
then table.insert(output_categories, list[i])
else table.insert(output_categories, pagetype..' '..list[i])
end
end
end
help = '(If you find a medium that is not shown here, please add "'..basepagename
help = help..'" to the appearances section with a '..h.Link('Marvel Database: Appearance Tags', 'proper tag')..'.)'
elseif subpagename == 'Items'
then
output = 'List of all notable items owned and/or used by '..h.Link(basepagename, basepagename)..'.'
help = '(If you find an item that is not shown here, please add "'..basepagename
help = help..'" to the "CurrentOwner" or "PreviousOwners" sections.)'
table.insert(output_categories, 'Items by User')
elseif subpagename == 'Quotes'
then
output = 'List of all notable quotes by or about '..h.Link(basepagename, basepagename)..'.'
help = '(Please add any important quotations that may be missing, ensuring to cite the original source. '
help = help..'Pages with a quote from this character will automatically be added here along with the quote.)'
table.insert(output_categories, 'Quotes')
elseif subpagename == 'Images'
then
output = 'List of all images of '..h.Link(basepagename, basepagename)..' on the database.'
help = '(If you find an image in the database that is not shown here, please add "'..basepagename..'" as an image subject.)'
table.insert(output_categories, pagetype..' Images')
elseif subpagename == 'Gallery'
then
output = 'Gallery of all notable images '
if pagetype == 'Marvel Staff' or pagetype == 'User Art'
then output = output..'by '
else output = output..'of '
end
if pagetype == 'User Art'
then output = output..h.Link('User:'..basepagename, 'User:'..basepagename)
else output = output..h.Link(basepagename, basepagename)
end
output = output..' on the database.'
help = h.Link('Marvel Database:Gallery Guidelines', 'Gallery Guidelines')
help = '(If you create a gallery or add image(s) to existing one, please follow our '..help..').'
table.insert(output_categories, pagetype..' Galleries')
elseif killed_by == true
then
output = 'List of all notable victims killed by '..h.Link(basepagename, basepagename)..'.'
help = '(If you find a character that is not shown here, please add "'..basepagename
help = help..'" to the "KilledBy" field.)'
table.insert(output_categories, 'Characters by Killer')
end
if ( pagetype ~= 'User Art' and not h.exists(basepagename) ) or ( pagetype == 'User Art' and not h.exists('User:'..basepagename) )
then
output_categories = {} -- remove all previous categories
if killed_by == true
then table.insert(output_categories, 'Killed By Categories with Articles Needed')
else table.insert(output_categories, subpagename..' Categories with Articles Needed')
end
end
end
help = p.add_help(help)
output = design.span(output).bold..help..list_of_subpages
return design.messagebox({output})..h.add_categories(output_categories, sortname)
end
--------------------------------------------------------------------------------
-- used in Template:Season Category
function p.season_category(frame)
local standard = require('Module:StandardizedName')
local basepagename = mw.title.getCurrentTitle().baseText
local info = standard.lua_get_title_volume_issue(basepagename, 'Season')
local sortname = info.sortname.all
local i
local category
local images = basepagename..'/Images'
local seasons = {}
local help = ''
local output_categories = {}
local output = ''
output = design.span('List of all known episodes from '..h.Link(info.title..'#Season '..info.volume, basepagename)..'.').bold
help = h.Link('Marvel Database:Episode Template', 'Episode Template')
help = '(If you find an episode that is not shown here, please add the '..help..' to it.)'
for i = 1, 30 do
category = info.title..' Season '..i
if h.exists('Category:'..category)
then
category = h.LinkToCategory(category, 'Season '..i)
table.insert(seasons, category)
end
end
seasons = p.lua_add_navigation(seasons)
if h.pages_in_category(images, 'files') > 0
then images = p.lua_add_navigation({ h.LinkToCategory(images, 'Images') })
else images = ''
end
output = output..'<br>'..help..images..seasons
table.insert(output_categories, 'Seasons')
return design.messagebox({output})..h.add_categories(output_categories, sortname)
end
--------------------------------------------------------------------------------
-- used in Template:Reality Category
function p.categories_by_reality(frame)
local page_types = {'Character', 'Item', 'Location', 'Organization', 'Race', 'Team', 'Vehicle'}
local basepagename = mw.title.getCurrentTitle().baseText
local subpagename = mw.title.getCurrentTitle().subpageText
local sortname = require('Module:Reality').get_reality_info({basepagename}).padded_number
local i
local category
local list_of_subpages = {}
local help = ''
local output_categories = {}
local output = ''
if string.find(basepagename, ' by Reality') ~= nil
then
for i = 1, #page_types do
category = page_types[i]..'s by Reality'
table.insert(list_of_subpages, h.LinkToCategory(category, page_types[i]..'s') )
end
list_of_subpages = mw.text.listToText(list_of_subpages, ' · ', ' · ')
else
for i = 1, #page_types do
table.insert(list_of_subpages, p.lua_add_navigation_link(basepagename..'/'..page_types[i]..'s', page_types[i]..'s'))
end
list_of_subpages = p.lua_add_navigation(list_of_subpages)
end
if subpagename == basepagename
then
if string.find(basepagename, ' by Reality') ~= nil
then
category = string.match(basepagename, '(.+) by Reality')
table.insert(output_categories, category)
sortname = 'Reality'
else
output = 'Articles related to '..h.Link(basepagename, basepagename)..' reality.'
table.insert(output_categories, 'Realities by Category')
end
else
output = subpagename..' that originate from '..h.Link(basepagename, basepagename)..' reality.'
table.insert(output_categories, subpagename..' by Reality')
table.insert(output_categories, {basepagename, subpagename})
help = '(To add '..string.lower(string.sub(subpagename, 1, -1))..' to this list enter "'..basepagename..'" in the "Universe" field of its template.)'
help = p.add_help(help)
end
output = design.span(output).bold..help..list_of_subpages
return design.messagebox({output})..h.add_categories(output_categories, sortname)
end
--------------------------------------------------------------------------------
-- used in Template:Year of Debut Category
function p.debut_category(frame)
local page_types = {}
local page_types2 = {}
local page_types1_1 = {'Character', 'Item', 'Location', 'Organization', 'Race', 'Reality', 'Team', 'Vehicle'}
local page_types1_2 = {'Characters', 'Items', 'Locations', 'Organizations', 'Races', 'Realities', 'Teams', 'Vehicles'}
local page_types2_1 = {'Event', 'Story Arc', 'Storyline'}
local page_types2_2 = {'Events', 'Story Arcs', 'Storylines'}
local pagename = mw.title.getCurrentTitle().text
local page_type
local page_type2
local year
local i
local category
local navigation = {}
local header = ''
local output_categories = {}
local output = ''
year, page_type = string.match(pagename, '^(%d%d%d%d) (.+) Debuts')
if page_type == nil
then
page_type2 = string.match(pagename, '^(.+)s by Year of Debut')
if page_type2 == 'Realitie'
then page_type = 'Reality'
else page_type = page_type2
end
output = p.debut_categories_navigation(page_type)
table.insert(output_categories, {page_type2..'s', 'Year of Debut'})
else
if h.in_list(page_types1_1, page_type)
then
page_types = page_types1_1
page_types2 = page_types1_2
header = ' which first appeared in medium released in '
else
page_types = page_types2_1
page_types2 = page_types2_2
header = ' what were released in '
end
for i = 1, #page_types do
if page_types[i] == page_type
then page_type2 = page_types2[i]
end
table.insert(navigation, p.lua_add_navigation_link(year..' '..page_types[i]..' Debuts', page_types2[i]))
end
navigation = p.lua_add_navigation(navigation)
table.insert(output_categories, page_type2..' by Year of Debut')
table.insert(output_categories, {year, page_type..' Debuts'})
header = design.span(page_type2..header..h.LinkToCategory(year, year)..'.').bold
output = design.messagebox({header..navigation})..p.debut_categories_navigation(page_type)
end
return output..h.add_categories(output_categories)
end
function p.debut_categories_navigation(page_type)
local page_types = {}
local page_types2 = {}
local page_types1_1 = {'Character', 'Item', 'Location', 'Organization', 'Race', 'Reality', 'Team', 'Vehicle'}
local page_types1_2 = {'Characters', 'Items', 'Locations', 'Organizations', 'Races', 'Realities', 'Teams', 'Vehicles'}
local page_types2_1 = {'Event', 'Story Arc', 'Storyline'}
local page_types2_2 = {'Events', 'Story Arcs', 'Storylines'}
local current_year = require("Module:Date").get_current_year()
local header
local i
local category
local help = {}
local navigation = {}
local output = {}
if h.in_list(page_types1_1, page_type)
then
page_types = page_types1_1
page_types2 = page_types1_2
header = ' by year of their first appearance.'
else
page_types = page_types2_1
page_types2 = page_types2_2
header = ' by year of their release.'
end
for i = 1939, current_year do
table.insert(navigation, p.lua_add_navigation_link(i..' '..page_type..' Debuts', i))
end
navigation = p.lua_add_navigation(navigation, ' ')
for i = 1, #page_types do
category = page_types2[i]..' by Year of Debut'
table.insert(help, h.LinkToCategory(category, page_types2[i]))
if page_type == page_types[i]
then page_type = page_types2[i]
end
end
header = design.span(page_type..header).bold
output = header..'<br>'..p.lua_add_navigation(help) ..'\n----\n'..navigation
return design.messagebox({output})
end
--------------------------------------------------------------------------------
-- for Template:Volume Debut and Template:Volume End
function p.volume_debut_or_end_category(frame)
local pagename = mw.title.getCurrentTitle().text
local m_date = require("Module:Date")
local current_year = m_date.get_current_year()
local debuts_ends = {'Volume Debut', 'Volume End'}
local s_type = ''
local i
local help = {}
local help_months = {}
local help_years = {}
local year
local month
local category
local header = 'Comic volumes which '
local output_categories = {}
local output =''
if string.find(pagename, 'Debut') ~= nil
then s_type = 'Debut'
elseif string.find(pagename, 'End') ~= nil
then s_type = 'End'
end
header = header..string.lower(s_type)..'ed in '
for i = 1939, current_year + 1 do
table.insert(help_years, p.lua_add_navigation_link(i..' Volume '..s_type..'s', i, 'all') )
end
help_years = p.lua_add_navigation(help_years, ' ')
year = string.match(pagename, '(%d+) Volume '..s_type..'s')
if year ~= nil
then
for i = 1, 2 do
table.insert(help, p.lua_add_navigation_link(year..' '..debuts_ends[i]..'s', debuts_ends[i]..'s', 'all'))
end
help = p.lua_add_navigation(help)
table.insert(output_categories, {'Volumes by Year of '..s_type, year})
table.insert(output_categories, {year, 'Volume '..s_type})
header = design.span( header..h.LinkToCategory(year, year)..'.' ).bold
output = header..help..'\n----\n'..help_years
else
month, year = string.match(pagename, '(.+) (%d+) Volume '..s_type)
for i = 1, 2 do
table.insert(help, p.lua_add_navigation_link(month..' '..year..' '..debuts_ends[i], debuts_ends[i], 'all') )
end
help = p.lua_add_navigation(help)
for i = 1, 12 do
table.insert(help_months, p.lua_add_navigation_link(g_list_of_months[i]..' '..year..' Volume '..s_type, g_list_of_months[i]) )
end
help_months = p.lua_add_navigation(help_months)
table.insert(output_categories, {year..' Volume '..s_type..'s', ' '..m_date.get_month_number({month})..pagename})
table.insert(output_categories, {year..', '..month, 'Volume '..s_type})
header = design.span( header..h.LinkToCategory(year..', '..month, month..', '..year)..'.' ).bold
output = header..help..help_months..'\n----\n'..help_years
end
return design.messagebox({output})..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
-- for Template:Volumes by Number of Issues
function p.volumes_by_number_of_issues_category(frame)
local function lpad(n)
return string.rep('0', 3-string.len(n))..n
end
local pagename = mw.title.getCurrentTitle().text
local i
local header = design.span('Comic volumes by number of issues.<br>').bold
local category_text = ''
local category = ''
local output = {}
table.insert(output, h.LinkToCategory('One Shots', 'One Shots'))
table.insert(output, h.LinkToCategory('Volumes With 2 to 9 Issues', '002-009') )
for i = 10, 90, 10 do
category = 'Volumes With '..i..' to '..(i+9)..' Issues'
category_text = lpad(i)..'-'..lpad(i+9)
table.insert(output, p.lua_add_navigation_link(category, category_text))
end
for i = 100, 950, 50 do
category = 'Volumes With '..i..' to '..(i+49)..' Issues'
category_text = i..'-'..(i+49)
table.insert(output, p.lua_add_navigation_link(category, category_text))
end
output = p.lua_add_navigation(output)
if pagename == 'One Shots'
then category = h.Category('Volumes by Number of Issues', '001')
elseif string.find(pagename, 'Volumes With') ~= nil
then
first = string.match(pagename, 'Volumes With (%d+) to (%d+) Issues')
category = h.Category('Volumes by Number of Issues', lpad(first))
end
return design.messagebox({header..output})..category
end
-- ***************************************************************************************
-- following functions are used only within this module
--------------------------------------------------------------------------------
function p.nonexistent_page(text)
return tostring( mw.html.create('span'):addClass('messagebox__nonexistent_page'):wikitext(text))
end
--------------------------------------------------------------------------------
function p.add_help(value)
local output = ''
if not h.isempty(value)
then output = '<br>'..tostring(mw.html.create('span'):css('font-size', '80%'):wikitext(value))
end
return output
end
--------------------------------------------------------------------------------
function p.lua_add_navigation_link(category, value, page_types)
if h.pages_in_category(category, page_types) > 0
then return h.LinkToCategory(category, value)
else return p.nonexistent_page(value)
end
end
--------------------------------------------------------------------------------
function p.lua_add_navigation(navigation_list, separator, new_line)
local output = ''
if h.isempty(separator)
then separator = ' · '
end
if h.isempty(new_line)
then new_line = true
end
if not h.isempty(navigation_list)
then
output = mw.text.listToText(navigation_list, separator, separator)
output = tostring( mw.html.create('span'):addClass('messagebox__help'):wikitext(output) )
if new_line
then output = '<br>'..output
end
end
return output
end
--------------------------------------------------------------------------------
function p.lua_add_nation_navigation(value)
local output = {}
table.insert(output, p.lua_add_navigation_link(value, 'Citizens', 'pages'))
table.insert(output, p.lua_add_navigation_link(value..' Staff Members', 'Staff Members', 'pages'))
table.insert(output, p.lua_add_navigation_link(value..' Organizations', 'Organizations', 'pages'))
table.insert(output, p.lua_add_navigation_link(value..' Technology', 'Technologies', 'pages'))
output = mw.text.listToText(output, ' · ', ' · ')
output = '<br>'..tostring( mw.html.create('span'):addClass('messagebox__help'):wikitext(output) )
return output
end
--------------------------------------------------------------------------------
function p.lua_add_year_of_birth_death_navigation(value)
local output = {}
table.insert(output, p.lua_add_navigation_link('Born in '..value, 'Born', 'pages'))
table.insert(output, p.lua_add_navigation_link('Died in '..value, 'Died', 'pages'))
output = mw.text.listToText(output, ' · ', ' · ')
output = '<br>'..tostring( mw.html.create('span'):addClass('messagebox__help'):wikitext(output) )
return output
end
return p