Modul:Projekt

Aus Steel Beasts Wiki

Die Dokumentation für dieses Modul kann unter Modul:Projekt/Doku erstellt werden

local p = {}

local args = require( 'Module:Arguments' )
local capiunto = require( 'Module:Infobox' )
local common = require( 'Module:Common' )

local infoBox
local categories = {
    '[[Kategorie:Projekt]]'
}

local function addLogo()
	local logo = common.getImage( {
		mw.title.getCurrentTitle().subpageText .. '_Logo',
	} )

    if logo ~= false then
        infoBox:addImage( logo, {
            [ 'alternativtext' ] = 'Logo ' .. mw.title.getCurrentTitle().subpageText,
            'rahmenlos',
            '350px'
        } )
    end
end

local function addContact()
    if args.contact then

        infoBox:addRow( 'Ansprechpartner', args.contact )
    else
        table.insert( categories, '[[Kategorie:Projekt mit fehlendem Ansprechpartner]]' )
    end
end

local function addWebsite()
    if args.website then
        if string.match( args.website, 'http' ) == nil then
            error( 'Webseite scheint kein valider Link zu sein', 0 )

            return nil
        end

        infoBox:addRow( 'Webseite', '[' .. args.website .. ' ' .. mw.title.getCurrentTitle().subpageText .. ']' )

        mw.smw.set({
            Webseite = args.website,
        })
    end
end

local function addOther()
    if args.other then
        infoBox:addRow( 'Sonstiges', args.other )
    end
end

function p.infobox( frame )
    args = args.getArgs( frame )

    infoBox = capiunto.create( {
        bodyClass = 'floatright',
    } )

    addLogo()
    infoBox:addTitle( mw.title.getCurrentTitle().subpageText )
    addContact()
    addWebsite()
    addOther()

    infoBox:addRowsFromArgs( args, '!' )
    
    common.setDisplayTitle( frame, mw.title.getCurrentTitle().subpageText )

    return tostring( infoBox ) .. table.concat( categories )
end

return p