Module:Comics/Sandbox

local p = {} local h = require("Module:HF") local standart = require("Module:StandardizedName") local m_date = require("Module:Date") local getArgs = require('Dev:Arguments').getArgs local pagetype = require("Module:PageType") local design = require("Module:Design") local SC = require("Module:StaffCorrection") local staff_info = mw.loadData("Module:Comics/Staff") local quote = require("Module:Quote")

local border_color = design.lua_getMainBorderColor local background_color = design.lua_getMainBackgroundColor

function p.main(frame) local args = getArgs (frame) local variant = args['Variant'] or '1' local appearances_and_synopses = {} local previous_issue = '' local next_issue = '' --local publisher = '' local main_image = '' --local headtitle = args['HeadTitle'] or '' local recent = '' local links_and_references = args['Links'] local category = '' local text = '' local header = '' local s = '' local i = 0 local j = 0 local body = {} local output = {} local pagename = '' local sortname = '' local main_cover = '' local main_cover_textless = '' local categories = {} local infobox = {} local stories = {} local canceled = false local released = true local issue_info = {}

if variant == '1' then table.insert(output, '') end

pagename = mw.title.getCurrentTitle.subpageText--page.text issue_info = standart.lua_get_title_volume_issue(pagename) sortname = issue_info.sortname.all main_cover = issue_info.filename.all..'.jpg' main_cover_textless = issue_info.filename.all..' Textless.jpg'

table.insert(categories, 'Comics')

-- PUBLISHER (Category:Comics by Publisher) ? change to Imprint --[[ probably no needed, because volumes are sorted into these categories.   publisher = args['Publisher']  or 'Marvel Comics' --shouldn't they all be in this category?    if not h.isempty(publisher)        then             table.insert(categories, publisher )            publisher = h.Link(publisher,publisher)    end

if string.find(pagename, ' Annual ') then table.insert(categories, 'Annuals' ) end if string.find(pagename, ' Handbook ') then table.insert(categories, 'Handbooks' ) end if string.find(pagename, ' TPB ') or string.find(pagename, ' HC ') then table.insert(categories, 'Trade Paperbacks' ) end --]] -- VOLUME category table.insert(categories, issue_info.noissue) -- HEADTITLE --headtitle = p.lua_get_headtitle(headtitle)

-- EVENTS, ARCS, STORYLINES text, category = p.lua_get_events_arcs_storylines(args) table.insert(infobox, text) categories = h.lua_concatTables(categories, category)

--MAIN IMAGE main_image, category = p.lua_get_main_cover(args['Image'], args['ImageSize'], main_cover, main_cover_textless) table.insert(infobox, main_image) table.insert(categories, category)

-- ALTERNATE COVERS table.insert(infobox, p.lua_get_alternate_covers(args, main_cover_textless, pagename) )

-- VOLUME (link) table.insert(infobox, design.infobox_line( {text = h.Link(issue_info.noissue, issue_info.noissue)..' #'..issue_info.issue } ) )

-- CANCELED if h.isempty(args['Canceled']) then canceled = false -- not canceled else canceled = true -- canceled table.insert(categories, 'Canceled Comics') end table.insert(output, p.lua_canceled_message(release_info, canceled) ) -- PUBLICATION AND RELEASE DATES release_info = m_date.lua_get_release_date_info(args['ReleaseDate']) table.insert(categories, release_info.week.text) -- ? shouldn't canceled issues be excluded from category ? released = release_info.released

publication_info, category = m_date.lua_get_publication_date_info(args['Year'], args['Month'], canceled) categories = h.lua_concatTables(categories, category) sortname = publication_info.sortdate..sortname

table.insert(infobox, p.links_to_release_publication_dates(release_info, publication_info, canceled) ) -- solicitation text, category = p.lua_solicitation(release_info, canceled) table.insert(output, text) table.insert(categories, category) -- SPOILER WARNING --if m_date.isRecent({ releasedate = release_info.date, year = publication_info.year, month = publication_info.month, canceled = canceled }) if not canceled and (release_info.recent or publication_info.recent) then recent = design.messagebox( {Message = 'Spoiler Warning! This comic has a recent publication date, thus the article below may contain spoilers! Read beyond this point at your own risk! ', background = 'rgb(255, 102, 102)', border = 'rgb(255, 20, 20)', extrastyle = 'color: white; font-weight: bold; clear: both;'}) end

-- ISSUE DETAILS text, category = p.lua_get_issue_details(args, released, canceled) table.insert(infobox, text) categories = h.lua_concatTables(categories, category)

-- COVER ARTISTS text, category = p.lua_get_cover_artists(args, released, canceled) table.insert(infobox, text) categories = h.lua_concatTables(categories, category) -- STORIES for i = 1,100 do       text, category = p.lua_get_story(args, i, pagename, released, canceled) if not text.empty or i == 1 then table.insert(stories, text) categories = h.lua_concatTables(categories, category) end end for i = 1,#stories do       if reprint and not h.isempty(stories[i].story_title) then if stories[i].story_title ~= stories[i].reprint_story_title then if not h.isempty(stories[i].reprint_story_title) then s = ' (originally printed as '..stories[i].reprint_story_title..') ' else s = ' (originally printed wothout story title) ' end else s = '' end end stories[i].story_title = p.lua_story_title(i, stories[i].story_title, stories[i].reprint_story_title)

stories[i].staff = design.story_contributors( {pagename = pagename, storytitle = stories[i].story_title, stories_n = i, body = stories[i].staff } )

if not h.isempty(stories[i].reprint_issue) then s = design.messagebox( { Message = 'This story is a reprint of the '..p.lua_ordinal_number(stories[i].reprint_story)..' story from '..standart.lua_standardized_link(stories[i].reprint_issue, 'Comics')..s,                        width = '50%' } ) else s = '' end header = design.lua_header('Appearing in '..stories[i].story_title, 2) if h.isempty(stories[i].appearances) then stories[i].appearances = header..s..'\n* Appearances not yet listed' if not stories[i].reprint and released and not canceled then table.insert(categories, 'Appearances Needed') end else stories[i].appearances = header..s..'\n'..stories[i].appearances end header = design.lua_header('Synopsis for '..stories[i].story_title, 2) if h.isempty(stories[i].synopsis) then stories[i].synopsis = header..s..'\n* Synopsis not yet written' if not stories[i].reprint and released and not canceled then table.insert(categories, 'Comic Synopsis Needed') end else stories[i].synopsis = header..s..'\n'..stories[i].synopsis end table.insert(appearances_and_synopses,stories[i].appearances..stories[i].synopsis) table.insert(infobox, stories[i].staff) end

-- PREVIOUS AND NEXT ISSUES previous_issue, next_issue = p.lua_get_previous_and_next_issues(issue_info, args['PreviousIssue'], args['NextIssue']) table.insert(infobox, design.infobox_line_horizontal({left_header = 'Previous Issue', left_text = previous_issue, right_header = 'Next Issue', right_text = next_issue}))

-- QUOTE text, category = p.lua_get_quote(args, released, canceled) --table.insert(output, text) --categories = h.lua_concatTables(categories, category) --   if released and not canceled then table.insert(output, table.concat(appearances_and_synopses) ) end -- OTHER SECTIONS table.insert(output, p.lua_add_section(args['Solicit'], 'Solicit Synopsis') ) table.insert(output, p.lua_add_section(args['Notes'], 'Notes') ) table.insert(output, p.lua_add_section(args['Trivia'], 'Trivia') ) -- SEE ALSO text, category = p.lua_get_see_also_section(pagename) table.insert(output, text) categories = h.lua_concatTables(categories, category) -- RECOMMENDED table.insert(output, p.lua_add_section(args['Recommended'], 'Recommended Reading') ) -- LINKS AND REFERENCES table.insert( output, design.lua_header('Links and References', 2)) if not h.isempty(links_and_references) then table.insert(output, '\n'..links_and_references) end table.insert(output, design.lua_header('Footnotes', 3)..'\n') --       table.insert(output, '') table.insert(output, p.lua_get_link_to_reviews(pagename) ) -- --   infobox = design.lua_createInfobox(table.concat(infobox)) categories = h.lua_create_list_of_categories(categories, sortname)

return stories[2]--recent..infobox..categories..frame:preprocess( table.concat(output) ) end

function p.lua_get_story(args, i, pagename, released, canceled) local reprint_issue = args['ReprintOf'..i]   local reprint_story = args['ReprintOfStory'..i]    local story_title = args['StoryTitle'..i] or '' local appearances = args['Appearing'..i] or '' local synopsis = args['Synopsis'..i] or '' local reprint_content = '' local reprint_story_title = '' local reprint = false local empty = true local j   local s    local category local staff = {} local staff_count = 0 local categories = {} local output if not h.isempty(reprint_issue) then reprint = true table.insert(categories, 'Reprints') reprint_issue = standart.lua_standardized_comics_name(reprint_issue) if h.isempty(reprint_story) then reprint_story = '1' table.insert(categories, 'Reprint Story Number Needed') end reprint_content = h.lua_getContent(reprint_issue) if not h.isempty(reprint_content) then reprint_story_title = h.lua_getFieldValue(reprint_content, 'StoryTitle'..reprint_story) s = h.lua_getFieldValue(reprint_content, 'Appearing'..reprint_story) appearances = p.lua_reprint_appearances(s, pagename) synopsis = h.lua_getFieldValue(reprint_content, 'Synopsis'..reprint_story) else appearances = '' synopsis = '' end end for j = 1,7 do       s = p.lua_get_list_from_args(args, staff_info[j].field..i..'_') s = p.lua_get_employees_list(j, s, reprint_content, reprint_story) if not h.isempty(s) then staff_count = staff_count + 1 end s, category = design.lua_infobox_line_staff(s, j, released, canceled) table.insert(staff, s)       categories = h.lua_concatTables(categories, category) end staff = table.concat(staff)

if p.lua_appearances_isempty(appearances) then appearances = '' end

if not h.isempty(appearances) or       not h.isempty(synopsis) or       not h.isempty(story_title) or       not h.isempty(reprint_issue) or       not h.isempty(reprint_story_title) or       staff_count > 0 then empty = false end

output = { appearances = appearances, synopsis = synopsis, story_title = story_title, reprint = reprint, reprint_issue = reprint_issue, reprint_story = reprint_story, reprint_story_title = reprint_story_title, staff = staff, empty = empty, }

return output, categories end

function p.lua_get_see_also_section(pagename) local text = '' local category = '' local categories = {} local output = {} table.insert(output, design.lua_header('See Also', 2) ) text, category = p.lua_get_link_to_subcategory(pagename, 'Image', 'from') table.insert(output, text) table.insert(categories, category)

text, category = p.lua_get_link_to_subcategory(pagename, 'Reprint', 'of') table.insert(output, text) table.insert(categories, category)

text, category = p.lua_get_link_to_subcategory(pagename, 'Review', 'of') table.insert(output, text) table.insert(categories, category) table.insert(output, '\n* Write your own review of this comic!') --table.insert(output, '\n* Discuss '..pagename..' on the forums' )

return table.concat(output), categories end

function p.lua_get_quote(args, released, canceled) local quotation = args['Quotation'] or '' local speaker = args['Speaker'] or '' local blockquote = args['BlockQuote'] or '' local reprintquote = args['ReprintQuote'] or '' local categories = {} local output = '' if released and not canceled then if not h.isempty(quotation) or not h.isempty(blockquote) or not h.isempty(reprintquote) then if not h.isempty(reprintquote) then output = quote.reprint_quote(reprintquote) elseif not h.isempty(quotation) then output = quote.quote({quote=quotation, speaker=speaker}) else output = blockquote table.insert(categories, 'BlockQuotes') end else table.insert(categories, 'Comic Quote Needed') end end return output end

function p.lua_add_section(section, header) local output = '' if not h.isempty(section) then output = design.lua_header(header, 2)..'\n'..section end return output end

function p.lua_get_list_from_args(args, field_name) local i   local s    local output = {}

for i = 1,50 do       s = args[field_name..i]        if not h.isempty(s) then table.insert(output, s)       end end return output end

function p.lua_get_list_from_args2(args, field_name) local i   local j    local s    local output = {}

for i = 1,9 do       for j = 1,50 do            s = args[field_name..i..'_'..j]            if not h.isempty(s) then table.insert(output, s)           end s = args[field_name..j]           if not h.isempty(s) then table.insert(output, s)           end end end return output end

function p.lua_get_issue_details(args, released, canceled) local i   local s    local rating local category local issue_details = {} local staff = { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, } local categories = {} local output = {} --table.insert(issue_details, { publisher, 'Publisher/Imprint' } ) table.insert(issue_details, { p.lua_get_ISBN(args['ISBN']), 'ISBN' }) table.insert(issue_details, { args['ISSN'], 'ISSN' }) table.insert(issue_details, { args['UPC'], 'UPC' } ) table.insert(issue_details, { args['Pages'], 'Pages' } ) rating, category = p.lua_get_rating(args['Rating']) table.insert(categories, category) table.insert(issue_details, { rating, 'Original rating' } ) table.insert(issue_details, { args['OriginalPrice'], 'Original price' } )

--President1_1 - President1_5 staff[9] = p.lua_get_list_from_args(args, staff_info[9].field) staff[10] = {args['CCO']} --Publisher1_1 - Publisher1_5 staff[11] = p.lua_get_list_from_args(args, staff_info[11].field) staff[12] = {args["Editor-in-Chief"]} --Production1_1 - Production1_5 staff[13] = p.lua_get_list_from_args2(args, staff_info[13].field)

for i = 9,13 do       s, category = design.lua_infobox_line_staff(p.lua_get_employees_list(i, staff[i]), i, released, canceled ) if not h.isempty(s) then table.insert(output, s)       end categories = h.lua_concatTables(categories, category) end for i = 1, #issue_details do       if not h.isempty(issue_details[i][1]) then s = design.infobox_line( { left = issue_details[i][2], right = issue_details[i][1] } ) table.insert(output, s)       end end

output = design.show_hide({               collapsed   = true,                extrastyle  = 'width:100%; margin:0px; border:none; border-top:2px solid '..border_color..'; text-align:left; font-size: 10px;',                title       = 'Production and publication details',                 body        = table.concat(output)                })

return output, categories end

function p.lua_get_ISBN(ISBN) local output = '' if not h.isempty(ISBN) then output = h.Link('Special:BookSources/'..ISBN, ISBN) end return output end

function p.lua_solicitation(release_info, canceled) local category = '' local output = '' if not release_info.released then category = 'Solicitations' if not canceled then output = design.messagebox( {Message = 'This comic will be released on '.. release_info.link, width = '50%'}) end end return output, category end function p.lua_canceled_message(release_info, canceled) local output = '' if canceled then output = design.messagebox( {Message = 'This comic will not be released. It was canceled prior to its release date, '..release_info.link, background = 'rgb(255, 102, 102)', border = 'rgb(255, 20, 20)', width = '50%', extrastyle = 'color:white;'}) end return output end

function p.lua_get_link_to_subcategory(pagename, subcategory, text) local n = 0 local page = pagename..'/'..subcategory..'s'   local s = '' local category = '' local output = ''

if subcategory == 'image' then n = h.lua_PagesInCategory(page, 'files') else n = h.lua_PagesInCategory(page) end if n > 0 then if n == 1 then s = ' '..string.lower(subcategory)..' ' else s = ' '..string.lower(subcategory)..'s ' end output = '\n* '..h.lua_link_to_category(page, i..s..text..' '..pagename) if not h.lua_isexists('Category:'..page) then category = subcategory..'s Category Needed' end end return output, category end

function p.lua_get_link_to_reviews(pagename) local n = h.lua_PagesInCategory(pagename..'/Reviews') local output = '' if n > 0 --number of reviews then output = '' end return output end

function p.lua_get_employees_list(occupation, list, reprint_content, reprint_story) local i   local s = '' local link local category local output = {} if not h.isempty(reprint_story) then reprint_story = reprint_story..'_' else reprint_story = '' end

if not h.isempty(list) then for i = 1, #list do               s = list[i] if not h.isempty(s) then link, category = SC.lua_get_staff_link_and_category(s, staff_info[occupation].category) table.insert(output, {link = link, category = category}) end end end if not h.isempty(reprint_content) then for i = 1,50 do               s = h.lua_getFieldValue(reprint_content, staff_info[occupation].field..reprint_story..i)                if not h.isempty(s) then link = SC.lua_get_staff_link_and_category(s) table.insert(output, { link = design.lua_italic(link), category = '' } ) end end end

return output end

function p.lua_get_cover_artists(args, released, canceled) local namespace = '' local content = '' local i   local s = '' local link local category local cover_artists = p.lua_get_list_from_args(args, 'CoverArtist') local reprint_cover = args['Reprint_CoverArtists'] local list = {} local categories = {} local output = {}

cover_artists = p.lua_get_employees_list('CoverArtist', cover_artists) if not h.isempty(reprint_cover) then namespace = pagetype.lua_getNamespace(reprint_cover) if namespace == 'Main' or string.find(reprint_cover, '^'..namespace..':', 1, false) ~= nil then content = h.lua_getContent(reprint_cover) else content = h.lua_getContent(namespace..':'..reprint_cover) end list = p.lua_get_employees_list('CoverArtist', _, content) table.insert(categories, 'Reprinted Cover') --? maybe create a new category for comics issues with cover reprinted from another comics end list = h.lua_concatTables(list, cover_artists) if not h.isempty(list) then output, categories = design.lua_infobox_line_staff(list, 'CoverArtist', released, canceled) end return output, categories end

-- function p.lua_get_previous_and_next_issues(issue_info, previous_issue, next_issue) local issue = tonumber(issue_info.issue) local list = {'-', '--', '---', '—', '&mdash;'} local s = ''

if h.isempty(previous_issue) then if issue ~= nil and issue > 1 then s = issue_info.noissue..' '..tostring(issue-1) previous_issue = standart.lua_standardized_link(s, 'Comics') else previous_issue = '&mdash;' end elseif h.inlist(list, previous_issue) then previous_issue = '&mdash;' else s = h.lua_breaklink(previous_issue, 1) if h.lua_isexists(s) then previous_issue = standart.lua_standardized_link(s, 'Comics') end end if h.isempty(next_issue) then if issue ~= nil then s = issue_info.noissue..' '..tostring(issue+1) next_issue = standart.lua_standardized_link(s, 'Comics') else next_issue = '&mdash;' end elseif h.inlist(list, next_issue) then next_issue = '&mdash;' else s = h.lua_breaklink(next_issue, 1) if h.lua_isexists(s) then next_issue = standart.lua_standardized_link(s, 'Comics') end end return previous_issue, next_issue end

-- function p.links_to_release_publication_dates(release_info, publication_info, canceled) local release = release_info.week.link local publication = publication_info.link local s1 = '' local s2 = '' local output = ''

if canceled then s1 = 'Intended Publication Date' s2 = 'Intended Release Date' else s1 = 'Published' s2 = 'Released' end

if not h.isempty(publication) then if not h.isempty(release) then output = design.infobox_line_horizontal({left_header = s1, left_text = publication, right_header = s2, right_text = release,  font_size_text = '12px'}) else output = design.infobox_line_horizontal({left_header=s1, left_text=publication, font_size_text = '12px'}) end elseif not h.isempty(release) then output = design.infobox_line_horizontal({left_header=s2, left_text=release, font_size_text = '12px'}) end return output end

-- function p.lua_get_main_cover(main_image, image_size, main_cover, main_cover_textless) local category = '' local output = main_image

image_size = image_size or '300px'

if h.isempty(main_image) then if h.lua_isexists('File:'..main_cover) then output = main_cover elseif h.lua_isexists('File:'..main_cover_textless) then output = main_cover_textless else output = 'No Image Cover.jpg' category = 'Cover Image Needed' end else if h.inlist( {'No Image Cover.jpg', 'Needed.png', 'Needed.jpg'}, main_image) then category = 'Cover Image Needed' elseif not h.inlist( {main_cover, main_cover_textless}, main_image) then category = 'Cover Image Correction Needed' end end output = '' return output, category end

-- function p.lua_get_headtitle(headtitle) local output = '' if not h.isempty(headtitle) then output = mw.html.create( 'div' ) :css( 'text-align', 'center' ) :css( 'font-size', '12px' ) :css( 'font-weight', 'bold' ) :css( 'line-height', '1.5em' ) :css( 'border-bottom', '2px solid '..border_color) :wikitext(headtitle) :done output = tostring(output) end return headtitle end

-- -- check if appearances section is filled only with subheaders (Featured Characters, etc.) without any actual appearances function p.lua_appearances_isempty(appearances) local s   local subheaders = { "Featured Characters:", "Supporting Characters:", "Antagonists:", "Other Characters:", "Races and Species:", "Locations:", "Items:", "Vehicles:", } local count = 0 local output = true --empty if not h.isempty(appearances) then s = mw.text.split(appearances, '\n', true) for i = 1,#s do               if h.inlist(subheaders, s[i]) or string.match(s[i], "^%*%s*$") ~= nil or string.match(s[i], "^%*%s*%s-$") ~= nil or string.match(s[i], "^%s*$") ~= nil then count = count + 1 end end if count ~= #s then output = false --not empty end end

return output end

-- --events, arcs, storylines function p.lua_get_events_arcs_storylines(args) local function part(table_links, table_names, name) local function tag_div(text) return tostring(mw.html.create( 'div' )               :css( 'text-align', 'center' )                :css( 'padding', '0.5em 0pt 0.5em 0pt' )                :css( 'font-size', '10px' )                :css( 'font-weight', 'bold' )                :css( 'line-height', '1em' )                :wikitext(text)                :done ) end local i       local t = {} local categories = {} local output = '' if not h.isempty(table_links) then for i = 1,#table_links do               if not h.isempty(table_links[i]) then table.insert(t, '"'..h.Link(table_links[i], table_names[i] or table_links[i])..'"' ) table.insert(categories, table_links[i]) end end if #t > 0 then if #t > 1 then name = name..'s'                   end output = tag_div('\nPart of the '..mw.text.listToText( t )..' '..name) end end return output, categories end local i   local events = {} local events_names = {} local arcs = {} local arcs_names = {} local storylines = {} local storylines_names = {} local text local category local categories = {} local output = {} table.insert(events, args['Event'] or '') table.insert(events_names, args['EventName'] or '') table.insert(arcs, args['StoryArc'] or '') table.insert(arcs_names, args['StoryArcName'] or '') table.insert(storylines, args['Storyline'] or '') table.insert(storylines_names, args['StorylineName'] or '') for i = 2, 9 do       table.insert(events, args['Event'..i] or '') table.insert(events_names, args['EventName'..i] or '') table.insert(arcs, args['StoryArc'..i] or '') table.insert(arcs_names, args['StoryArcName'..i] or '') table.insert(storylines, args['Storyline'..i] or '') table.insert(storylines_names, args['StorylineName'..i] or '') end text, category = part(events, events_names, 'event') table.insert(output, text) categories = h.lua_concatTables(categories, category) text, category = part(arcs, arcs_names, 'arc') table.insert(output, text) categories = h.lua_concatTables(categories, category) text, category = part(storylines, storylines_names, 'storyline') table.insert(output, text) categories = h.lua_concatTables(categories, category) return table.concat(output), categories end

-- --returns story title, story title from reprint or story number if none of them exists function p.lua_story_title(number,story_title,reprint_story_title) local ordinal_number = p.lua_ordinal_number(number) local output = '' if h.isempty(story_title) then output = reprint_story_title else output = story_title end if not h.isempty(output) then output = '"'..string.gsub(output,'"','')..'"'       else output = ordinal_number..' story'    end

return output end

-- -- return gallery of alternate covers function p.lua_get_alternate_covers(args, main_cover_textless, pagename) local i = 1 local j = 1 local s = '' local covers = {} local captions = {} local output = {} for i = 2,200 do       s = args['Image'..i]        if not h.isempty(s) then table.insert(covers, s)               table.insert(captions, args['Image'..i..'Text'] or '') end end

if (#covers == 0 or covers[1] ~= main_cover_textless) and h.lua_isexists('File:'..main_cover_textless) then table.insert(covers, 1, main_cover_textless) table.insert(captions, 1, 'Textless') end if #covers > 0 and covers[1] == main_cover_textless and ( h.isempty(captions[1]) or captions[1] ~= 'Textless' ) then captions[1] = 'Textless' end

for j = 1,#covers do       s = tostring(mw.html.create( 'div' )                :css( 'float', 'left' )                :css( 'width', '65px' )                :css( 'text-align', 'center' )                :css( 'font-size', '10px' )                :css( 'font-weight', 'bold' )                :css( 'line-height', '1.5em' )                :css( 'margin', '2px 8px' )                :wikitext(''..captions[j])                :done ) if i == 3 then s = s..' ' i = 1 else i = i + 1 end table.insert(output, s)   end if #output > 0 then output = design.show_hide({           collapsed   = true,            extrastyle  = 'width:100%; border:none; text-align:left; font-size: 10px;',            title       = 'Alternate Covers:',--h.lua_link_to_category(pagename..'/Images', 'Alternate Covers:'),             body        = table.concat(output)        }) else output = '' end return output end

-- -- get the list of appearances formed by dpl query from a comics issue and replace/move all tags to suppress all categoriztion. function p.lua_reprint_appearances(l, pagename) local j   local k    local s1    local s2    local s3    local n    list = mw.text.unstrip(l) list = mw.text.split(l,'\n') n = #list for i = 1,n do       l = list[i] l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, ,  ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, ,  ) l = mw.ustring.gsub(l, ,  ) j, k = mw.ustring.find(string.lower(l), '') s2 = mw.ustring.sub( l, k+1, i-1 ) s3 = mw.ustring.sub( l, i+2, #l ) j = mw.ustring.find(s2, ,1,true)               k = mw.ustring.find(s2, ,1,true) if j ~= nil then s2 = ..mw.ustring.sub(s2, j+2, k-1 ).. else s2 = mw.text.split( s2,"|",true ) if #s2 == 3 then s2 = ''..s2[2]..' ' elseif #s2 == 2 then s2 = s2[1]..' ' else s2 = s2[1] end end l = s1..s2..s3       end l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '', '%1 ' ) l = mw.ustring.gsub(l, '', '%1' ) l = mw.ustring.gsub(l, '(', '%2 %1}}' )       l = mw.ustring.gsub(l, ,  )        l = mw.ustring.gsub(l, ,  )        --l = mw.ustring.gsub(l, ,  )        j, k = mw.ustring.find(string.lower(l), ,1,true)        if j ~= nil             then                s1 = string.sub( l, 1, j-1 )                s2 =                 s3 = string.sub( l, k+1, #l )                l = s1..s2..s3        end           l = mw.ustring.gsub(l, '%[%[Category:.-%]%]', '' )        l = mw.ustring.gsub(l, '&lt;', '<' )        l = mw.ustring.gsub(l, '&gt;', '>' )        list[i] = '\n'..l    end    return table.concat(list) end

-- function p.lua_get_rating(rating) local category = '' local output = '' local ratings = { ['all ages'] = { 'All Ages (for all ages)', 'All Ages (for all ages)' }, ['a'] = { 'A (9 and up)', 'A (9 and up)' }, ['psr'] = { 'PSR (9 and up)', 'PSR (9 and up)' }, ['pg'] = { 'PG (9 and up)', 'PG (9 and up)' }, ['a-'] = { 'A- (9 and up)', 'A- (9 and up)' }, ['a+'] = { 'A+ (9 and up)', 'A+ (9 and up)' }, ['t'] = { 'T (13 and up)', 'T (13 and up)' }, ['teen'] = { 'Teen (13 and up)', 'T (13 and up)' }, ['psr+'] = { 'PSR+ (13 and up)', 'PSR+ (13 and up)' }, ['pg+'] = { 'PG+ (13 and up)', 'PG+ (13 and up)' }, ['t-'] = { 'T- (13 and up)', 'T- (13 and up)' }, ['t+'] = { 'T+ (13 and up)', 'T+ (13 and up)' }, ['pa'] = { 'Parental Advisory (15 and up)', 'Parental Advisory (15 and up)' }, ['parental advisory'] = { 'Parental Advisory (15 and up)', 'Parental Advisory (15 and up)' }, ['pa/ec'] = { 'Parental Advisory (15 and up)', 'PA/EC (15 and up)' }, ['explicit content'] = { 'Parental Advisory (15 and up)', 'Explicit Content (15 and up)' }, ['parental advisory/explicit content'] = { 'Parental Advisory (15 and up)', 'Parental Advisory/Explicit Content (15 and up)' }, ['mature'] = { 'MAX: Explicit Content (18 and up)', 'Mature' }, ['max'] = { 'MAX: Explicit Content (18 and up)', 'MAX: Explicit Content (18 and up)' }, ['maxx'] = { 'MAXX: Explicit Content (18 and up)', 'MAXX: Explicit Content (18 and up)' } }   if not h.isempty(rating) then output = ratings[string.lower(rating)] --or {rating, rating} if output ~= nil then category = output[1] else output = {rating, rating} end output = h.lua_link_to_category(output[1], output[2]) end return output, category end

-- --counts how many times "text" is found in the "list" function p.lua_count_inlist(list, text) local output = 0 if not h.isempty(list) and not h.isempty(text) then for i, v in ipairs( list ) do               if v == text then output = output + 1 end end end return output end

-- --returns number of "text" element in the "list" function p.lua_find_inlist(list, text) local output = 0 if not h.isempty(list) and not h.isempty(text) then for i, v in ipairs( list ) do               if v == text then output = i                       break end end end return output end

-- --transform 'number' into ordinal number, for example '1' into '1st' function p.lua_ordinal_number(number) local output = '' number = tonumber(number) if not h.isempty(number) then if number % 10 == 1 and number ~= 11 -- in (1,21,31,41,51,61,71) then output = number..'st' elseif number % 10 == 2 and number ~= 12 -- in (2,22,32,42,52,62,72) then output = number..'nd' elseif number % 10 == 3 and number ~= 13 --in (3,23,33,43,53,63,73) then output = number..'rd' else output = number..'th' end end return output end

return p