Module:Fileinfo
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Fileinfo/doc
local getArgument = require('Module:Arguments').getArgument
local p = {}
function capitalFirst(str) -- Allows capitalization of the first letter of each word in a string; adapted from (https://stackoverflow.com/questions/20284515/capitalize-first-letter-of-every-word-in-lua)
return (str:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end))
end
function trim(s) -- Allows removing of whitespace from inputs; adapted from (https://www.lua.org/manual/2.4/node32.html)
local l = 1
while string.sub(s,l,l) == ' ' do
l = l+1
end
local r = string.len(s)
while string.sub(s,r,r) == ' ' do
r = r-1
end
return string.sub(s,l,r)
end
function p.Main(frame)
local args = frame.args
local summary = args['summary']
local filetype = trim(args['type']:lower())
local source = args['source']
local media = trim(args['media']:lower())
local mediatype = trim(args['mediatype']:lower())
if mediatype == 'tv' or mediatype == 'ova' or mediatype == 'trpg' then
mediatype = mediatype:upper()
elseif mediatype ~= '' then
mediatype = mediatype
else
mediatype = 'game'
end
local license = trim(args['licensing']:lower())
local subject = args['subject']
local trademark = args['trademark']
local platform = args['version']
local artists = args['artists']
local extrasource = args['reused']
local suppressCat = args['suppresscat']
local suppressCatType = args['suppresscattype']
local suppressPlat = args['suppressplat']
local suppressPlatType = args['suppressplattype']
local filecat = {
['artwork'] = {
displaytext = "[[:Category:Artwork|Artwork]] [[Category:Artwork]]",
cattext = " Artwork"
},
['illustration'] = {
displaytext = "[[:Category:Illustrations|Illustration]] [[Category:Illustrations]]",
cattext = " Illustrations"
},
['render'] = {
displaytext = '[[:Category:Renders|Render]] [[Category:Renders]]',
cattext = ' Renders'
},
['logo'] = {
displaytext = '[[:Category:Logos|Logo]] [[Category:Logos]]',
cattext = " Logos"
},
['cover'] = {
displaytext = '[[:Category:Covers|Cover]] [[Category:Covers]]',
cattext = ' Covers'
},
['map'] = {
displaytext = "[[:Category:Maps|Map]] [[Category:Maps]]",
cattext = ' Maps'
},
['model'] = {
displaytext = "[[:Category:Models|Model]] [[Category:Models]]",
cattext = " Models"
},
['graphic'] = {
displaytext = "[[:Category:Graphics|Graphic]] [[Category:Graphics]]",
cattext = " Graphics"
},
['sprite'] = {
displaytext = "[[:Category:Sprites|Sprite]] [[Category:Sprites]]",
cattext = " Sprites"
},
['screenshot'] = {
displaytext = "[[:Category:Screenshots|Screenshot]] [[Category:Screenshots]]",
cattext = " Screenshots"
},
['card'] = {
displaytext = '[[:Category:Cards|Card]] [[Category:Cards]]',
cattext = " Cards"
},
['icon'] = {
displaytext = '[[:Category:Icons|Icon]] [[Category:Icons]]',
cattext = " Icons"
},
['crop'] = {
displaytext = '[[:Category:Cropped Images|Cropped Image]] [[Category:Cropped Images]]',
cattext = " Cropped Images"
},
['photo'] = {
displaytext = "[[:Category:Photos|Photo]] [[Category:Photos]]",
cattext = " Photos"
},
['merchandise'] = {
displaytext = "[[:Category:Merchandise Images|Merchandise]] [[Category:Merchandise Images]]",
cattext = " Merchandise Images"
},
['audio'] = {
displaytext = "[[:Category:Audio|Audio]] [[Category:Audio]]",
cattext = " Audio"
},
['video'] = {
displaytext = "[[:Category:Videos|Video]] [[Category:Videos]]",
cattext = " Videos"
},
['wiki'] = {
displaytext = "[[:Category:Wiki Images|Wiki Image]] [[Category:Wiki Images]]",
cattext = " Wiki Images"
},
['flag'] = {
displaytext = "[[:Category:Flags|Flag]] [[Category:Flags]]",
cattext = " Flags"
},
['advertisement'] = {
displaytext = "[[:Category:Advertisements|Advertisement]] [[Category:Advertisements]]",
cattext = " Advertisements"
},
['other'] = {
displaytext = "[[:Category:Other Images|Other Image]] [[Category:Other Images]]",
cattext = " Other Images"
}
}
if summary ~= '' then
summary = "\n!Summary \n|" .. summary .. "\n|-"
else
summary = ''
end
if filetype ~= '' and filecat[filetype] ~= nil then
filetype = "\n!Type \n|" .. filecat[filetype].displaytext .. "\n|-"
elseif filecat[filetype] == nil then
filetype = "\n!Type \n|''Error: Invalid file type[[Category:Pages with script errors]]''" .. "\n|-"
else
filetype = "\n!Type \n|''This file is missing a type. Please assign the correct type to the file.'' [[Category:Files missing type]]\n|-"
typemissing = true
end
if source ~= '' then
source = "\n!Source \n|" .. source .. "\n|-"
else
source = "\n!Source \n|''This file does not have a source. Please add the source, contact the original uploader, or upload a new version of the file.'' [[Category:Unsourced Files]]" .. "\n|-"
end
local licenselist = {
['copyright'] = "Copyright",
['public domain'] = "Public Domain",
['gfdl'] = "GFDL",
['cc by-sa'] = "CC BY-SA",
['cc by-nc-sa'] = "CC BY-NC-SA"
}
if license == '' then
license = "\n!Licensing\n|''This file is missing a license tag. Please assign the correct license tag to the file.'' [[Category:Files missing license tag]]" .. "\n|-"
elseif licenselist[license] == nil then
license = "\n!Licensing\n|\n''Error: Invalid license tag[[Category:Pages with script errors]]''" .. "\n|-"
else
license = "\n!Licensing\n|\n" .. frame:expandTemplate { title = licenselist[license] } .. "\n|-"
end
if subject ~= '' then
subject = "\n!Subject\n|" .. subject .. "\n|-"
else
subject = ''
end
if trademark ~= '' then
trademark = "\n!Trademark\n|" .. trademark .. "\n|-"
else
trademark = ''
end
if artists ~= '' and artists:lower() ~= 'unknown' and string.find(artists, ':') ~= 7 then
local Init = 0
local staffBreak = true
local artLinks = ''
while staffBreak == true do
stringEnd = string.find(artists, ',', Init)
if stringEnd ~= nil then --If there's a comma after this point, do this
artSubst = trim(string.sub(artists, Init, stringEnd - 1))
if mw.title.makeTitle(0, artSubst).redirectTarget ~= false then
pagetitle = tostring(mw.title.makeTitle(0, artSubst).redirectTarget)
artNew = "[[" .. pagetitle .. "]][[Category:Works by " .. pagetitle .. "]], "
artLinks = artLinks .. artNew
elseif mw.title.makeTitle(0, artSubst).exists == true then
artNew = "[[" .. artSubst .. "]][[Category:Works by " .. artSubst .. "]], "
artLinks = artLinks .. artNew
elseif (string.find(artSubst, '(%(.*%))', nil) ~= nil) then
artNew = string.sub(artSubst, 2, -2) .. "[[Category:Files with escaped artist names]], "
artLinks = artLinks .. artNew
else
artLinks = artLinks .. "''This file has incorrectly attributed an artist. Please add the proper attribution or correct spelling errors.''[[Category:Files with red links in artist name]]<br/>"
staffBreak = false
end
Init = stringEnd + 1
else --If there's no comma after this point, do this
artSubst = trim(string.sub(artists, Init,-1))
if mw.title.makeTitle(0, artSubst).redirectTarget ~= false then
pagetitle = tostring(mw.title.makeTitle(0, artSubst).redirectTarget)
artNew = "[[" .. pagetitle .. "]][[Category:Works by " .. pagetitle .. "]]"
artLinks = artLinks .. artNew
elseif mw.title.makeTitle(0, artSubst).exists == true then
artNew = "[[" .. artSubst .. "]][[Category:Works by " .. artSubst .. "]]"
artLinks = artLinks .. artNew
elseif (string.find(artSubst, '(%(.*%))', nil) ~= nil) then
artNew = string.sub(artSubst, 2, -2) .. "[[Category:Files with escaped artist names]]"
artLinks = artLinks .. artNew
else
artLinks = artLinks .. "''This file has incorrectly attributed an artist. Please add the proper attribution or correct spelling errors.''[[Category:Files with errors in artist name]]<br/>"
end
staffBreak = false
end
end
artOutput = "\n!Artists\n|" .. artLinks .. "\n|-"
else
if args['type']:lower() == 'artwork' or args['type']:lower() == 'illustration' then
if artists:lower() == 'unknown' then
artOutput = "\n!Artists\n|" .. "''The author of this artwork is unknown.''[[Category:Artwork with unknown authorship]]" .. "\n|-"
elseif string.find(artists, ':', 0) == 7 then
artOutput = "\n!Artists\n|" .. string.sub(artists, 9) .. "\n|-"
else
artOutput = "\n!Artists\n|" .. "''This file requires artist attribution. Please add the proper attribution.''[[Category:Files without artist attribution]]" .. "\n|-"
end
else
artOutput = ''
end
end
--This: The current addition to artLinks for this loop. artNew
--artLinks: The second column of fileinfo; includes links and categories. artLinks
--artOutput: The final output sent to the return output line. Includes the new line and header cell and encapsulates artLinks. artOutput
if media ~= '' then
--A list of codes that produce a conflict in their output (the same text as another) and what to append to the title to fix the error
local conflictResolver = {
['mt'] = {
series = " (Series)",
ova = " (OVA)"
},
['mtt'] = {
game = " (Telenet)",
},
['mt1'] = {
game = ''
},
['dds1'] = {
novel = " (Novel)"
},
['smt'] = {
series = " (Series)"
},
['smt1'] = {
game = " (Game)"
},
['smtn'] = {
game = '',
anthology = ' (Anthology)'
},
['smtsj'] = {
game = '',
anthology = ' (Anthology)'
},
['smtif'] = {
game = '',
manga = '',
novel = ' (Novel)'
},
['smt3'] = {
game = '',
drama = '',
manga = ' (Manga)'
},
['smttr'] = {
game = '',
manga = '',
ova = ' (OVA)'
},
['lb'] = {
series = ' (Series)'
},
['desum'] = {
series = ' (Series)',
game = '',
tv = ' (TV Series)'
},
['mjt'] = {
series = ' (Series)'
},
['r'] = {
game = '',
manga = ' (Manga)'
},
['p'] = {
game = ' (PSP)',
series = ' (Series)'
},
['mip'] = {
game = '',
manga = ' (Manga)'
},
['p3'] = {
game = '',
manga = ' (Manga)',
anthology = ' (Anthology)'
},
['p4'] = {
game = '',
manga = ' (Manga)'
},
['p5'] = {
game = '',
manga = ' (Manga)'
},
['p4a'] = {
game = '',
tv = '',
manga = ' (Manga)'
},
['p4au'] = {
game = '',
manga = ' (Manga)'
},
['pdn'] = {
novel = '',
manga = ' (Manga)'
},
['dc'] = {
series = ' (Series)',
manga = ' (Manga)',
anthology = ' (Anthology)'
},
['dcld'] = {
game = '',
tv = ' (TV Series)',
manga = ' (Manga)'
},
['desu'] = {
series = ' (Series)'
},
['desu1'] = {
game = '',
drama = '',
manga = ' (Manga)'
},
['desu2a'] = {
tv = '',
manga = ' (Manga)'
}
}
--MEDIA GOES HERE BUT FOR NOW WE BALL
local getLink = mw.loadData('Module:Data/Media/' .. capitalFirst(mediatype))
if mw.title.makeTitle('Module', 'Data/Media/' .. capitalFirst(mediatype) .. '/raw').exists == true then
getLinkRaw = mw.loadData('Module:Data/Media/' .. capitalFirst(mediatype) .. '/raw')
end
local link = getLink.media[media]
if getLinkRaw and getLinkRaw.media[media] and media == 'sh' or media == 'dsrk' then
link = "\n!Origin\n|[[" .. getLink.media[media] .. "|''" .. getLinkRaw.media[media] .. "'' (Series)]]" .. "\n|-"
elseif getLinkRaw and getLinkRaw.media[media] then
link = "\n!Origin\n|''[[" .. getLink.media[media] .. "|" .. getLinkRaw.media[media] .. "]]''" .. "\n|-"
else
if link:sub(-1) == ')' and mediatype == 'series' and media ~= 'mtf' then
link = "\n!Origin\n|[[" .. getLink.media[media] .. "|''" .. string.sub(link,1,string.find(link, '%(') - 2) .. "'' (Series)]]\n|-"
elseif link:sub(-1) == ')' then
link = "\n!Origin\n|[[" .. getLink.media[media] .. "|''" .. string.sub(link,1,string.find(link, '%(') - 2) .. "'' " .. string.sub(link,string.find(link, '%('),string.find(link, '%)')) .. "]]\n|-"
elseif mediatype == "short story" then
link = "\n!Origin\n|\"[[" .. link .. "]]\"\n|-"
else
link = "\n!Origin\n|''[[" .. link .. "]]''\n|-"
end
end
local categorytype = ''
if conflictResolver[media] and conflictResolver[media].mediatype ~= nil then
if typemissing == true then
category = '[[Category:' .. getLink.media[media] .. conflictResolver[media].mediatype .. " Files]]"
else
category = '[[Category:' .. getLink.media[media] .. conflictResolver[media].mediatype .. " Files]]"
categorytype = "[[Category:" .. getLink.media[media] .. conflictResolver[media].mediatype .. filecat[trim(args['type']:lower())].cattext .. "]]"
end
else
if typemissing == true then
if media == "lb1gg" then
category = '[[Category:Last Bible Game Gear Files]]'
elseif media == 'sh' or media == 'dsrk' then
category = '[[Category:' .. getLinkRaw.media[media] .. " (Series) Files]]"
elseif mediatype == 'crossover' then
category = '[[Category:' .. getLinkRaw.media[media] .. " Files]]"
else
category = '[[Category:' .. getLink.media[media] .. " Files]]"
end
else
if media == "lb1gg" then
category = '[[Category:Last Bible Game Gear Files]]'
categorytype = "[[Category:Last Bible Game Gear " .. filecat[trim(args['type']:lower())].cattext .. "]]"
elseif media == 'sh' or media == 'dsrk' then
category = '[[Category:' .. getLinkRaw.media[media] .. " (Series) Files]]"
categorytype = "[[Category:" .. getLinkRaw.media[media] .. " (Series)" .. filecat[trim(args['type']:lower())].cattext .. "]]"
elseif mediatype == 'crossover' then
category = '[[Category:' .. getLinkRaw.media[media] .. " Files]]"
categorytype = "[[Category:" .. getLinkRaw.media[media] .. filecat[trim(args['type']:lower())].cattext .. "]]"
else
category = '[[Category:' .. getLink.media[media] .. " Files]]"
categorytype = "[[Category:" .. getLink.media[media] .. filecat[trim(args['type']:lower())].cattext .. "]]"
end
end
end
local getPlat = mw.loadData('Module:Data/Media/Platform')
local platcattype = ''
if platform ~= '' then
if typemissing == true then
plat = ''
platcat = ''
else
plat = "\n!Version\n|" .. getPlat.media[platform:lower()] .. "\n|-"
platcat = '[[Category:' .. getLink.media[media] .. ' ' .. getPlat.media[platform:lower()] .. " Files]]"
platcattype = "[[Category:" .. getLink.media[media] .. ' ' .. getPlat.media[platform:lower()] .. ' ' .. filecat[trim(args['type']:lower())].cattext .. "]]"
end
else
plat = ''
platcat = ''
end
local parentCatIndex = {
['smt3nm'] = '[[Category:Shin Megami Tensei III: Nocturne Files]] [[Category:Shin Megami Tensei III: Nocturne ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['smt3ce'] = '[[Category:Shin Megami Tensei III: Nocturne Files]] [[Category:Shin Megami Tensei III: Nocturne ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['smt3hd'] = '[[Category:Shin Megami Tensei III: Nocturne Files]] [[Category:Shin Megami Tensei III: Nocturne ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['rds'] = '[[Category:Last Bible Files]] [[Category:Last Bible ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['lb1gg'] = '[[Category:Last Bible Files]] [[Category:Last Bible ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['rp'] = '[[Category:Megami Ibunroku Persona Files]] [[Category:Megami Ibunroku Persona ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['p1'] = '[[Category:Megami Ibunroku Persona Files]] [[Category:Megami Ibunroku Persona ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dcb'] = '[[Category:Devil Children Black Book and Red Book Files]] [[Category:Devil Children Black Book and Red Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dcr'] = '[[Category:Devil Children Black Book and Red Book Files]] [[Category:Devil Children Black Book and Red Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dcl'] = '[[Category:Devil Children Light Book and Dark Book Files]] [[Category:Devil Children Light Book and Dark Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dcd'] = '[[Category:Devil Children Light Book and Dark Book Files]] [[Category:Devil Children Light Book and Dark Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dkld'] = '[[Category:Devil Children Light Book and Dark Book Files]] [[Category:Devil Children Light Book and Dark Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dcf'] = '[[Category:Devil Children Fire Book and Ice Book Files]] [[Category:Devil Children Fire Book and Ice Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
['dci'] = '[[Category:Devil Children Fire Book and Ice Book Files]] [[Category:Devil Children Fire Book and Ice Book ' .. filecat[trim(args['type']:lower())].cattext .. ']]',
}
if parentCatIndex[media] and mediatype == 'game' and trim(args['type']:lower()) ~= 'wiki' then
parentCat = parentCatIndex[media]
else
parentCat = ''
end
function extrLink()
local extlink = getLink.media[media]
if getLinkRaw and getLinkRaw.media[media] and media == 'sh' or media == 'dsrk' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. getLinkRaw.media[media] .. "'' (Series)]], "
elseif getLinkRaw and getLinkRaw.media[media] then
extrlink = "''[[" .. getLink.media[media] .. "|" .. getLinkRaw.media[media] .. "]]'', "
else
if extlink:sub(-1) == ')' and media == 'mtt' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "'' (Telenet)]], "
elseif extlink:sub(-1) == ')' and media == 'dcm' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "'' (Mobile)]], "
elseif mediatype == 'series' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "'' (Series)]], "
elseif extlink:sub(-1) == ')' then
extrlink = "[[" .. getLink.media[media] .. "|" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "]]'', "
else
extrlink = "''[[" .. extlink .. "]]'', "
end
end
return extrlink
end
function extrLinkEnd()
local extlink = getLink.media[media]
if getLinkRaw and getLinkRaw.media[media] and media == 'sh' or media == 'dsrk' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. getLinkRaw.media[media] .. "'' (Series)]]"
elseif getLinkRaw and getLinkRaw.media[media] then
extrlink = "''[[" .. getLink.media[media] .. "|" .. getLinkRaw.media[media] .. "]]''"
else
if extlink:sub(-1) == ')' and media == 'mtt' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "'' (Telenet)]]"
elseif extlink:sub(-1) == ')' and media == 'dcm' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "'' (Mobile)]]"
elseif mediatype == 'series' then
extrlink = "[[" .. getLink.media[media] .. "|''" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "'' (Series)]]"
elseif extlink:sub(-1) == ')' then
extrlink = "[[" .. getLink.media[media] .. "|" .. string.sub(extlink,1,string.find(extlink, '%(') - 2) .. "]]''"
else
extrlink = "''[[" .. extlink .. "]]''"
end
end
return extrlink
end
if extrasource ~= '' then
local extracats = ''
local extrabreak = true
local Init = 0
local stringEnd = ''
local extLink2 = ''
while extrabreak == true do
stringEnd = string.find(extrasource, ',', Init)
if stringEnd ~= nil then
media = trim(string.sub(extrasource, Init, stringEnd - 1)):lower()
if media ~= '' then
if conflictResolver[media] and conflictResolver[media].mediatype ~= nil then
if typemissing == true then
newcats = '[[Category:Reused ' .. getLink.media[media] .. conflictResolver[media].mediatype .. " Files]]"
extlinkpass = extrLink()
else
newcats = '[[Category:Reused ' .. getLink.media[media] .. conflictResolver[media].mediatype .. " Files]]"
extlinkpass = extrLink()
end
elseif typemissing == true then
if media == 'sh' or media == 'dsrk' then
newcats = '[[Category:' .. getLinkRaw.media[media] .. " (Series) Files]]"
extlinkpass = extrLink()
else
newcats = '[[Category:Reused ' .. getLink.media[media] .. " Files]]"
extlinkpass = extrLink()
end
else
if media == 'sh' or media == 'dsrk' then
newcats = '[[Category:' .. getLinkRaw.media[media] .. " (Series) Files]] [[Category:" .. getLinkRaw.media[media] .. " (Series)" .. filecat[trim(args['type']:lower())].cattext .. "]]"
extlinkpass = extrLink()
else
newcats = "[[Category:Reused " .. getLink.media[media] .. " Files]]"
extlinkpass = extrLink()
end
end
else
newcats = ''
extrabreak = false
end
Init = stringEnd + 1
else -- if stringEnd isn't nil, so the break version of above
media = trim(string.sub(extrasource, Init,-1)):lower()
if media ~= '' then
if conflictResolver[media] and conflictResolver[media].mediatype ~= nil then
if typemissing == true then
newcats = '[[Category:Reused ' .. getLink.media[media] .. conflictResolver[media].mediatype .. " Files]]"
extlinkpass = extrLinkEnd()
extrabreak = false
else
newcats = '[[Category:Reused ' .. getLink.media[media] .. conflictResolver[media].mediatype .. " Files]]"
extlinkpass = extrLinkEnd()
extrabreak = false
end
elseif typemissing == true then
if media == 'sh' or media == 'dsrk' then
newcats = '[[Category:' .. getLinkRaw.media[media] .. " (Series) Files]]"
extlinkpass = extrLinkEnd()
extrabreak = false
else
newcats = '[[Category:Reused ' .. getLink.media[media] .. " Files]]"
extlinkpass = extrLinkEnd()
extrabreak = false
end
else
if media == 'sh' or media == 'dsrk' then
newcats = '[[Category:' .. getLinkRaw.media[media] .. " (Series) Files]] [[Category:" .. getLinkRaw.media[media] .. " (Series)" .. filecat[trim(args['type']:lower())].cattext .. "]]"
extlinkpass = extrLinkEnd()
extrabreak = false
else
newcats = '[[Category:Reused ' .. getLink.media[media] .. " Files]]"
extlinkpass = extrLinkEnd()
extrabreak = false
end
end
else
newcats = ''
extrabreak = false
end
end
if newcats ~= '' then
extracats = extracats .. newcats
extLink2 = extLink2 .. extlinkpass
elseif extracats == '' then
extracats = newcats
extLink2 = extlinkpass
end
end -- While extrabreak is true
extrasource = extracats
extraLinksOutput = "\n!Reused\n|" .. extLink2 .. "\n|-"
else -- If extrasource is blank
extrasource = ''
extraLinksOutput = ''
end -- If extrasource isn't blank end statement
if suppressCat ~= '' then
category = ''
end
if suppressCatType ~= '' then
categorytype = ''
end
if suppressPlat ~= '' then
platcat = ''
end
if suppressPlatType ~= '' then
platcattype = ''
end
if string.sub(mw.title.getCurrentTitle().text, 1, 2) == "MP" and filetype:find("[[Category:Wiki Images]]", 1, true) then filetype = (string.gsub(filetype, "Category:Wiki Images", "Category:Main Page Images")) end
local output = '{| class="wikitable"' .. summary .. filetype .. source .. artOutput .. link .. plat .. extraLinksOutput .. subject .. trademark .. license .. "\n|}" .. parentCat .. category .. categorytype .. platcat .. platcattype .. extrasource
return output
else
local output = '{| class="wikitable"' .. summary .. filetype .. source .. artOutput .. subject .. trademark .. license .. "\n|}[[Category:Files with no associated media]]"
return output
end
end
return p