Module:RpgPost

local rpg_post = mw.title.new( 'RpgPost/Example.json', 'Module' ) local rpg_data = mw.text.jsonDecode( rpg_post:getContent ) local p = {}

function log2html( log, node ) 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( log.user ) character:newline local avatar = character:tag('div') avatar:attr( 'class', 'avatar' ) avatar:wikitext( log.user ) contentContainer:newline local speech = contentContainer:tag('div') speech:attr( 'class', 'speech' ) speech:wikitext( log.content ) end

function p.hello( frame ) local posts = mw.html.create( 'div' ) for k,v in pairs(rpg_data) do		local node = posts:tag('div') log2html(v,node) posts:newline end return tostring(posts) end

return p