Module:InterviewArchive

local p = {}

local function generateInterview(interview, frame) local output = {} table.insert(output, ' ') table.insert(output, ' ') if interview.cover ~= '' then table.insert(output, '') else table.insert(output, '') end table.insert(output, ' ') table.insert(output, ' ') table.insert(output, ' ') table.insert(output, '') table.insert(output, ' ') table.insert(output, ' ') if interview.display then table.insert(output, frame:preprocess("")) else table.insert(output, frame:preprocess("")) end table.insert(output, ' ') table.insert(output, ' ') if interview.translation then table.insert(output, frame:preprocess('<' .. interview.translation .. ' >'))   end if interview.transcript then table.insert(output, frame:preprocess('<' .. interview.transcript .. ' >'))   end table.insert(output, frame:preprocess('<' .. interview.media .. ' >'))   table.insert(output, frame:preprocess('<' .. interview.type .. ' >'))   table.insert(output, frame:preprocess('right')) table.insert(output, ' 👤 ') for i, person in ipairs(interview.interviewee) do	 if i > 1 then table.insert(output, ", ") end table.insert(output, frame:preprocess(person)) end

table.insert(output, ' ') table.insert(output, ' 📜 ') for _, tag in ipairs(interview.tags) do       table.insert(output, frame:preprocess('<' .. tag .. ' >'))   end table.insert(output, '    ') return table.concat(output) end

-- Sanitize the JSON string -- So it can be passed to generateInterview without being interpreted as wikitext and converted into a table. function p.passThrough(interviewJson) return interviewJson end

function tableToString(t) local result = {} for k, v in pairs(t) do       table.insert(result, k .. ": " .. tostring(v)) end return table.concat(result, ", ") end

-- Export the generateInterview function so it can be used from outside the module function p.generateInterview(interviewJson, frame) mw.dumpObject(interviewJson) -- Check if interviewJson is a table or a string local interview = type(interviewJson) == 'table' and interviewJson or mw.text.jsonDecode(interviewJson) mw.dumpObject(tableToString(interview)) return generateInterview(interview, frame) end

function p.generateArchive(frame) local content = mw.loadJsonData('JoJo Wiki:Interviews').interviews local html = {' '} -- Start the div with the ID 'interview-container' for _, interview in ipairs(content) do       table.insert(html, generateInterview(interview, frame)) end

table.insert(html, ' ') -- End the div with the ID 'interview-container' return table.concat(html) end

return p