Module:Quote

local p = {} local h = require("Module:HF") local getArgs = require('Dev:Arguments').getArgs

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

local i = 1 local j = 1 local k = 1 local s = '' local quotes = {} local speakers = {} local images = {} local output = {} local categorize = true

local function quote_part(qu, sp, im) local im2 = '' local content = '' local link = '' local image_size = '60px' local speakers_categories = {}

if not h.isempty(im) then im2 = im           elseif h.lua_isLink(sp) then link = h.lua_breaklink(sp,1) if categorize then table.insert(speakers_categories, '') end if h.lua_isexists(link) and not pagetype.lua_isRedirect(link) then content = h.lua_getContent( h.lua_breaklink(sp,1) ) im2 = h.lua_getFieldValue(content, 'Image') else im2 = '' end end

local tag_div_arrow = mw.html.create( 'div' ) :css( 'z-index', '2' ) :css( 'position', 'relative' ) :css( 'left', '47%' ) :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' ) :attr( 'valign', 'top' ) :css( 'text-align', 'center' ) :wikitext(tostring(tag_div_text)) :done local tag_div_quote = mw.html.create( 'div' ) :css( 'height', 'auto' ) :css( 'border', '1px solid grey' ) :css( '-moz-border-radius', '10px 10px 10px 10px' ) :wikitext( qu ) :done local tag_td_quote = mw.html.create( 'td' ) :attr( 'valign', 'bottom' ) :wikitext( tostring(tag_div_quote) ) :done local tag_tr = mw.html.create( 'tr' ) :wikitext( tostring(tag_td_image)..tostring(tag_td_quote) ) :done return tostring(tag_tr)..table.concat(speakers_categories) end

if type(frame) == 'table' then args = getArgs (frame) categorize = args['categorize'] or true 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 table.insert( images, args['Image'..i] or '' ) end else j = string.find(frame, '', 1, true) if j ~= nil and k ~= nil then frame = string.sub(frame, j+14, k-1)..'|' for i = 1,20 do                       j, k, s = string.find(frame, '|%s-Image'..i..'%s-=%s-(.-)|', 1, false) if j ~= nil and k ~= nil then table.insert(images, s or '') frame = string.gsub(frame, string.sub(frame, j, k-1), '') end end j = 1 i = 1 while i<#frame do                       if j % 2 == 1 then k = string.find(frame, '|', i+1, true) table.insert( quotes, string.sub(frame, i+1, k-1) ) i = k                           elseif string.find(frame, , i, true) ~= nil                                then                                    k = string.find(frame, , i, true) table.insert( speakers, string.sub(frame, i+1, k+1) ) i = k+2 else k = string.find(frame, '|', i+1, true) table.insert( speakers, string.sub(frame, i+1, k-1) ) i = k                       end j = j + 1 end else return blockquote 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) --return mw.text.listToText( images, '\n', '\n' ), mw.text.listToText( quotes, '\n', '\n' ), mw.text.listToText( speakers, '\n', '\n' ) end

--display a quote from the original comics without autocategorization function p.reprint_quote(source) local standart = require("Module:StandardizedName") 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 = p.blockquote(blockquote) end end end return output end

return p