Die Dokumentation für dieses Modul kann unter Modul:Galactapedia/Doku erstellt werden
local Galactapedia = {} local metatable = {} local methodtable = {} metatable.__index = methodtable local objectData = mw.loadJsonData( 'Module:Galactapedia/data.json' ) -- Needed Extensions local common = require( 'Module:Common' ) local localized = require( 'Module:Localized' ) local TNT = require( 'Module:Translate' ):new() --- Creates the main title --- @return string function methodtable.getTitle( self ) local title = '' --[[ if self.args[ 'title' ] ~= nil then title = self.args[ 'title' ] else title = mw.title.getCurrentTitle().subpageText end]] -- Return the title text for now return localized.getMainTitle() end --- Entrypoint for {{#seo:}} --- @return void function methodtable.setSeoData( self ) -- Call to {{#seo:}} require( 'Module:SEO' ).set( 'Galactapedia', localized.getMainTitle(), table.concat({ localized.getMainTitle(), 'Galactapedia', self.frame:preprocess( '{{SITENAME}}' ) }, ' - '), 'replace', { 'Galactapedia', 'Star Citizen', 'CIG', 'Star Citizen Lore', 'Squadron 42' }, nil, self.args[ 'image' ], localized.getMainTitle() ) end --- Sets the frame and extracts the args --- @param frame table function methodtable.setFrame( self, frame ) self.frame = frame self.args = require( 'Module:Arguments' ).getArgs( frame ) end --- Get the infobox for the current article function methodtable.getInfobox( self ) local tableData = {} local box = require( 'Module:InfoboxNeue' ):new() local png, _ = mw.ustring.gsub( self.args[ 'image' ], '.jpg', '.png' ) box:renderImage( common.getImage( { self.args[ 'image' ], png } ) ) box:renderHeader( self:getTitle() ) local section = {} for _, key in ipairs( objectData.propertyOrder ) do if self.args[ key ] ~= nil then local data = { key = key, value = self.args[ key ] } local added = 0 for _, value in pairs( common.extractDataFromPrefix( key, self.args ) ) do local setValue if objectData.propertyContent[ value ] ~= nil then setValue = objectData.propertyContent[ value ] else setValue = value end added = added + 1 if added == 1 then data.value = setValue elseif added == 2 then data.value = { data.value, setValue, } elseif added > 2 then table.insert( data.value, setValue ) end end table.insert( tableData, data ) self.args[ key ] = nil end end for _, data in ipairs( tableData ) do local key = data.key local value = data.value if type( value ) ~= 'table' then value = { value } end if objectData.smwMapData[ key ] ~= nil then if key == 'dateS' then self.smwData[ objectData.smwMapData[ key ] ] = mw.text.split( table.concat( value ), '-', true ) else self.smwData[ objectData.smwMapData[ key ] ] = value end end local rowData = table.concat( value, '<br>' ) rowData = mw.text.split( rowData, ', ', true ) local success, translation = pcall( TNT.format, 'Module:Galactapedia/i18n.json', key ) if not success then translation = mw.getContentLanguage():ucfirst( key ) end table.insert( section, box:renderItem( translation, table.concat( rowData, '<br>' ) ) ) end box:renderSection( { col = 2, content = section } ) if not mw.title.getCurrentTitle().isSubpage then mw.smw.set( self.smwData ) end if self.args.related ~= nil then box:renderSection( { content = { box:renderItem( TNT.format( 'Module:Galactapedia/i18n.json', 'related_articles' ), self.args.related ) } } ) end return tostring( box ) .. tostring( table.concat( self.categories ) ) .. tostring( common.generateInterWikiLinks( self:getTitle() ) ) end --- Entry point for template calls --- @return string function Galactapedia.infoBox( frame ) local instance = Galactapedia:new() instance:setFrame( frame ) instance:setSeoData() return instance:getInfobox() end --- New Instance --- Library entrance function Galactapedia.new( self ) local instance = { frame = nil, args = nil, categories = {}, smwData = { [ 'Austritt' ] = nil, [ 'Geburtsdatum' ] = nil, [ 'Todesdatum' ] = nil, [ 'Volk' ] = nil, [ 'Hersteller' ] = nil, [ 'Beruf' ] = nil, [ 'Veröffentlichung' ] = nil, [ 'Zeitpunkt' ] = nil, [ 'Gründungsdatum' ] = nil, [ 'Ort' ] = nil, } } setmetatable( instance, metatable ) return instance end return Galactapedia