Module:Qud look: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
m attempt to fix Qud Look header
update with modern border image. remove padding arg
 
(10 intermediate revisions by 2 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 bottomtext
local linebreaks


--[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
 
if frame.args.linebreaks == "yes" then
--[Determine border color]--
linebreaks = true
local bordercolorin = frame.args.bordercolor
else
if bordercolorin == nil then
linebreaks = false
  bordercolor = ''
end
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]--
--[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 ""
 
if linebreaks then
--[Determine body padding]--
text = colorparse.linebreaks(text)
local paddingin = frame.args.padding
end
if paddingin == nil or paddingin == '' then
  padding = '0'
else
  padding = paddingin
end


--[Determine img]--
local imgin = frame.args.image
if imgin == nil or imgin == '' then
  img = ''
else
  img = '[[File:' .. imgin .. '|32px]]'
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 = '<span style="color:white;">Perfect</span>'
elseif bottomin == 'none' then
elseif bottomin == 'none' then
  bottomtext= ''
  bottomtext = ''
else
else
  bottomtext= bottomin
  bottomtext = colorparse.parse('&Y'..bottomin, 'notxml')
end
end
 
--[Pass choices through]--
local choices = frame.args.choices
if choices == nil then
  choices = ''
end
--[parse color]--
--[parse color]--
local title
local title
local textcontent
local textcontent
local parsedbottomtext
local parsedbottomtext
if notxml == true then
        if titlein == nil or titlein == '' then
  title = colorparse.modulenonxmlparse('&y'..titlein)
        title = ''
  textcontent=colorparse.modulenonxmlparse('&y' .. text)
        else
  parsedbottomtext=colorparse.modulenonxmlparse('&Y'..bottomtext)
            title = colorparse.parse('&y'..titlein, 'notxml')
else
        end
  title = colorparse.moduleparse('&amp;y'.. titlein)
if colorparse.determinexml(text) then
  textcontent=colorparse.moduleparse('&amp;y' .. text)
        textcontent=colorparse.parse('&amp;y' .. text, 'xml')
  parsedbottomtext=colorparse.moduleparse('&amp;Y'..bottomtext)
else
end
            textcontent=colorparse.parse('&y' .. text, 'notxml')
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-look-modern-box')
    :node(mw.html.create('div')
        :addClass('qud-look-modern-title')
        :node(mw.html.create('div')
            :wikitext(img))
    :node(mw.html.create('div')
            :wikitext(title)))
    if title ~= '' then
    html:node(mw.html.create('hr'))
    end
    html
     :node(mw.html.create('div')
     :node(mw.html.create('div')
        :addClass('qud-box')
        :addClass('qud-look-modern-text')
        :node(mw.html.create('div')
        :wikitext(qudtext))
              :addClass('qud-box-header')
    if bottomtext ~= '' then
              :wikitext('<b>' .. title .. '</b>'))
        html
        :node(mw.html.create('div')
        :node(mw.html.create('div')
              :addClass('qud-box-content')
            :addClass('qud-look-modern-status')
              :css({['font-weight']='bold', ['line-height']='1.5em', ['padding']='0em' .. padding .. 'em'})
            :wikitext(bottomtext))
              :wikitext(qudtext))
    end
        :node(mw.html.create('span')
if choices ~= '' then
              :addClass('qud-box-footer-left')
html:node(mw.html.create('div')
              :wikitext(parsedbottomtext))
:wikitext(choices))
    )
end
 
return "<div style='overflow:hidden;'>" .. tostring(html) .. '</div>\n'
return tostring(html) .. '\n'
end
end


return p
return p

Latest revision as of 02:09, 3 January 2025



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

function p.qudlook(frame)

    local args
	local bordercolor
	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 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 img]--
	local imgin = frame.args.image
	if imgin == nil or imgin == '' then
  		img = ''
	else 
  		img = '[[File:' .. imgin .. '|32px]]'
	end
--[Determine bottomtext]--
	local bottomin = frame.args.bottomtext
	if bottomin == nil or bottomin == '' then
  		bottomtext = '<span style="color:white;">Perfect</span>'
	elseif bottomin == 'none' then
  		bottomtext = ''
	else
  		bottomtext = colorparse.parse('&Y'..bottomin, 'notxml')
	end
--[Pass choices through]--
	local choices = frame.args.choices
	if choices == nil then
  		choices = ''
	end
	
--[parse color]--
	local title
	local textcontent
	local parsedbottomtext
        if titlein == nil or titlein == '' then
        	title = ''
        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

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

--[Return html]--
	local html = mw.html.create('div')
	html
    	:addClass('qud-look-modern-box')
    	:node(mw.html.create('div')
        	:addClass('qud-look-modern-title')
        	:node(mw.html.create('div')
            	:wikitext(img))
    		:node(mw.html.create('div')
            	:wikitext(title)))
    if title ~= '' then
    	html:node(mw.html.create('hr'))
    end
    html
    :node(mw.html.create('div')
        :addClass('qud-look-modern-text')
        :wikitext(qudtext))
    if bottomtext ~= '' then
        html
        :node(mw.html.create('div')
            :addClass('qud-look-modern-status')
            :wikitext(bottomtext))
    end
	if choices ~= '' then
		html:node(mw.html.create('div')
			:wikitext(choices))
	end
	return "<div style='overflow:hidden;'>" .. tostring(html) .. '</div>\n'
end

return p