Module:Qud look

From Caves of Qud Wiki
Revision as of 20:57, 10 August 2019 by Teamtoto (talk | contribs) (can now parse notxml)
Jump to navigation Jump to search

local p = {}
local colorparse = require'Module:ColorParse'

function p.qudlook(frame)

local bordercolor
local padding
local bottomtext

--[determine notxml]--
local notxml = false
local notxmlin = frame.args.notxml
if notxmlin ~= nil then
  if notxmlin == 'yes' then
    notxml = true
  end
end

--[Determine border color]--
local bordercolorin = frame.args.bordercolor
if bordercolorin == nil then
  bordercolor = ''
elseif bordercolorin == 'c' then
  bordercolor = ''
elseif bordercolorin == 'y' then
  bordercolor='white-border'
else
  error('bordercolor not set to either "c" or "y"',0)
end

--[Determine Title Color]--
local titlein= frame.args.title

--[Determine qud text]--
local text = frame.args['text']

--[Determine body padding]--
local paddingin = frame.args.padding
if paddingin == nil or paddingin == '' then
  padding = '0'
else 
  padding = paddingin
end

--[Determine bottomtext]--
local bottomin = frame.args.bottomtext
if bottomin == nil or bottomin == '' then
  bottomtext= 'Perfect'
elseif bottomin == 'none' then
  bottomtext= ''
else
  bottomtext= bottomin
end

--[parse color]--
local title
local textcontent
local parsedbottomtext
if notxml == true then
  title = colorparse.modulenonxmlparse('&y'..titlein)
  textcontent=colorparse.modulenonxmlparse('&y' .. text)
  parsedbottomtext=colorparse.modulenonxmlparse('&Y'..bottomtext)
else
  title = colorparse.moduleparse('&y'.. titlein)
  textcontent=colorparse.moduleparse('&y' .. text)
  parsedbottomtext=colorparse.moduleparse('&Y'..bottomtext)
end

local qudtext = frame:extensionTag{ name='poem', content=textcontent }

--[Return html]--
local html = {
  '<div class="qud-box-wrapper ' ..bordercolor..'"><div class="qud-box"><span class="qud-box-header"><b>' .. title .. '</b></span><div class="qud-box-content" style="font-weight:bold; line-height:1.5em; padding:0em '..padding..'em;">'..qudtext..'</div><span class="qud-box-footer-left">'..parsedbottomtext..'</span></div></div>'
  }

return table.concat(html , '\n')
end

return p