Module:Comics/Sandbox

local p = {} local h = require("Module:HF") local SC = require("Module:StaffCorrection") local standart = require("Module:StandardizedName") local m = require("Module:Month") local getArgs = require('Dev:Arguments').getArgs local border_color = '#B5B7CF' local background_color = '#EFF0FF' local staff_fieldname = {'Writer', 'Penciler', 'Inker', 'Colourist', 'Letterer', 'AdaptedFrom', 'Editor', 'CoverArtist', 'Editor-in-Chief', 'CCO', 'President', 'Publisher', 'Production' } local staff_link_name = {'Writers', 'Pencilers', 'Inkers', 'Colourists', 'Letterers', 'Adapted Stories', 'Editors', 'Cover Artists', 'Editors-in-Chief', 'Chief Creative Officers', 'Presidents', 'Publishers', 'Producers'} local staff_link_text = {'Writer', 'Penciler', 'Inker', 'Colourist', 'Letterer', 'Adapted from original material by', 'Editor', 'Cover Artist', 'Editor-in-Chief', 'Chief Creative Officer', 'President', 'Publisher', 'Producer'} local staff_category_name = {'Writer', 'Penciler', 'Inker', 'Colourist', 'Letterer', 'Adapted Stories', 'Editor', 'Cover Artist', 'Editor-in-Chief', 'Chief Creative Officer', 'President', 'Publisher', 'Producer'} local staff_category_needed = {true, true, true, true, true, false, true, true, true, false, false, false, false} local staff_infobox_link = {true, true, true, true, true, true, true, true, true, false, false, false, false} local page = '' local pagename = '' local sortname = '' local title = {} local title_volume = '' local main_cover = '' local main_cover_textless = '' local categories = {} local box = {} --local stories = {} local stories_n = 0 local canceled = false local released = true local published_category = '' local published_link = '' local year = '' local month = '' local season = '' local releasedate = '' local releaseweek = '' local covers = {} local captions = {} local events = {} local events_names = {} local arcs = {} local arcs_names = {} local storylines = {} local storylines_names = {}

function p.infobox(frame) local args = getArgs (frame) local reprint_title = {} local reprint_story = {} local storytitles = {} local appearances = {} local synopses = {} local appearances_and_synopses = {} local contributors = {} local staff = {} local editor_in_chief = '' local cover_artists = {} local reprint = '' --local reprints_content = {} local reprint_storytitles = {} local previous_issue = '' local next_issue = '' local details1 = {} local details2 = {} local publisher = '' local main_image = '' local cco = '' local headtitle = args['HeadTitle'] or '' local quotation = args['Quotation'] or '' local speaker = args['Speaker'] or '' local blockquote = args['BlockQuote'] or '' local reprintquote = args['ReprintQuote'] or '' local recent = '' local header = '' local s = '' local i = 0 local j = 0 local j = 0 local body = {} local categorize = true local output = {}

table.insert( output, '' )

page = mw.title.getCurrentTitle pagename = page.text title = { standart.lua_get_title_volume_issue(pagename) } title_volume = title[1]..' Vol '..title[2] sortname = standart.lua_standardized_name_for_sorting(pagename,'Comics') main_cover = title[5]..' Vol '..title[2]..' '..title[3]..'.jpg' main_cover_textless = title[5]..' Vol '..title[2]..' '..title[3]..' Textless.jpg'

table.insert(categories, 'Comics' ) -- PUBLISHER (Category:Comics by Publisher) ? change to Imprint 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, title_volume ) -- HEADTITLE if not h.isempty(headtitle) then --table.insert(box, p.lua_tag_infobox_head_div(headtitle)) table.insert(box, tostring(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 ) ) end -- EVENTS, ARCS, STORYLINES table.insert(events, args['Event']) table.insert(events_names, args['EventName']) table.insert(arcs, args['StoryArc']) table.insert(arcs_names, args['StoryArcName']) table.insert(storylines, args['Storyline']) table.insert(storylines_names, args['StorylineName']) for i = 2, 9 do       table.insert(events, args['Event'..i]) table.insert(events_names, args['EventName'..i]) table.insert(arcs, args['StoryArc'..i]) table.insert(arcs_names, args['StoryArcName'..i]) table.insert(storylines, args['Storyline'..i]) table.insert(storylines_names, args['StorylineName'..i]) end table.insert(box, p.events_arcs_storylines(events, events_names, 'event') ) table.insert(box, p.events_arcs_storylines(arcs, arcs_names, 'arc') ) table.insert(box, p.events_arcs_storylines(storylines, storylines_names, 'storyline') )

--MAIN IMAGE main_image = args['Image'] if h.isempty(main_image) then if h.lua_isexists('File:'..main_cover) then main_image = main_cover elseif h.lua_isexists('File:'..main_cover_textless) then main_image = main_cover_textless else main_image = 'No Image Cover.jpg' table.insert(categories, 'Cover Image Needed') end else if main_image ~= main_cover and main_image ~= main_cover_textless then table.insert(categories, 'Cover Image Correction Needed‎') end if main_image == 'No Image Cover.jpg' then table.insert(categories, 'Cover Image Needed') end end s = args['ImageSize'] or '300px' table.insert(box, '' ) s = '' -- ALTERNATE COVERS for i = 2,200 do       if not h.isempty(args['Image'..i]) then table.insert( covers, args['Image'..i]) table.insert( captions, args['Image'..i..'Text'] or '') end end table.insert(box, p.lua_alternate_covers )

-- VOLUME (link) table.insert(box, p.lua_infobox_line(,,h.Link(title_volume, title_volume)..' #'..title[3]) )

-- PUBLICATION AND RELEASE DATES if h.isempty(args['Canceled']) then canceled = false -- not canceled else canceled = true -- canceled table.insert(categories, 'Canceled Comics') end releasedate = args['ReleaseDate'] year = args['Year'] month = args['Month'] season = args['Season']

if not h.isempty(releasedate) then releasedate = p.lua_date_converter(releasedate, 'F j, Y') released = p.lua_date_comparison(releasedate) releaseweek = 'Week '..p.lua_date_converter(releasedate, 'W')..', '..p.lua_date_converter(releasedate, 'Y') table.insert(categories, releaseweek) end

if h.isempty(month) then if h.isempty(season) then month = '' else month = season end end

p.lua_published table.insert(box, p.links_to_release_publication_dates) -- SPOILER WARNING if p.lua_recent then recent = p.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 if not released then table.insert(categories, 'Solicitations') if not canceled then table.insert( output, p.messagebox( {Message = 'This comic will be released on '..h.Link(':Category:'..releaseweek, releasedate), width = '50%'}) ) end end if canceled then table.insert( output, p.messagebox( {Message = 'This comic will not be released. It was canceled prior to its release date, '..h.Link(':Category:'..releaseweek, releasedate), background = 'rgb(255, 102, 102)', border = 'rgb(255, 20, 20)', width = '50%', extrastyle = 'color:white;'}) ) end

for i = 1,#staff_fieldname do       table.insert( staff, {} ) end

-- ISSUE DETAILS table.insert(details1, { publisher, 'Publisher/Imprint' } ) table.insert(details1, { args['Pages'], 'Pages' } ) table.insert(details1, { args['Rating'], 'Rating' } ) table.insert(details1, { args['OriginalPrice'], 'Original Price' } ) table.insert(details1, { args['UPC'], 'UPC Number' } ) table.insert(details1, { args['ISSN'], 'ISSN' })

for i = 1, #details1 do       if not h.isempty(details1[i][1]) then if i == 3 --rating then table.insert(details2, p.lua_rating(details1[i][1]) ) else table.insert(details2, p.lua_infobox_line( details1[i][2], details1[i][1] ) ) end end end

cco = args['CCO'] if not h.isempty(cco) then table.insert(details2, p.lua_infobox_line_staff({cco}, 10, true) ) end --Production1_1 - Production1_5 --Publisher1_1 - Publisher1_5 --President1_1 - President1_5 for j = 11,13 do       for k = 1,5 do            staff[j][k] = args[staff_fieldname[j]..'1_'..k] or '' end table.insert(details2, p.lua_infobox_line_staff(staff[j], j, true) ) end

if not h.isempty( details2 ) then table.insert(box, p.show_hide({ collapsed  = true, extrastyle = 'width:100%; margin:0px; border:none; border-top:2px solid '..border_color..'; text-align:left; font-size: 10px;', title      = 'Issue Details', body       = table.concat(details2) }) )   end

-- EDITOR-IN-CHIEF editor_in_chief = args["Editor-in-Chief"] or '' if not h.isempty(editor_in_chief) then editor_in_chief = SC.Correction(editor_in_chief) table.insert(box, p.lua_infobox_line_staff({editor_in_chief}, 9, true) ) end

-- COVER ARTISTS for k = 1,50 do       s = args[staff_fieldname[8]..k] or '' if not h.isempty(s) then s = table.insert( cover_artists, s ) end end table.insert(box, p.lua_infobox_line_staff(cover_artists, 8, true) )

-- STORIES for i = 1,100 do       table.insert( reprint_title, args['ReprintOf'..i] or '' ) --if not h.isempty(reprint_title[i]) --   then table.insert( reprint_story, args['ReprintOfStory'..i] or '1' ) --end table.insert( storytitles, args['StoryTitle'..i] or '' )

if not h.isempty(reprint_title[i]) then if p.lua_count_inlist(categories, 'Reprints') == 0 then table.insert(categories, 'Reprints' ) end s = standart.lua_standardized_comics_name(reprint_title[i]) --checks if the same comics issue is reprinted several times, if it is, then its content is retrieved from the table, if not, then it returned by getContent - to prevent using getContent several times for the same comics issue --if p.lua_count_inlist(reprint_title, s)>1 --   then --       reprints_content[i] = reprints_content[p.lua_find_inlist(reprint_title, s)] --       reprint = reprints_content[i] --   else reprint = h.lua_getContent(s) --       table.insert(reprints_content, reprint) table.insert(categories, s..'/Reprints') --end if not h.isempty(reprint) then reprint_storytitles[i] = h.lua_getFieldValue(reprint, 'StoryTitle'..reprint_story[i]) for j = 1,7 do                           for k = 1,50 do                                staff[j][k] = h.lua_getFieldValue(reprint, staff_fieldname[j]..reprint_story[i]..'_'..k)                            end end appearances[i] = p.lua_reprint_appearances( h.lua_getFieldValue(reprint, 'Appearing'..reprint_story[i]), pagename ) synopses[i] = h.lua_getFieldValue( reprint, 'Synopsis'..reprint_story[i] ) categorize = false else appearances[i] = '' synopses[i] = '' end else table.insert( appearances, args['Appearing'..i] or '' ) table.insert( synopses, args['Synopsis'..i] or '' ) categorize = true for j = 1,7 do                   for k = 1,50 do                         staff[j][k] = args[staff_fieldname[j]..i..'_'..k] or '' end end end

if not h.isempty(storytitles[i]) or           not h.isempty(reprint_storytitles[i]) or           not h.isempty(reprint_title[i]) or           not h.isempty(appearances[i]) or           not h.isempty(synopses[i]) or           i == 1 then stories_n = stories_n + 1 storytitles[i] = p.lua_story_title( i, storytitles[i], reprint_storytitles[i] )

body = {} for j = 1,7 do                   table.insert(body, p.lua_infobox_line_staff(staff[j], j, categorize) ) end body = table.concat(body) contributors[i] = p.lua_story_contributors( storytitles[i], body ) if not h.isempty(reprint_title[i]) then s = p.messagebox( {                       Message = 'This story is a reprint of the '..p.lua_ordinal_number(reprint_story[i])..' story from the '..standart.lua_standardized_link(reprint_title[i], 'Comics'),                         width = '50%' } ) else s = '' end header = p.lua_header('Appearing in '..storytitles[i], 2) if h.isempty(appearances[i]) or (h.isempty(reprint_title[i]) and p.lua_appearances_isempty(appearances[i])) then appearances[i] = header..s..'\n* Appearances not yet listed' if not canceled then table.insert(categories, 'Appearances Needed') end else appearances[i] = header..s..'\n'..appearances[i] end header = p.lua_header('Synopsis for '..storytitles[i], 2) if h.isempty(synopses[i]) then synopses[i] = header..s..'\n* Synopsis not yet written' if not canceled and not h.isempty(reprint_title[i]) then table.insert(categories, 'Comic Synopsis Needed') end else synopses[i] = header..s..'\n'..synopses[i] end table.insert(appearances_and_synopses,appearances[i]..synopses[i]) table.insert(box, contributors[i]) end end

previous_issue = args['PreviousIssue'] or standart.lua_standardized_link(title_volume..' '..tonumber(title[3])-1, 'Comics') next_issue = args['NextIssue'] or standart.lua_standardized_link(title_volume..' '..tonumber(title[3])+1, 'Comics') if previous_issue == '-' or previous_issue == '--' or previous_issue == '---' or title[3] == '1' then previous_issue = '&mdash;' end if next_issue == '-' or next_issue == '--' or next_issue == '---' then next_issue = '&mdash;' end table.insert(box, p.infobox_line_horizontal({left_header = 'Previous Issue', left_text = previous_issue, right_header = 'Next Issue', right_text = next_issue}))

box = tostring( mw.html.create( 'div' )       :attr('class', 'infobox')        :css( 'width', '300px' )        :css( 'float', 'right' )        :css( 'clear', 'none' )        :css( 'margin', '0px 0px 1em 1em' )        :css( 'border', '1px solid '..border_color )        :css( 'background', background_color )        :css( 'border-radius', '10px' )        :css( 'padding', '10px' )        :wikitext(table.concat(box))        :done )

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 table.insert( output, p.reprint_quote(reprintquote)) elseif not h.isempty(quotation) then table.insert( output, p.quote({quote=quotation, speaker=speaker}) ) --else output = blockquote end else table.insert(categories, 'Comic Quote Needed') end

table.insert( output, frame:preprocess(table.concat(appearances_and_synopses)) ) end

for i = 1,#categories do       categories[i] = h.CategoryLink(categories[i], sortname) end

return recent..box..table.concat(categories)..table.concat(output) end

function p.lua_story_contributors(storytitle, text) local output = '' if not h.isempty(text) then output = p.show_hide({           collapsed   = true,            extrastyle  = 'width:100%; margin:0px; border:none; border-top:2px solid '..border_color..'; text-align:left; font-size: 10px;',            title       = h.Link(page.prefixedText..'#Appearing in '..storytitle, stories_n..'. '..storytitle),            body        = text        }) end return output end

--transform the list of contributors into infobox line with or without categorization function p.lua_infobox_line_staff(list, n, cat) local i   local name = '' local corrected = '' local job = '' local output = '' local list2 = {}

if not h.isempty(list) then if staff_infobox_link[n] == true then job = ..staff_link_text[n].. else job = staff_link_text[n] end for i = 1, #list do               v = list[i] if not h.isempty(v) then c = SC.Correction(v) if string.lower(v) == 'uncredited' or string.lower(v) == 'n/a' then list2[i] = '\nUncredited' else --list2[i] = '\n'..h.Link(c, v)--..' ' list2[i] = h.Link(c, v)..' ' if cat == true then table.insert(categories, c..'/'..staff_category_name[n]) end end end end list2 = table.concat(list2) if not h.isempty(list2) then output = p.lua_infobox_line( job, list2 ) end elseif staff_category_needed[n] and released and not canceled then table.insert(categories, staff_category_name[n]..' Needed') end return output 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 = appearances or '' s = mw.text.split(s, '\n', true) local output = 0 local empty = { "Featured Characters:", "* ", "Supporting Characters:", "* ", "Antagonists:", "* ", "Other Characters:", "* ", "Locations:", "* ", "Items:", "* ", "Vehicles:", "* " }   if #s == 14 then for i = 1, #s do               if s[i] == empty[i] then output = output + 1 end end end if output ~= 14 then output = false --not empty else output = true --empty end return output end

--takes a date and formats it according to the syntax - https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##time function p.lua_date_converter(s_date, s_format) local l = mw.language.new('en') local s = {} --1 = year, 2 = month, 3 = day local i = 0 local j = 0 local output = '' --'To comma' = 'F j, Y', "dash" = 'm-d-Y' s_format = s_format or 'Ymd'

if h.isempty(s_date) then output = l:formatDate(s_format) else i = string.find(s_date, '-',1,true) j = string.find(s_date, ', ',1,true) if i ~= nil then j = string.find(s_date, '-',i+1,true) s[2] = m.month({ string.sub(s_date, 1, i-1) }) s[3] = string.sub(s_date, i+1, j-1) if #s[3] == 1 then s[3] = '0'..s[3] end s[1] = string.sub(s_date, j+1, #s_date) output = l:formatDate(s_format, s[2]..' '..s[3]..' '..s[1]) elseif j ~= nil then s[1] = string.sub(s_date, j+2, #s_date) i = string.find(s_date, ' ',1,true) s[2] = m.month({ string.sub(s_date, 1, i-1) }) s[3] = string.sub(s_date, i+1, j-1) if #s[3] == 1 then s[3] = '0'..s[3] end output = l:formatDate(s_format, s[2]..' '..s[3]..' '..s[1]) else output = l:formatDate(s_format, s_date) end end return output end

--compares two dates. Return "true" if 1st date is before the 2nd date, and "false" otherwise. function p.lua_date_comparison(date1, date2) date1 = p.lua_date_converter(date1, 'Ymd') date2 = p.lua_date_converter(date2 or 'now', 'Ymd') --If 2nd date is ommited, then current date is used for comparison.

if date1<=date2 then return true else return false end end

--check if comics is recently released/published function p.lua_recent local current = p.lua_date_converter local output = false local s = '-4 months' local s_date = releasedate local s_month = month if not canceled then if h.isempty(s_month) then if h.isempty(season) then s_month = '1' else s_month = season end end s_month = m.month({s_month}) if h.isempty(s_date) and not h.isempty(year) then s_date = s_month..' 01 '..year s = '-2 months' end s_date = p.lua_date_converter(s_date, 'Ymd') if s_date>=mw.language.new('en'):formatDate('Ymd', s) and s_date<=current then output = true end end return output end

--returns publication category function p.lua_published local month2 = m.month({month or '1'}) --local output = ''

if not h.isempty(year) then sortname = ' '..p.lua_date_converter(month2..' '..year, 'Ymd')..sortname table.insert(categories, year) published_category = year published_link = year if not h.isempty(month) then month = m.month({month}) published_category = year..', '..month published_link = month..', '..year table.insert(categories, published_category) end table.insert(categories, p.lua_era) else table.insert(categories, 'Need Comic Dates' ) end --return output end

--returns link to date of publication category function p.lua_link_to_publication_category(year, month, season) local s = '' if h.isempty(month) and not h.isempty(season) then month = season end

if not h.isempty(year) then if not h.isempty(month) then month = m.month({month}) s = ..month..', '..year.. else s = ..year.. end end return s end

--returns era based on year function p.lua_era(t) local output = '' year = tonumber(year) if not h.isempty(year) then if h.isempty(t) then t = '' else t = ' '..t           end if year<1955 then output = 'Golden-Age'..t end if year>=1955 and year<1970 then output = 'Silver-Age'..t end if year>=1970 and year<1983 then output = 'Bronze-Age'..t end if year>=1983 and year<1992 then output = 'Copper-Age'..t end if year>=1992 then output = 'Modern-Age'..t end end return output end

function p.links_to_release_publication_dates local release = h.Link(':Category:'..releaseweek, releasedate) local published = h.Link(':Category:'..published_category, published_link) local output = '' local s1 = '' local s2 = '' if canceled then s1 = 'Intended Publication Date' s2 = 'Intended Release Date' else s1 = 'Published' s2 = 'Released' end

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

-- --events, arcs, storylines function p.events_arcs_storylines(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 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('Part of the '..mw.text.listToText( t )..' '..name) end end return output end

function p.quote(frame) local args = getArgs (frame) local quote = args[1] or args['quote'] local speaker = args[2] or args['speaker'] or '' local source = args[3] or args['source'] or '' local categorize_speaker = args[4] or args['categorize'] local source_link = '' local source_text = '' local speaker_link = '' local speaker_text = '' local left = '' local right = '' local output = ''

local tag_div = mw.html.create( 'div' ) :attr( 'class', 'quote' ) :done local tag_span = mw.html.create( 'span' ) :css( 'font-style', 'italic' ) :done

if not h.isempty(categorize_speaker) or categorize_speaker == true then categorize_speaker = true else categorize_speaker = false end

if not h.isempty(source) then source_link = h.lua_breaklink(source,1) source_text = h.lua_breaklink(source,2) end if not h.isempty(speaker) then if not h.lua_isLink(speaker) then if h.lua_isexists(speaker) then speaker_link = speaker --speaker_text = speaker --speaker = h.Link(speaker_link, speaker_text) speaker = ..speaker_link.. end end end

if not h.isempty(quote) then if not h.isempty(source_link) then output = tostring( tag_span:attr('title', 'Source: '..source_link):wikitext(quote) ) else output = tostring( tag_span:wikitext(quote) ) end output = left..'  '..output..'   '..right if not h.isempty(speaker) then output = output..'\n::--'..speaker end if not h.isempty(source_link) then output = output..' '..h.Link(source_link, '[src]')..' ' end output = tostring( tag_div:wikitext(output) ) end return output end

function p.blockquote(frame) local args = getArgs (frame) local i   local quotes = {} local speakers = {} local images = {} local output = {}

local function quote_part(qu, sp, im) local top = 50---28 local len_sp = 0 local im2 = '' local content = '' local link = '' local image_size = '75px'

if not h.isempty(im) then im2 = im           elseif h.lua_isLink(sp) then link = h.lua_breaklink(sp,1) if h.lua_isexists(link) and not h.lua_isRedirect(link) then content = h.lua_getContent( h.lua_breaklink(sp,1) ) im2 = h.lua_getFieldValue(content, 'Image') else im2 = '' end end --len_sp = string.len(sp) --if len_sp>95 --   then top = -( ( math.floor(len_sp/95)-1 )*21 )-28 --end local tag_div_arrow = mw.html.create( 'div' ) :css( 'z-index', '2' ) :css( 'position', 'relative' ) :css( 'left', '43%' ) :css( 'bottom', '22px' ) :css( 'height', '0px' ) :wikitext('') :done local tag_div_image = '' if not h.isempty(im2) then tag_div_image = tostring(mw.html.create( 'div' )               :css( 'height', image_size )                :css( 'overflow', 'hidden' )                :wikitext('')                :done ) end local tag_div_text = mw.html.create( 'div' ) :css( 'width', image_size ) :wikitext(tag_div_image..sp..tostring(tag_div_arrow)) :done local tag_td_image = mw.html.create( 'td' ) :css( 'text-align', 'center' ) :wikitext(tostring(tag_div_text)) :done local tag_td_quote = mw.html.create( 'td' ) :css( 'border', '1px solid grey' ) :css( '-moz-border-radius', '10px 10px 10px 10px' ) :wikitext( qu ) :done local tag_tr = mw.html.create( 'tr' ) :attr( 'valign', 'top' ) :wikitext( tostring(tag_td_image)..tostring(tag_td_quote) ) :done return tostring(tag_tr) end

for i = 1,20 do		if not h.isempty(args[i]) then if i % 2 == 1 then table.insert( quotes, args[i] ) else table.insert( speakers, args[i] ) end end if not h.isempty(args['Image'..i]) then table.insert( images, args['Image'..i] ) end end if not h.isempty(quotes) then for i = 1,#quotes do	           table.insert(output, quote_part(quotes[i],speakers[i],images[i]) ) end end local tag_table = mw.html.create( 'table' ) :css( 'width', '50%' ) :css( 'text-align', 'left' ) :wikitext( table.concat(output) ) :done return tostring(tag_table) end

--display a quote from the original comics without autocategorization function p.reprint_quote(source) local quotation = '' local speaker = '' local blockquote = '' local content = '' local output = '' if not h.isempty(source) then source = standart.lua_standardized_comics_name(source) content = h.lua_getContent(source) if not h.isempty(content) then quotation = h.lua_getFieldValue(content, 'Quotation') speaker = h.lua_getFieldValue(content, 'Speaker') blockquote = h.lua_getFieldValue(content, 'BlockQuote') if not h.isempty(quotation) then output = p.quote({quotation, speaker}) --else output = blockquote 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

--returns story title, story title from reprint or story number if none of them exists function p.lua_story_title(number,st,reprint_st) number = p.lua_ordinal_number(number)..' story'

if h.isempty(st) then st = reprint_st end if not h.isempty(st) then if string.sub(st,1,1) ~= '"'               then st = '"'..st..'"'            end        else            st = number    end

return st end

-- get the list of images and captions and transform them into gallery of alternate covers function p.lua_alternate_covers local i = 1 local j = 1 local s = '' local output = {}

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 ) --''..captions[j]..' ' if i == 3 then s = s..' ' i = 1 else i = i + 1 end table.insert(output, s)   end if #output > 0 then output = p.show_hide({           collapsed   = true,            extrastyle  = 'width:100%; border:none; text-align:left; font-size: 10px;',            title       = h.Link(':Category:'..page.text..'/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 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) j = mw.ustring.find(s2, ,1,true)               k = mw.ustring.find(s2, ,1,true) if j ~= nil then s2 = ..string.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_rating(rating) 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} table.insert(categories, output[1]) output = p.lua_infobox_line( 'Rating', h.Link(':Category:'..output[1], output[2]) ) end return output end

function p.show_hide(frame) local args = getArgs (frame)

local title = args['title'] or args['header'] or ' ' local body = args['body'] or args['text'] or '' local collapsed = args['collapsed'] local clear = args['clear'] or 'both' local border = args['border'] or border_color local extrastyle = args['extrastyle'] or '' local extrastyle2 = args['extrastyle2'] or '' local extrastyle3 = args['extrastyle3'] or '' local width = args['width'] or '100%' local background = args['background'] or background_color local titlestyle = args['titlestyle'] or ''

if h.isempty(collapsed) or collapsed == 'true' or collapsed == true then collapsed = ' mw-collapsed' else collapsed = '' end

local tag_td = mw.html.create( 'td' ) :css( 'margin', '0.5em' ) :css( 'font-size', '1em' ) :wikitext(body) :done if not h.isempty(extrastyle3) then tag_td:cssText (extrastyle3):done end tag_td = ' '..tostring(tag_td)..' '

local tag_div = mw.html.create( 'div' ) :css( 'font-weight', 'bold' ) :wikitext(title) :done if not h.isempty(titlestyle) then tag_div:cssText (titlestyle):done end tag_div = tostring(tag_div) local tag_th = mw.html.create( 'th' ) :attr('colspan', '1') :css( 'background-color', background ) :css( 'font-size', '1.1em' ) :wikitext(tag_div) :done if not h.isempty(extrastyle2) then tag_th:cssText (extrastyle2):done end tag_th = ' '..tostring(tag_th)..' ' local tag_table = mw.html.create( 'table' ) :addClass('mw-collapsible'..collapsed) :css( 'clear', clear ) :css( 'border', '1px solid '..border ) :css( 'font-size', '0.85em' ) :css( 'width', width ) :wikitext(tag_th..tag_td) :done if not h.isempty(extrastyle) then tag_table:cssText (extrastyle):done end return tostring(tag_table) end

function p.lua_infobox_line(left, right, text, width_l, width_r) left = left or '' right = right or '' text = text or '' width_l = width_l or '100px' width_r = width_r or '190px' local tag_l = mw.html.create( 'div' ) :css( 'width', width_l ) :css( 'text-align', 'left' ) :css( 'float', 'left' ) :wikitext(left) :done local tag_r = mw.html.create( 'div' ) :css( 'width', width_r ) :css( 'text-align', 'right' ) :css( 'float', 'left' ) :wikitext(right) :done tag_l = tostring(tag_l) tag_r = tostring(tag_r) local tag = mw.html.create( 'div' ) :css( 'border-top', '1px solid '..border_color ) :css( 'text-align', 'center' ) :css( 'clear', 'left' ) :css( 'font-size', '10px' ) :wikitext(text..tag_l..tag_r) :done return tostring(tag) end

function p.infobox_line_horizontal(frame) local args = getArgs (frame) local leftheader = args['left_header'] local lefttext = args['left_text'] or '' local rightheader = args['right_header'] or '' local righttext = args['right_text'] or '' local totalwidth = args['total_width'] local fontsize_text = args['font_size_text'] or '10px' local output = ''

if not h.isempty(righttext) then if not h.isempty(totalwidth) then totalwidth = tostring(tonumber(totalwidth)/2)..'px' else totalwidth = '50%' end else totalwidth = '100%' end

local tag_leftheader = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'font-size', '10px' ) :wikitext(leftheader) :done output = output..tostring(tag_leftheader) if not h.isempty(righttext) then local tag_rightheader = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'clear', 'right' ) :css( 'font-size', '10px' ) :wikitext(rightheader) :done output = output..tostring(tag_rightheader) end --output = output..' ' local tag_lefttext = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'clear', 'left' ) :css( 'font-size', fontsize_text ) :wikitext(lefttext) :done output = output..tostring(tag_lefttext)

if not h.isempty(righttext) then local tag_righttext = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'font-size', fontsize_text ) :css( 'text-align', 'center' ) :wikitext(righttext) :done output = output..tostring(tag_righttext) end

return tostring( mw.html.create( 'div' )       :css( 'border-top', '1px solid '..border_color )        :css( 'text-align', 'center' )        --:css( 'clear', 'left' )        :wikitext(output)        :done ) end

-- creates a header function p.lua_header(text, level) local output = '' level = level or '2' if not h.isempty(text) then output = '\n'..tostring( mw.html.create( 'h'..level ):wikitext( text ) ) end return output end

function p.messagebox(frame) local args = getArgs (frame) local width = args['width'] or '95%' local textalign = args['text-align'] or 'center' local fontsize = args['font-size'] or '100%' local border = args['border'] or border_color local background = args['background'] or background_color local margin = args['margin'] or '1em' local clear = args['clear'] or 'none' local padding = args['padding'] or '5px' local extrastyle = args['extrastyle'] or '' local message = args[1] or args['Message'] or '' local tag = mw.html.create( 'div' ) :attr( 'id', 'messageBox' ) :attr( 'align', 'center' ) :css( 'width', width ) :css( 'text-align', textalign ) :css( 'font-size', fontsize ) :css( 'border', '1px solid '..border ) :css( 'background', background ) :css( 'border-radius', '10px' ) :css( 'margin', margin ) :css( 'clear', clear ) :css( 'padding', padding ) :wikitext( message ) :done if not h.isempty(extrastyle) then tag:cssText (extrastyle):done end return tostring(tag) 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

-- forms a gallery of comics issues in specified volume based on dpl query from vloume category function p.volume(frame) local args = getArgs (frame) local l = mw.text.split(args["list"],"@@@",true) local parts = {} local above = {} local below = {} local part local a   local b    local s_page local s_image local s_title local i, j, k, f   local v    local s    local t = {} local t2 = {} local cover local textless local title = '' local volume = '' local issue = '' local padded_issue = '' local padded_volume = '' local title_for_files = '' local title_for_sorting = '' local publication_date = '' local link = '' local output = ''

for i = 1,9 do       table.insert(parts, tonumber(standart.lua_padded_issue(args['part'..i]))) table.insert(above, args['part'..i..'_above']) table.insert(below, args['part'..i..'below']) end

i = 1 while next(l,i) ~= nil do       v = mw.text.split(l[i],"*",true) i = i + 1 s_page = v[1] s_image = v[2] s_title = v[3]

publication_date = p.lua_link_to_publication_category(v[4], v[5]) title, volume, issue, padded_issue, padded_volume, title_for_files = standart.lua_get_title_volume_issue(s_page) link = standart.lua_standardized_link(s_page, 'Comics') title_for_files = title_for_files..' Vol '..volume..' '..issue cover = title_for_files..".jpg" textless = title_for_files.." Textless.jpg" if h.isempty(s_image) then if mw.title.new("File:"..cover).exists then s_image = cover elseif mw.title.new("File:"..textless).exists then s_image = textless else s_image = "No Image Cover.jpg" end end if h.isempty(s_title) then s_title = "" else s_title = ' "'..s_title..'"' end

s = padded_issue..'@@@'..s_image..'|'..link..s_title..' ('..publication_date..')\n' table.insert(t,s) end table.sort(t) part = tonumber(parts[1]) i = 1 while i <= #t do       v = mw.text.split(t[i],"@@@",true) i = i + 1 if h.isempty(part) or part == 0 then table.insert(t2, v[2]) else table.insert(t2, {v[1], v[2]}) end end

if h.isempty(part) or part == 0 then output = frame:preprocess('') --output = table.concat(t2) else t = {} k = tonumber( t2[1][1] ) f = parts[1] i = 1 if parts[#parts] < tonumber( t2[#t2][1] ) then table.insert(parts, tonumber( t2[#t2][1] ) ) end while i <=#parts do               part = tonumber(parts[i]) if h.isempty(part) or part == 0 then break else a = above[i] or '' b = below[i] or '' part = {} for j = 1, #t2 do                           if tonumber( t2[j][1] ) >= tonumber (k) and tonumber( t2[j][1] ) <= tonumber (f) then table.insert(part, t2[j][2]) end end i = i + 1 k = f+1 f = parts[i] table.insert(t, a..frame:preprocess('')..b)                       --table.insert(t, a..table.concat(part)..b)                end end output = table.concat(t) end return output end

return p