Module:Dev:Quote

From JCraft Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Dev: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