Module:Comics

local p = {}

function p.test(frame) local l = mw.text.unstrip( frame.args[1] ) local j   local k    local i    local s1    local s2    local s3    local h = require("Module:HF")

j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) 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 l = s1..s2..s3   end return frame:preprocess(l) end

function p.test2(frame) local h = require("Module:HF") local l_covers = mw.text.split( frame.args[1],"*",true ) local l_captions = mw.text.split( frame.args[2],"*",true ) local s_page = frame.args[3] local ttt = 'Star Wars Age of Resistance Special Vol 1 1 Textless.jpg' local t = {} local l = {} local c = {} local i   local j    local s    local res = {} i = 1 j = 1 if h.isempty(s_page) == false then s_page = mw.ustring.gsub(s_page,'/',' ') s_page = mw.ustring.gsub(s_page,':',' ') s_page = frame:preprocess(s_page.." Textless.jpg") end while next(l_covers,i) ~= nil do       if h.isempty(l_covers[i]) == false then l[j] = l_covers[i] c[j] = l_captions[i] j = j + 1 end i = i + 1 end

if l[1] == s_page then t[1] = 'yes1' else t[1] = 'no1' end if l[1] == ttt then t[2] = 'yes2' else t[2] = 'no2' end if s_page == ttt then t[3] = 'yes3' else t[3] = 'no3' end return '_'..t[1]..'_'..t[2]..'_'..t[3]..'_' end

--get the list of general contributors (cover artists, editors-in-chief, etc.) function p.GeneralContributors(frame) local SC = require("Module:StaffCorrection") local h = require("Module:HF") local l = mw.text.split( frame.args[1],"*",true ) local t = frame.args[2] local cat = frame.args["category"] local link_name = frame.args["link_name"] local needed = frame.args["needed"] local t2

if t == 'Editor-in-Chief' then t2 = 'Editors-in-Chief' else t2 = t..'s'   end if h.isempty(link_name) == true then link_name = ..t.. end l = p.lua_StoryContributors(l, t, cat) if h.isempty(l) == false then return frame:preprocess( '' ) elseif cat == 'yes' and needed ~= 'no' then return '' else return '' end end

--get the list of general contributors (cover artists, editors-in-chief, etc.) function p.StoryContributors(frame) local SC = require("Module:StaffCorrection") local h = require("Module:HF") local l = mw.text.split( frame.args[1],"@",true ) local l2 = {} local t = {"Writer", "Penciler", "Inker", "Colourist", "Letterer", "Adapted Stories", "Editor"} local t2 = {} local cat = frame.args["category"] local link_name local i   local j

for i = 1,7 do       if cat == 'yes' then l2[i] = mw.text.split(l[i],"*",true ) else l[i] = l[i].."|" l2[i] = mw.text.split(l[i],"|",true ) end for j = 1,#l2[i] do           l2[i][j] = mw.text.trim(l2[i][j]) end l2[i] = p.lua_StoryContributors(l2[i], t[i], cat) if i == 6 then t2[i] = 'Adapted from original material by' else t2[i] = ..t[i].. end end

l = '' if h.isempty(table.concat(l2)) == true then return '' else for i = 1,7 do               if h.isempty(l2[i]) == false then l = l..frame:preprocess( '' ) elseif cat == 'yes' and i ~= 6 then l = l..'' end end return l   end end

--transform the list of contributors into infobox lines with or without categorization function p.lua_StoryContributors(l, t, cat) local SC = require("Module:StaffCorrection") local h = require("Module:HF") local i   local v    local c

i = 1 if h.isempty(l) == true then return '' else while next(l,i) ~= nil do               v = l[i] c = SC.Correction(v) if h.isempty(v) == false then if string.lower(v) == 'uncredited' or string.lower(v) == 'n/a' then l[i] = 'Uncredited' else l[i] = ..v.. if cat == "yes" then l[i] = l[i]..' ' else l[i] = l[i]..' ' end end end i = i + 1 end return table.concat(l) end end

-- get the list of images and captions and transform them into gallery of alternate covers function p.covers(frame) local h = require("Module:HF") local l_covers = mw.text.split( frame.args[1],"@@@",true ) local l_captions = mw.text.split( frame.args[2],"@@@",true ) local s_page = frame.args[3] local l = {} local c = {} local i   local j    local s    local res = {} i = 1 j = 1 s_page = string.gsub(s_page,'/',' ') s_page = string.gsub(s_page,':',' ') s_page = s_page.." Textless.jpg" while next(l_covers,i) ~= nil do       if h.isempty(l_covers[i]) == false then l[j] = l_covers[i] c[j] = l_captions[i] j = j + 1 end i = i + 1 end i = 1 --if l[1] ~= s_page and mw.title.new("File:"..s_page).exists == true --       then --           table.insert(l, 1, s_page) --          table.insert(c, 1, 'Textless') --   end for j=1,#l do       s = ''..c[j]..' ' if i == 3 then s = s..' ' i = 1 else i = i + 1 end table.insert(res, s)   end return table.concat(res) 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    j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) l = s1..s2..s3   end j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s2 = mw.text.split( s2,"|",true ) s2 = s2[1] s3 = string.sub( l, i+2, #l ) l = s1..s2..s3   end j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s2 = mw.text.split( s2,"|",true ) s2 = s2[1]..' ' s3 = string.sub( l, i+2, #l ) l = s1..s2..s3   end j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s2 = mw.text.split( s2,"|",true ) s2 = s2[1]..' ' s3 = string.sub( l, i+2, #l ) l = s1..s2..s3   end j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s2 = mw.text.split( s2,"|",true ) s2 = s2[1]..' ' s3 = string.sub( l, i+2, #l ) l = s1..s2..s3   end

j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) 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 l = s1..s2..s3   end j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) s2 = mw.text.split( s2,"|",true ) if #s2 == 2 then s2 = s2[1]..' ' else s2 = s2[1] end l = s1..s2..s3   end j, k = mw.ustring.find(string.lower(l), '') s2 = string.sub( l, k+1, i-1 ) s3 = string.sub( l, i+2, #l ) s2 = mw.text.split( s2,"|",true ) if #s2 == 2 then s2 = s2[1]..' ' else s2 = s2[1] end l = s1..s2..s3   end 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, '', '%1' ) --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, '', '%1 ' ) --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, '', '%1' ) --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, '', '%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, '(', '%2 %1}}' )   --j, k = mw.ustring.find(l, '{{.-|')    --if j ~= nil     --    and string.lower( string.sub( l, j, k ) ) ~= '{{g|'     --    and string.lower( string.sub( l, j, k ) ) ~= '{{green|'     --    and string.lower( string.sub( l, j, k ) ) ~= '{{c|'    --    and string.lower( string.sub( l, j, k ) ) ~= '{{r|'    --    then l = mw.ustring.gsub(l, '(', '%2 %1}}' ) --end l = mw.ustring.gsub(l, '{{chronology}}', '{{g|See chronology}}' ) l = mw.ustring.gsub(l, '{{Chronology}}', '{{g|See chronology}}' ) l = mw.ustring.gsub(l, '{{chronoFB}}', '{{g|Appears in flashback}}' ) l = mw.ustring.gsub(l, '{{ChronoFB}}', '{{g|Appears in flashback}}' ) --l = mw.ustring.gsub(l, ,  ) l = mw.ustring.gsub(l, '%[%[Category:.-%]%]', '' ) l = mw.ustring.gsub(l, '&lt;', '<' ) l = mw.ustring.gsub(l, '&gt;', '>' ) return l end

function p.reprint_appearances(frame) local l = mw.text.unstrip( frame.args[1] ) local pagename = frame.args[2] local h = require("Module:HF") local j   local k    l = mw.text.split(l,'\n') --for i,v in ipairs(l) do   for i = 1,#l do        --j,k = mw.ustring.find(l[i], ']]}} and {{[[', 1, true) --if h.isempty(j) == false --   then --       j = p.lua_reprint_appearances( mw.ustring.sub(l[i], 1, j+4) ) --       k = p.lua_reprint_appearances( mw.ustring.sub(l[i], k-4, #l[i]) ) --       l[i] = j..' and '..k        --   else l[i] = '\n'..p.lua_reprint_appearances(l[i], pagename) --end end return frame:preprocess( table.concat(l) ) end

-- forms a gallery of comics issues in specified volume based on dpl query from vloume category function p.volume(frame) local monthData = mw.loadData( 'Module:Month/data' ) local monthAliases = monthData[1] local l = mw.text.split(frame.args["list"],"@@@",true) local parts = { frame.args["part1"], frame.args["part2"], frame.args["part3"], frame.args["part4"], frame.args["part5"], frame.args["part6"], frame.args["part7"], frame.args["part8"], frame.args["part9"]} local above = { frame.args["part1_above"], frame.args["part2_above"], frame.args["part3_above"], frame.args["part4_above"], frame.args["part5_above"], frame.args["part6_above"], frame.args["part7_above"], frame.args["part8_above"], frame.args["part9_above"] } local below = { frame.args["part1_below"], frame.args["part2_below"], frame.args["part3_below"], frame.args["part4_below"], frame.args["part5_below"], frame.args["part6_below"], frame.args["part7_below"], frame.args["part8_below"], frame.args["part9_below"] } local part local a   local b    local s_page local s_image local s_title local s_year local s_month local s_volume local s_issue local i = 1 local v   local s    local t = {} local t2 = {} local cover local textless local j   local k    local e

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] s_year = v[4] s_month = monthAliases[string.lower( v[5] )] or v[5] s = s_page s = string.gsub(s,'/',' ') s = string.gsub(s,':',' ') cover = s..".jpg" textless = s.." Textless.jpg" if s_image == nil or s_image == "" then if mw.title.new("File:"..cover).exists == true then s_image = cover elseif mw.title.new("File:"..textless).exists == true then s_image = textless else s_image = "No Image Cover.jpg" end end if s_title == nil or s_title == "" then s_title = "" else s_title = ' "'..s_title..'"' end

e,j,k = string.find(s_page," Vol (%d+) ") s_volume = string.sub(s_page, 1, e)       s_issue = string.sub(s_page, j+1, string.len(s_page)) if tonumber(k) == 1 then s = ""..s_volume.." #"..s_issue.."" else s = ""..s_volume.." Vol "..k.." #"..s_issue.."" end j = string.find(s_issue,"-",1,true) -- -1 issues k = string.find(s_issue,".",1,true) -- point one issues if j == nil then if k ~= nil then s_issue = string.sub(s_issue,1,k-1).."9" s_issue = string.rep("0", 10-#s_issue)..s_issue else s_issue = s_issue.."0" s_issue = string.rep("0", 10-#s_issue)..s_issue end end s = s_issue..'@@@'..s_image..'{{!}}'....s_page..'{{!}}'..s....s_title..' (Category:'..s_year..', '..s_month..'{{!}}'..s_month..' ,'..s_year..')\n' table.insert(t,s) end table.sort(t) i = 1 while i <= #t do       v = mw.text.split(t[i],"@@@",true) i = i + 1 s = v[2] table.insert(t2,s) end

if tonumber(parts[1]) == nil or tonumber(parts[1]) == 0 then return frame:preprocess('{{#tag:gallery|'..table.concat(t2)..'|position=center|captionalign=center|hideaddbutton=true}}') else t = {} i = 1 while i <=#parts do               if i == 1 then j = 1 else j = parts[i-1]+1 end part = tonumber(parts[i]) if part == nil or part == 0 then break else a = above[i] b = below[i] i = i + 1 if part>#t2 then part = #t2 end table.insert(t, a..frame:preprocess('{{#tag:gallery|'..table.concat(t2,"",j,part)..'|position=center|captionalign=center|hideaddbutton=true}}')..b)               end end return table.concat(t) end end

return p