Module:Quote: Difference between revisions

From JCraft Wiki
Jump to navigation Jump to search
m 1 revision imported
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
-- This Module is used for making templates based in the Lua language.
local p = {}
-- See more details about Lua in [[w:Help:Lua]].
-- The Fandom Developer's Wiki hosts Global Lua Modules that can be imported and locally overridden.
-- The next line imports the Quote module from the [[w:c:dev:Global Lua Modules]].
local Quote = require('Dev:Quote')
-- See more details about this module at [[w:c:dev:Global_Lua_Modules/Quote]]


-- The last line produces the output for the template
function p.main(frame)
return Quote
    -- 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

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