sc>FoXFTW KKeine Bearbeitungszusammenfassung |
K (1 Version importiert) |
Aktuelle Version vom 3. September 2023, 08:02 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Portfolio/Doku erstellt werden
local Portfolio = {} local metatable = {} local methodtable = {} metatable.__index = methodtable -- Extensions local infobox = require( 'Module:InfoboxNeue' ) local common = require( 'Module:Common' ) --- Creates the infobox function methodtable.getInfoBox( self ) local smwData = self:getSmwData() local title = string.format( 'Portfolio: %s', self.frameArgs[ 'Name' ] ) -- Set Title of page common.setDisplayTitle( self.currentFrame, title ) -- Add as link title = string.format( '[[%s]] - Portfolio', self.frameArgs[ 'Name' ] ) local box = infobox:new( { removeEmpty = true, } ) box:renderImage( self.frameArgs[ 'Bild' ] ) box:renderHeader( { title = title } ) box:renderSection( { title = 'Informationen', col = 2, content = { box:renderItem( 'ID', self.frameArgs[ 'ID' ] ), box:renderItem( 'Veröffentlichung', smwData[ 'Erstelldatum' ] ), } } ) box:renderSection( { title = 'Quellen', content = { box:renderItem( { label = 'Wiki Comm-Link', data = string.format( '[[Comm-Link:%s]]', self.frameArgs[ 'ID' ] ), } ), box:renderItem( { label = 'Wiki API', data = string.format( '[https://api.star-citizen.wiki/rsi/comm-links/%s API]', self.frameArgs[ 'ID' ] ), } ), box:renderItem( { label = 'Robert Space Industries', data = string.format( '[%s RSI]', smwData[ 'Quelle' ] ), } ) } } ) return tostring( box ) end -- Add the Comm-Link ID as an attribute to the page -- @return table SMW Result function methodtable.setSemanticProperties( self ) local setObj = { [ 'Comm-Link' ] = string.format( 'Comm-Link:%s', self.frameArgs[ 'ID' ] ), } return mw.smw.set( setObj ) end -- Retrieve all attributes from the Comm-Link:ID page -- @return table function methodtable.getSmwData( self ) -- Cache multiple calls if self.smwData ~= nil then return self.smwData end local data = mw.smw.ask( { '[[Comm-Link:' .. self.frameArgs[ 'ID' ] .. ']]', '?#-=page', '?Erstelldatum#-F[d.m.Y]=Erstelldatum', '?Quelle#-', 'mainlabel=-' } ) if data == nil or data[ 1 ] == nil then error( 'Kein Comm-Link mit ID "' .. self.frameArgs[ 'ID' ] .. '" gefunden.', 0 ) end self.smwData = data[ 1 ] return self.smwData end --- Set the frame and load args --- @param frame table function methodtable.setFrame( self, frame ) self.currentFrame = frame self.frameArgs = require( 'Module:Arguments' ).getArgs( frame ) end --- Template entry function Portfolio.main( frame ) local instance = Portfolio:new() instance:setFrame( frame ) instance:setSemanticProperties() return tostring( instance:getInfoBox() ) .. '[[Kategorie:Portfolio]]' end --- New Instance function Portfolio.new( self ) local instance = {} setmetatable( instance, metatable ) return instance end return Portfolio