Module:Volume

-- module to form Marvel Database:Volume Template local p = {} local h = require("Module:HF") local SC = require("Module:StaffCorrection") local standart = require("Module:StandardizedName") local m_date = require("Module:Date") local getArgs = require('Dev:Arguments').getArgs

function p.getMinMaxFromList(list) local s_min local s_max if not h.isempty(list) then s_min = list[1] s_max = list[1] for i = 2,#list do               s_min = math.min(list[i], s_min) s_max = math.max(list[i], s_max) end end return s_min, s_max end

-- checks if volume title is in list of known comicc books series (for example, "Wolverine Comics Books", "Spider-Man Comics Books", etc.) function p.checkSeries local s = 'Spider-Man / Fantastic Four' local titles = { 'Fantastic Four', 'Wolverine' } local output = '' for i = 1, #titles do       mw.log(titles[i]) output = string.find(s, '.-'..titles[i]..'.-', 1, false) mw.log(output) if not h.isempty(output) then return true end end return false end

-- forms a gallery of comics issues in specified volume based on dpl query from vloume category function p.main(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 = m_date.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