Documentation for this module may be created at Module:Image Template/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
local h = require("Module:HF")
local SC = require("Module:StaffCorrection")
local reality = require("Module:Reality")
local design = require('Module:Design')
local standard = require("Module:StandardizedName")
local pagetype = require("Module:PageType")
function p.main(frame)
local args = getArgs(frame)
local pagename = mw.title.getCurrentTitle().text
local reprint = false
local value
local categories = {}
local group = {}
local reprint_message = ''
local reprint_content = ''
local output_categories = {}
local output_infobox = {}
local output = {}
table.insert(output_categories, 'Templated Images')
--check if image is a reprint
value = args['ReprintOf']
if not h.isempty(value)
then
reprint = true
value = 'File:'..string.gsub(value, 'File:', '')
if h.exists(value)
then
reprint_message = design.messagebox({'This image is reprint of '..value..'.'})
reprint_content = h.get_content(value)
end
end
-- infobox
value, categories = p.lua_get_image_license(args['License'], reprint_content)
table.insert(output_categories, categories)
table.insert(output_infobox, design.add_infobox_row('License', value) )
value, categories = p.lua_get_image_type(args['ImageType'], reprint_content)
table.insert(output_categories, categories)
table.insert(output_infobox, design.add_infobox_row('Image type', value) )
value, categories = p.group_reality_and_subjects(args, reprint_content)
output_categories = h.join_tables(output_categories, categories)
table.insert(output_infobox, value)
value, categories = p.group_source_and_creators(args, reprint_content)
output_categories = h.join_tables(output_categories, categories)
table.insert(output_infobox, value)
table.insert(output_categories, p.lua_get_outdated_fields(args) )
-- sections
table.insert( output, '__NOTOC__' )
table.insert( output, design.add_section('Description', args.Description, 2) )
value = '\n* All [[Marvel Comics]] characters and the distinctive likeness(es) thereof are Trademarks & Copyright © 1941-'..os.date('*t').year..' Marvel Characters, Inc. ALL RIGHTS RESERVED.'
if not h.isempty(args.Notes)
then value = value..'\n'..args.Notes
end
table.insert( output, design.add_section('Notes', value, 2) )
table.insert( output, design.add_section('Trivia', args.Trivia, 2) )
value = '\n* [[Marvel Database:Image Policy|Our Image Policy]]\n* [[Marvel Database:Copyrights|Our Copyright Policy]]\n* [[Marvel Database:General disclaimer|General Disclaimer]]'
value = value..'\n* http://en.wikipedia.org/wiki/Fair_Use\n* http://www.copyright.gov/title17/92chap1.html\n* http://www.copyright.gov/title17/92chap1.html#107'
value = value..'\n* http://www.ipwatchdog.com/2012/10/05/copyright-fair-use-cases-of-the-united-states-supreme-court/id=26225/'
value = value..'\n* http://en.wikipedia.org/wiki/GNU_Free_Documentation_License\n* http://www.gnu.org/copyleft/fdl.html'
value = value..'\n<references/>'
table.insert( output, design.add_section('Links and References', value, 2) )
--
output_infobox = design.create_infobox( table.concat(output_infobox) )
output_categories = h.add_categories(output_categories)
output = table.concat(output)
return output_categories..frame:preprocess(output_infobox..output)
end
--------------------------------------------------------------------------------------------------
function p.lua_get_image_license(value, reprint_content)
local license = {
['gfdl'] = { 'GFDL', 'GFDL' },
['pd'] = { 'Public Domain Images', 'Public Domain' },
['public domain'] = { 'Public Domain Images', 'Public Domain' },
['fair use'] = { 'Fair Use Images', 'Fair Use' },
['fairuse'] = { 'Fair Use Images', 'Fair Use' },
['cover'] = { 'Fair Use (Comic Covers)', 'Fair Use (Comic Cover)' },
['comic cover'] = { 'Fair Use (Comic Covers)', 'Fair Use (Comic Cover)' },
['comic covers'] = { 'Fair Use (Comic Covers)', 'Fair Use (Comic Cover)' },
['cover art'] = { 'Fair Use (Comic Covers)', 'Fair Use (Comic Cover)' },
['csp'] = { 'Fair Use (Comic Single Panels)', 'Fair Use (Comic Single Panel)' },
['panel'] = { 'Fair Use (Comic Single Panels)', 'Fair Use (Comic Single Panel)' },
['single panel'] = { 'Fair Use (Comic Single Panels)', 'Fair Use (Comic Single Panel)' },
['comic single panel'] = { 'Fair Use (Comic Single Panels)', 'Fair Use (Comic Single Panel)' },
['comic single panels'] = { 'Fair Use (Comic Single Panels)', 'Fair Use (Comic Single Panel)' },
['cs'] = { 'Fair Use (Comic Scenes)', 'Fair Use (Comic Scene)' },
['scene'] = { 'Fair Use (Comic Scenes)', 'Fair Use (Comic Scene)' },
['comic scene'] = { 'Fair Use (Comic Scenes)', 'Fair Use (Comic Scene)' },
['comic scenes'] = { 'Fair Use (Comic Scenes)', 'Fair Use (Comic Scene)' },
['cp'] = { 'Fair Use (Comic Pages)', 'Fair Use (Comic Page)' },
['page'] = { 'Fair Use (Comic Pages)', 'Fair Use (Comic Page)' },
['comic page'] = { 'Fair Use (Comic Pages)', 'Fair Use (Comic Page)' },
['tc'] = { 'Fair Use (Trading Cards)', 'Fair Use (Trading Card)' }, --Trading Card Images
['card'] = { 'Fair Use (Trading Cards)', 'Fair Use (Trading Card)' }, --Trading Card Images
['trading card'] = { 'Fair Use (Trading Cards)', 'Fair Use (Trading Card)' }, --Trading Card Images
['trading cards'] = { 'Fair Use (Trading Cards)', 'Fair Use (Trading Card)' }, --Trading Card Images
['novel'] = { 'Fair Use (Novel Images)', 'Fair Use (Novel Image)' },
['novels'] = { 'Fair Use (Novel Images)', 'Fair Use (Novel Image)' },
['book'] = { 'Fair Use (Novel Images)', 'Fair Use (Novel Image)' },
['books'] = { 'Fair Use (Novel Images)', 'Fair Use (Novel Image)' },
['game'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['games'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['video game'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['video games'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['videogame'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['videogames'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['game screenshot'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['game screenshots'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['video game screenshot'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['video game screenshots'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['videogame screenshot'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['videogame screenshots'] = { 'Fair Use (Game Screenshots)', 'Fair Use (Game Screenshot)' }, --Video Game Screenshots
['film'] = { 'Fair Use (Movie Screenshots)', 'Fair Use (Movie Screenshot)' }, --Movie Screenshots
['movie'] = { 'Fair Use (Movie Screenshots)', 'Fair Use (Movie Screenshot)' }, --Movie Screenshots
['movie screenshot'] = { 'Fair Use (Movie Screenshots)', 'Fair Use (Movie Screenshot)' }, --Movie Screenshots
['movie screenshots'] = { 'Fair Use (Movie Screenshots)', 'Fair Use (Movie Screenshot)' }, --Movie Screenshots
['tv'] = { 'Fair Use (TV Screenshots)', 'Fair Use (TV Screenshot)' }, --TV Screenshots
['tv screenshot'] = { 'Fair Use (TV Screenshots)', 'Fair Use (TV Screenshot)' }, --TV Screenshots
['tv screenshots'] = { 'Fair Use (TV Screenshots)', 'Fair Use (TV Screenshot)' }, --TV Screenshots
['database'] = { 'Fair Use (Database Screenshots)', 'Fair Use (Database Screenshot)' }, --Database Screenshots
['database screenshot'] = { 'Fair Use (Database Screenshots)', 'Fair Use (Database Screenshot)' }, --Database Screenshots
['database screenshots'] = { 'Fair Use (Database Screenshots)', 'Fair Use (Database Screenshot)' }, --Database Screenshots
['software'] = { 'Fair Use (Software Screenshots)', 'Fair Use (Software Screenshot)' }, --Software Screenshots
['software screenshot'] = { 'Fair Use (Software Screenshots)', 'Fair Use (Software Screenshot)' }, --Software Screenshots
['software screenshots'] = { 'Fair Use (Software Screenshots)', 'Fair Use (Software Screenshot)' }, --Software Screenshots
['promo'] = { 'Fair Use (Promotional Materials)', 'Fair Use (Promotional Material)' }, --Promotional Material
['promo material'] = { 'Fair Use (Promotional Materials)', 'Fair Use (Promotional Material)' }, --Promotional Material
['promo materials'] = { 'Fair Use (Promotional Materials)', 'Fair Use (Promotional Material)' }, --Promotional Material
['promotional material'] = { 'Fair Use (Promotional Materials)', 'Fair Use (Promotional Material)' }, --Promotional Material
['promotional materials'] = { 'Fair Use (Promotional Materials)', 'Fair Use (Promotional Material)' }, --Promotional Material
['promotional'] = { 'Fair Use (Promotional Materials)', 'Fair Use (Promotional Material)' }, --Promotional Material
['movie poster'] = { 'Fair Use (Movie Posters)', 'Fair Use (Movie Poster)' }, --Movie Posters
['movie posters'] = { 'Fair Use (Movie Posters)', 'Fair Use (Movie Poster)' }, --Movie Posters
['merch'] = { 'Fair Use (Merchandise Images)', 'Fair Use (Merchandise Image)' }, --Merchandise Images
['merchandise'] = { 'Fair Use (Merchandise Images)', 'Fair Use (Merchandise Image)' }, --Merchandise Images
['merchandise image'] = { 'Fair Use (Merchandise Images)', 'Fair Use (Merchandise Image)' }, --Merchandise Images
}
local info = { 'Unlicensed Images', 'Unlicensed' }
local category = ''
local text = ''
local output_category = ''
local output = ''
if reprint_content ~= ''
then value = h.get_field_value(reprint_content, 'License')
end
if not h.isempty(value) and license[string.lower(value)] ~= nil
then info = license[string.lower(value)]
end
output = h.LinkToCategory(info[1], info[2])
if reprint_content ~= ''
then output_category = info[1]
end
return output, output_category
end
--------------------------------------------------------------------------------------------------
function p.lua_get_image_type(value, reprint_content)
local image_type = {
['cover'] = { 'Cover Art Images', 'Cover Art Image' },
['cover art'] = { 'Cover Art Images', 'Cover Art Image' },
['wraparound cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['wrap-around cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['wrap around cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['wraparound'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['wrap-around'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['wrap around'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['foldout cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['fold out cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['fold-out cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['folded cover'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['fold out'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['foldout'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['fold-out'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['gatefold'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['gate-fold'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['folded'] = { 'Wraparound Cover Images', 'Cover Art (Wraparound) Image' },
['variant cover'] = { 'Variant Covers', 'Cover Art (Variant) Image' },
['variants cover'] = { 'Variant Covers', 'Cover Art (Variant) Image' },
['variable cover'] = { 'Variant Covers', 'Cover Art (Variant) Image' },
['variant'] = { 'Variant Covers', 'Cover Art (Variant) Image' },
['variants'] = { 'Variant Covers', 'Cover Art (Variant) Image' },
['variable'] = { 'Variant Covers', 'Cover Art (Variant) Image' },
['solicit'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicits'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicit cover'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicits cover'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicitation cover'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicitations cover'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicitation'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['solicitations'] = { 'Solicit Cover Images', 'Cover Art (Solicit) Image' },
['textless'] = { 'Textless Cover Images', 'Cover Art (Textless) Image' },
['no text'] = { 'Textless Cover Images', 'Cover Art (Textless) Image' },
['textless cover'] = { 'Textless Cover Images', 'Cover Art (Textless) Image' },
['no text cover'] = { 'Textless Cover Images', 'Cover Art (Textless) Image' },
['2nd printing cover'] = { 'Second Printing Variants', 'Cover Art (2nd Printing) Image' },
['2nd printing'] = { 'Second Printing Variants', 'Cover Art (2nd Printing) Image' },
['second-printing cover'] = { 'Second Printing Variants', 'Cover Art (2nd Printing) Image' },
['second printing cover'] = { 'Second Printing Variants', 'Cover Art (2nd Printing) Image' },
['second-printing'] = { 'Second Printing Variants', 'Cover Art (2nd Printing) Image' },
['second printing'] = { 'Second Printing Variants', 'Cover Art (2nd Printing) Image' },
--['trading card'] = { 'Trading Card Images', 'Trading Card Image' },
--['trading cards'] = { 'Trading Card Images', 'Trading Card Image' },
--['card'] = { 'Trading Card Images', 'Trading Card Image' },
--['tc'] = { 'Trading Card Images', 'Trading Card Image' },
--['episode'] = { 'Episode Images', 'Episode Image' },
['character'] = { 'Character Images', 'Character Image' },
['character image'] = { 'Character Images', 'Character Image' },
['char'] = { 'Character Images', 'Character Image' },
['teams'] = { 'Team Images', 'Team Image' },
['team'] = { 'Team Images', 'Team Image' },
['vehicles'] = { 'Vehicle Images', 'Vehicle Image' },
['vehicle'] = { 'Vehicle Images', 'Vehicle Image' },
['organization'] = { 'Organization Images', 'Organization Image' },
['item'] = { 'Item Images', 'Item Image' },
['reality'] = { 'Reality Images', 'Reality Image' },
['location'] = { 'Location Images', 'Location Image' },
['event'] = { 'Event Images', 'Event Image' },
['race'] = { 'Race Images', 'Race Image' },
['map'] = { 'Map Images', 'Map Image' },
['scene'] = { 'Scene Images', 'Scene Image' },
['staff'] = { 'Marvel Staff Images', 'Marvel Staff Image' },
['staff members'] = { 'Marvel Staff Images', 'Marvel Staff Image' },
['members'] = { 'Marvel Staff Images', 'Marvel Staff Image' },
['marvel staff'] = { 'Marvel Staff Images', 'Marvel Staff Image' },
['non marvel'] = { 'Non-Marvel Images', 'Non-Marvel Image' },
['non-marvel'] = { 'Non-Marvel Images', 'Non-Marvel Image' },
['user image'] = { 'User Images', 'User Image' },
['user'] = { 'User Images', 'User Image' },
['logos'] = { 'Logo Images', 'Logo Image' },
['logo'] = { 'Logo Images', 'Logo Image' },
['site'] = { 'Site Images', 'Site Image' },
}
local info = { 'Images of Unknown Type', 'Unknown Type' }
local output_category = ''
local output = ''
if reprint_content ~= ''
then value = h.get_field_value(reprint_content, 'ImageType')
end
if not h.isempty(value) and image_type[string.lower(value)] ~= nil
then info = image_type[string.lower(value)]
end
output = h.LinkToCategory(info[1], info[2])
if not reprint
then output_category = info[1]
end
return output, output_category
end
--------------------------------------------------------------------------------------------------
function p.lua_get_outdated_fields(args)
local output = ''
if (
not h.isempty(args.ImageType)
and h.in_list( {'trading card', 'trading cards', 'card', 'episode'}, string.lower(args.ImageType) )
)
or not h.isempty(args.Issue)
then output = 'Outdated Fields'
end
return output
end
-- ********************* GROUPS *********************
--------------------------------------------------------------------------------------------------
function p.group_reality_and_subjects(args, reprint_content)
local reprint = false
local i
local value
local category
local subjects = {}
local label = 'Subject'
local output_categories = {}
local output = {}
if reprint_content ~= ''
then reprint = true
end
if reprint
then value = h.get_field_value(reprint_content, 'Universe')
else value = args['Universe']
end
if not h.isempty(value)
then
value = reality.get_reality_info({value, 1})
category = value..'/Images'
if not reprint
then table.insert(output_categories, category)
end
value = h.Link(value)
category = h.LinkToCategory(category, '(Images)')
table.insert(output, design.add_infobox_row('Reality', value..' '..category) )
end
if not reprint
then
value = args['Subject1']
if h.isempty(value)
then table.insert(output_categories, 'Image Subject Needed')
elseif string.lower(value) == 'none'
then table.insert(output_categories, 'No Subject Image')
end
end
if reprint
then
for i = 1, 200 do
value = h.get_field_value(reprint_content, 'Subject'..i)
if not h.isempty(value)
then
category = h.LinkToCategory(value..'/Images', '(Images)')
value = design.lua_span( h.Link(value) ).italic
table.insert(subjects, value..' '..category)
end
end
end
for i = 1, 200 do
value = args['Subject'..i]
if not h.isempty(value)
then
category = value..'/Images'
table.insert(output_categories, category)
table.insert(subjects, h.Link(value)..' '..h.LinkToCategory(category, '(Images)'))
end
end
if #subjects > 0
then
if #subjects > 1
then label = 'Subjects'
end
subjects = mw.text.listToText(subjects, '\n', '\n')
table.insert(output, design.add_infobox_row(label, subjects) )
end
return design.add_infobox_group(output, 'Image Contents'), output_categories
end
--------------------------------------------------------------------------------------------------
function p.group_source_and_creators(args, reprint_content)
local staff = {'Cover Artist', 'Penciler', 'Inker', 'Colourist', 'Letterer' }
local reprint = false
local i
local j
local correct_name
local value
local category
local s = {}
local label
local output_categories = {}
local output = {}
if reprint_content ~= ''
then reprint = true
end
value = args['Source']
if not h.isempty(value)
then
table.insert(output_categories, value..'/Images')
value = standard.lua_get_link_and_release_date(value)
table.insert(output, design.add_infobox_row('Source', value) )
end
if reprint
then value = h.get_field_value(reprint_content, 'Medium')
else value = args['Medium']
end
value = design.lua_span(value).italic
table.insert(output, design.add_infobox_row('Medium', value) )
if reprint
then value = h.get_field_value(reprint_content, 'Photographer')
else value = args['Photographer']
end
if not h.isempty(value)
then
correct_name = SC.lua_get_corrected_name(value)
category = value..'/Photographer Images'
value = h.Link(value, correct_name)
if not reprint
then table.insert(output_categories, category)
else value = design.lua_span(value).italic
end
category = h.LinkToCategory(category, '(Images)')
table.insert(output, design.add_infobox_row('Photographer', value..' '..category) )
end
for i = 1, #staff do
s = {}
if reprint
then
for j = 1, 10 do
value = h.get_field_value(reprint_content, staff[i]..j)
if not h.isempty(value)
then
correct_name = SC.lua_get_corrected_name(value)
category = h.LinkToCategory(value..'/'..staff[i]..' Images', '(Images)')
value = design.lua_span( h.Link(value, correct_name) ).italic
table.insert(s, value..' '..category)
end
end
end
for j = 1, 10 do
value = args[staff[i]..j]
if not h.isempty(value)
then
correct_name = SC.lua_get_corrected_name(value)
category = value..'/'..staff[i]..' Images'
table.insert(output_categories, category)
category = h.LinkToCategory(value..'/'..staff[i]..' Images', '(Images)')
value = h.Link(value, correct_name)
table.insert(s, value..' '..category)
end
end
if #s > 1
then label = staff[i]..'s'
else label = staff[i]
end
table.insert(output, design.add_infobox_row(label, mw.text.listToText(s, '\n', '\n')) )
end
return design.add_infobox_group(output, 'Source and Creators'), output_categories
end
return p