Module:Qud look: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
(Created page with "local p = {} local colorparse = require'Module:ColorParse' function p.qudlook(frame) local bordercolor local padding local bottomtext --[Determine border color]-- local bor...")
 
(make linebreaks argument actually do things)
 
(11 intermediate revisions by 3 users not shown)
Line 4: Line 4:
function p.qudlook(frame)
function p.qudlook(frame)


local bordercolor
    local args
local padding
local bordercolor
local bottomtext
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]--
--[Determine border color]--
local bordercolorin = frame.args.bordercolor
local bordercolorin = frame.args.bordercolor
if bordercolorin == nil then
if bordercolorin == nil then
  bordercolor = ''
  bordercolor = ''
elseif bordercolorin == 'c' then
elseif bordercolorin == 'c' then
  bordercolor = ''
  bordercolor = ''
elseif bordercolorin == 'y' then
elseif bordercolorin == 'y' then
  bordercolor='white-border'
  bordercolor='white-border'
else
else
  error('bordercolor not set to either "c" or "y"',0)
  error('bordercolor not set to either "c" or "y"',0)
end
end


--[Determine Title Color]--
--[Determine Title Color]--
local titlein= frame.args.title
local titlein = frame.args.title
local title = colorparse.moduleparse('&y'.. titlein)


--[Determine qud text]--
--[Determine qud text]--
local text = frame.args['text']
local text = frame.args['text'] or ""
local qudtext = frame:extensionTag{ name='poem', content=colorparse.moduleparse('&y' .. text) }
if linebreaks then
text = colorparse.linebreaks(text)
end


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


--[Determine bottomtext]--
--[Determine bottomtext]--
local bottomin = frame.args.bottomtext
local bottomin = frame.args.bottomtext
if bottomin == nil or bottomin == '' then
if bottomin == nil or bottomin == '' then
  bottomtext= 'Perfect'
  bottomtext = 'Perfect'
elseif bottomin == 'none' then
elseif bottomin == 'none' then
  bottomtext= ''
  bottomtext = ''
else
else
  bottomtext= bottomin
  bottomtext = bottomin
end
end
local a = {}
 
local parsedbottomtext=colorparse.moduleparse('&Y'..bottomtext)
--[parse color]--
local title
local textcontent
local parsedbottomtext
        if colorparse.determinexml(titlein) then
            title = colorparse.parse('&y'.. titlein, 'xml')
        else
            title = colorparse.parse('&y'..titlein, 'notxml')
        end
if colorparse.determinexml(text) then
        textcontent=colorparse.parse('&y' .. text, 'xml')
else
            textcontent=colorparse.parse('&y' .. text, 'notxml')
end
  if colorparse.determinexml(bottomtext) then
            parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'xml')
        else
      parsedbottomtext=colorparse.parse('&Y'..bottomtext, 'notxml')
end
 
local qudtext = frame:extensionTag{ name='poem', content=textcontent }


--[Return html]--
--[Return html]--
local html = {
local html = mw.html.create('div')
  '<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>'
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 table.concat(html , '\n')
return tostring(html) .. '\n'
end
end


return p
return p

Latest revision as of 02:21, 29 December 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 ""
	if linebreaks then
		text = colorparse.linebreaks(text)
	end

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