Jump to content

Module:Message box

From WhiskerWiki

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

local getArgs = require('Module:Arguments').getArgs -- for processing arguments

local p = {}


-- function to create a general message box
function p.message(frame)
    local args = getArgs(frame)
    local width = args.width or '50%'
    local message = args.message
    local image = args.image or "Mediawiki_exclamation_black.png" -- placeholder for default image

    local container = mw.html.create('div')
        :css{
            ['background-color'] = '#D0E0E5',
            ['border'] = '3px solid #000000',
            ['padding'] = '15px',
            ['font-family'] = "'Segoe UI', Arial, sans-serif",
            ['width'] = width,
            ['display'] = 'flex',
        }
    
    local imageContainer = container:tag('div')
        :css{
            ['flex'] = '0 0 5%',
            ['margin-right'] = '10px',
        }
        
    imageContainer:wikitext(string.format("[[File:%s|frameless|none|50px|alt=Placeholder image]]", image))
        
    local contentContainer = container:tag('div')
        :css{
            ['flex'] = '1',
        }
    
    contentContainer:wikitext(message)

    return tostring(container)
end





-- function for creating an infobox describing a page or section being in complete
function p.incomplete(frame)
	local args = getArgs(frame)
    local item = args.item or "page"
    local width = args.width or '50%'
    local reason = args.reason
    local admin_link = "WhiskerWiki:About"
    local image = args.image or "Mediawiki_exclamation_black.png" -- placeholder for default image

    local container = mw.html.create('div')
        :css{
            ['background-color'] = '#D0E0E5',
            ['border'] = '3px solid #000000',
            ['padding'] = '15px',
            ['font-family'] = "'Segoe UI', Arial, sans-serif",
            ['width'] = width,
            ['display'] = 'flex',
        }
    
    local imageContainer = container:tag('div')
        :css{
            ['flex'] = '0 0 5%',
            ['margin-right'] = '10px',
        }
        :wikitext(string.format("[[File:%s|frameless|none|50px|alt=Placeholder image]]", image))

        
    local contentContainer = container:tag('div')
        :css{
            ['flex'] = '1',
        }
        
    if args.reason == "references" or args.reason == "reference" then
        contentContainer:wikitext(string.format(
            "'''This %s needs supporting references!''' If you have expertise or materials on this topic that you are willing to contribute, [[WhiskerWiki:About|please get in touch with an administrator]].",
            item
        ))
    elseif args.reason == "photos" or args.reason == "photo" then
        contentContainer:wikitext(string.format(
            "'''This %s needs additional photos!''' If you have any relevant photos to contribute, [[WhiskerWiki:About|please get in touch with an administrator]].",
            item
        ))
    elseif not args.reason then
        contentContainer:wikitext(string.format(
            "'''This %s is incomplete and lacking information and resources!''' If you have any to contribute, [[WhiskerWiki:About|please get in touch with an administrator]].",
            item
        ))    
    end
    

    return tostring(container)
end


return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.