Module:RPG

local getArgs = require('Module:Arguments').getArgs local _rpgchars = mw.title.new( 'RPG/Characters', 'Module' ) local characters = mw.text.jsonDecode( _rpgchars:getContent ) local p = {}

function log2html( log, node, frame ) local chr = characters[log.user] node:attr( 'class', 'post' ) local time = node:tag('div') time:attr( 'class', 'time' ) if log.streamlinedDate then time:wikitext( os.date("%c", log.unixTimestamp) ) else time:wikitext( log.date ) end node:newline local contentContainer = node:tag('div') contentContainer:attr( 'class', 'content' ) contentContainer:newline local character = contentContainer:tag('div') character:newline local name = character:tag('div') name:attr( 'class', 'name' ) name:wikitext( chr.character_name ) character:newline local avatar = character:tag('div') avatar:attr( 'class', 'avatar' ) if chr.characterpic == nil or chr.characterpic == '' then avatar:wikitext( '' ) else avatar:wikitext( '' ) end contentContainer:newline local speech = contentContainer:tag('div') speech:attr( 'class', 'speech' ) speech:wikitext( frame:preprocess(log.content) ) end

function p.hello( frame ) local args = getArgs(frame) local _rpgdata = mw.title.new( args[1], 'Module' ) local sections = mw.text.jsonDecode( _rpgdata:getContent ) local posts = mw.html.create( 'div' ) for k,v in pairs(sections) do -- posts:wikitext( '== ' .. v.sectionName .. ' ==' ) local sectionHeader = posts:tag('h1') sectionHeader:wikitext(v.sectionName) posts:newline local node = posts:tag('div') for k2,v2 in pairs(v.posts) do			local node = posts:tag('div') log2html(v2,node,frame) posts:newline end posts:newline end return tostring(posts) end

return p