Module:InterviewArchive

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 02:57, 7 May 2023 by Vish (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:InterviewArchive/doc

local p = {}

local function generateInterview(interview, frame)
    local output = {}
    table.insert(output, '<div class="mnbox" id="' .. interview.title .. '">')
    table.insert(output, '<div class="ivimage" style="display:table-cell; vertical-align:top;">')
    if interview.cover ~= '' then
        table.insert(output, '[[File:' .. interview.cover .. '||90px]]')
    else
        table.insert(output, '[[File:NoPicAv.png|90px]]')
    end
    table.insert(output, '</div>')
    table.insert(output, '<div class="column">')
    table.insert(output, '<div class="diamond" style="background:{{Color|' .. interview.part .. '}}; text-align:center; padding:0.5%;">')
    table.insert(output, '<span class="fadeinimg" style="float: left; margin-left:5px;">')
    table.insert(output, '[[File:JJLSymbol.png|20px|link=#' .. interview.title .. '|Link to this section]]</span>')
    table.insert(output, "'''Interview:" .. interview.title .. "'''")
    table.insert(output, '</div>')
    table.insert(output, '<div style="padding-left:1%; font-size:90%;">')
    if interview.translation ~= nil then
        table.insert(output, '{{Tag|' .. interview.translation .. '}}')
    end
    if interview.transcript ~= nil then
        table.insert(output, '{{Tag|' .. interview.transcript .. '}}')
    end
    table.insert(output, '{{Tag|' .. interview.media .. '}}')
    table.insert(output, '{{Tag|' .. interview.type .. '}}')
    table.insert(output, '<span style="float:right;"><span class="tag">Date=' .. interview.date .. '</span></span>')
    table.insert(output, '</div>')
    table.insert(output, '<div class="interviewee" style="display:table-row;">👤 ' .. table.concat(interview.interviewee, ", ") .. '</div>')
    table.insert(output, '<div style="display:table-row;">📜 ')
    for _, tag in ipairs(interview.tags) do
        table.insert(output, '{{Tag|' .. tag .. '}}')
    end
    table.insert(output, '</div>')
    table.insert(output, '</div></div>')
    table.insert(output, '<div class="mw-collapsible mw-collapsed whitecollapse" style="padding-left:1%; text-align:center; font-size:95%;">')
    table.insert(output, frame:extensionTag{ name = 'lsth', args = { 'Interview:' .. interview.title, 'Interview' } })
    table.insert(output, '</div></div>')

    return table.concat(output)
end

function p.generateArchive(frame)
    local content = mw.loadJsonData('JoJo Wiki:Interviews').interviews
    local output = {}

    for _, interview in ipairs(content) do
        table.insert(output, generateInterview(interview))
    end

    return table.concat(output, '\n')
end

return p