Module:Quote: Difference between revisions

From JCraft Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 12: Line 12:
     local source = args.source or args[3] or ""
     local source = args.source or args[3] or ""


    -- Build the HTML wrapper styled for jcraft-eoe.com
 
     local container = mw.html.create('div')
     local container = mw.html.create('div')
     container:cssText("border-left: 4px solid #a862ea; background-color: #1e1f22; padding: 15px 20px; margin: 15px 0; border-radius: 0 8px 8px 0; box-shadow: 0 4px 15px rgba(0,0,0,0.4);")
     container:cssText("border-left: 4px solid #a862ea; background-color: #1e1f22; padding: 15px 20px; margin: 15px 0; border-radius: 0 8px 8px 0; box-shadow: 0 4px 15px rgba(0,0,0,0.4);")


    -- Add the Quote Text
 
     container:tag('div')
     container:tag('div')
         :cssText("font-style: italic; font-size: 1.1em; color: #e6e6e6;")
         :cssText("font-style: italic; font-size: 1.1em; color: #e6e6e6;")
         :wikitext(text)
         :wikitext(text)


    -- Add the Author and Source (if they were provided)
 
     if author ~= "" or source ~= "" then
     if author ~= "" or source ~= "" then
         local citation = container:tag('div')
         local citation = container:tag('div')
Line 41: Line 41:
end
end


-- Map common function names so the template doesn't get confused
 
p.quote = p.main
p.quote = p.main


return p
return p

Latest revision as of 12:22, 28 April 2026

Documentation for this module may be created at Module:Quote/doc

local p = {}

function p.main(frame)
    -- Grab the arguments passed to the template
    local args = frame:getParent().args
    if args[1] == nil and args.quote == nil and args.text == nil then
        args = frame.args
    end

    local text = args.quote or args.text or args[1] or ""
    local author = args.author or args.sign or args[2] or ""
    local source = args.source or args[3] or ""

   
    local container = mw.html.create('div')
    container:cssText("border-left: 4px solid #a862ea; background-color: #1e1f22; padding: 15px 20px; margin: 15px 0; border-radius: 0 8px 8px 0; box-shadow: 0 4px 15px rgba(0,0,0,0.4);")

  
    container:tag('div')
        :cssText("font-style: italic; font-size: 1.1em; color: #e6e6e6;")
        :wikitext(text)

  
    if author ~= "" or source ~= "" then
        local citation = container:tag('div')
            :cssText("margin-top: 10px; font-size: 0.95em; color: #bbbbbb; font-weight: 500;")
        
        if author ~= "" then
            citation:wikitext("— " .. author)
        end
        
        if source ~= "" then
            if author ~= "" then
                citation:wikitext(", ")
            end
            citation:tag('i'):wikitext(source)
        end
    end

    return tostring(container)
end


p.quote = p.main

return p