Module:Qud look: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
mNo edit summary
(autodetermine if xml or not)
Line 64: Line 64:
local textcontent
local textcontent
local parsedbottomtext
local parsedbottomtext
if notxml == true then
       
   title = colorparse.parse('&y'..titlein, 'notxml')
if colorparse.determinexml(text) then
                title = colorparse.parse('&y'.. titlein, 'xml')
  textcontent=colorparse.parse('&y' .. text, 'xml')
   parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'xml')
else
title = colorparse.parse('&y'..titlein, 'notxml')
   textcontent=colorparse.parse('&y' .. text, 'notxml')
   textcontent=colorparse.parse('&y' .. text, 'notxml')
   parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'notxml')
   parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'notxml')
else
  title = colorparse.parse('&y'.. titlein, 'xml')
  textcontent=colorparse.parse('&y' .. text, 'xml')
  parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'xml')
end
end



Revision as of 02:10, 21 July 2020


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

function p.qudlook(frame)

    local args
	local bordercolor
	local padding
	local bottomtext
	local linebreaks 

--[determine notxml]--
	local notxml = false
	local notxmlin = frame.args.notxml
	if notxmlin ~= nil then
  		if notxmlin == 'yes' then
    		notxml = true
  		end
	end
	if frame.args.linebreaks == "yes" then
		linebreaks = true
	else
		linebreaks = false
	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'] or ""

--[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 colorparse.determinexml(text) then
                title = colorparse.parse('&y'.. titlein, 'xml')
  		textcontent=colorparse.parse('&y' .. text, 'xml')
  		parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'xml')
	else
		title = colorparse.parse('&y'..titlein, 'notxml')
  		textcontent=colorparse.parse('&y' .. text, 'notxml')
  		parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'notxml')
	end

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

--[Return html]--
	local html = mw.html.create('div')
	html
    :addClass('qud-box-wrapper ' .. bordercolor)
    :node(mw.html.create('div')
        :addClass('qud-box')
    	:node(mw.html.create('div')
            :addClass('qud-box-header')
            :wikitext('<b>' .. title .. '</b>'))
        :node(mw.html.create('div')
            :addClass('qud-box-content')
            :css({['font-weight']='bold', ['line-height']='1.5em', ['padding']='0em' .. padding .. 'em'})
            :wikitext(qudtext))
        :node(mw.html.create('span')
            :addClass('qud-box-footer-left')
            :wikitext(parsedbottomtext)))

	return tostring(html) .. '\n'
end

return p