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..."
 
update with modern border image. remove padding arg
 
(14 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 bottomtext
local linebreaks


--[Determine border color]--
--[determine notxml]--
local bordercolorin = frame.args.bordercolor
local notxml = false
if bordercolorin == nil then
local notxmlin = frame.args.notxml
  bordercolor = ''
if notxmlin ~= nil then
elseif bordercolorin == 'c' then
  if notxmlin == 'yes' then
  bordercolor = ''
    notxml = true
elseif bordercolorin == 'y' then
  end
  bordercolor='white-border'
end
else
if frame.args.linebreaks == "yes" then
  error('bordercolor not set to either "c" or "y"',0)
linebreaks = true
end
else
linebreaks = false
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 img]--
local paddingin = frame.args.padding
local imgin = frame.args.image
if paddingin == nil or paddingin == '' then
if imgin == nil or imgin == '' then
  padding = '0'
  img = ''
else  
else  
  padding = paddingin
  img = '[[File:' .. imgin .. '|32px]]'
end
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


--[Determine bottomtext]--
local qudtext = frame:extensionTag{ name='poem', content=textcontent }
local bottomin = frame.args.bottomtext
if bottomin == nil or bottomin == '' then
  bottomtext= 'Perfect'
elseif bottomin == 'none' then
  bottomtext= ''
else
  bottomtext= bottomin
end
local a = {}
local parsedbottomtext=colorparse.moduleparse('&amp;Y'..bottomtext)


--[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-look-modern-box')
 
    :node(mw.html.create('div')
return table.concat(html , '\n')
        :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
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