Module:KnowledgePage
From MentiSphere
More actions
Documentation for this module may be created at Module:KnowledgePage/doc
local p = {}
function p.render(frame)
local args = frame:getParent().args
local title = args.title or mw.title.getCurrentTitle().text
local domain = args.domain or 'General'
local summary = args.summary or ''
local html = mw.html.create('div')
:addClass('knowledge-infobox')
:css('border', '1px solid #c8e6c9')
:css('border-radius', '8px')
:css('padding', '16px')
:css('margin-bottom', '16px')
:css('background', '#e8f5e9')
html:tag('div')
:css('display', 'flex')
:css('justify-content', 'space-between')
:css('align-items', 'center')
:css('margin-bottom', '12px')
:tag('h2'):css('margin', '0'):wikitext(title):done()
:tag('span')
:css('background', '#4caf50')
:css('color', 'white')
:css('padding', '2px 8px')
:css('border-radius', '4px')
:css('font-size', '0.85em')
:wikitext('KNOWLEDGE')
html:tag('div')
:css('margin-bottom', '8px')
:tag('strong'):wikitext('Domain: '):done()
:wikitext('[[:Category:' .. domain .. '|' .. domain .. ']]')
if summary ~= '' then
html:tag('div')
:css('font-style', 'italic')
:css('margin-bottom', '8px')
:wikitext(summary)
end
local categoryText = '[[Category:' .. domain .. ']][[Category:Knowledge Pages]]'
return tostring(html) .. categoryText
end
return p