Module:Qud look: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
m (attempt to fix Qud Look header)
imported>Teamtotobot
((by SublimeText.Mediawiker))
Line 4: Line 4:
function p.qudlook(frame)
function p.qudlook(frame)


local bordercolor
local bordercolor
local padding
local padding
local bottomtext
local bottomtext


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


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


--[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


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


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


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


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


return p
return p

Revision as of 01:38, 13 November 2019


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