[create]
The documentation for this module is missing. Click here to create it.
local p = {}
function p.main(frame)
local faqPage = frame.args.faqPage or 'MediaWiki:Custom-FAQ.json'
local questions = mw.loadJsonData(faqPage)
local container = mw.html.create('div')
for idx, faq in ipairs(questions) do
local el = container:tag('div'):attr('id', tostring(faq.id)):addClass('faq')
el:tag('div'):addClass('question')
:tag('span'):addClass('question-text'):wikitext(frame:preprocess('[[{{FULLPAGENAME}}#' .. faq.id .. '|' .. faq.question .. ']]')):done()
:done()
local answer = el:tag('div'):addClass('answer'):wikitext(faq.answer)
if faq.related ~= nil then
answer:tag('hr'):done()
local related = answer:tag('ul'):addClass('related')
if faq.related.articles ~= nil then
for i, article in ipairs(faq.related.articles) do
related:tag('li'):wikitext('[[' .. article .. ']]'):done()
end
end
if faq.related.discussions ~= nil then
for i, discussion in ipairs(faq.related.discussions) do
related:tag('li'):wikitext(frame:preprocess('[' .. tostring(mw.uri.new():parse(mw.site.scriptPath .. '/f/p/' .. discussion.p)) .. ' ' .. discussion.title .. ']')):done()
end
end
if faq.related.external ~= nil then
for i, external in ipairs(faq.related.external) do
related:tag('li'):wikitext('[' .. external.url .. ' ' .. external.title .. ']'):done()
end
end
related:done()
end
answer:done()
el:done()
end
return container:done()
end
return p