Content deleted Content added
Alistair3149 (talk | contribs) No edit summary |
Alistair3149 (talk | contribs) No edit summary |
||
Line 28: | Line 28: | ||
for _, navplateRow in ipairs( template[ 'content' ] ) do |
for _, navplateRow in ipairs( template[ 'content' ] ) do |
||
local label = navplateRow[ 'label' ] |
local label = navplateRow[ 'label' ] |
||
⚫ | |||
mw.logObject( label ) |
|||
for _, result in pairs( data ) do |
for _, result in pairs( data ) do |
||
if result[ 'Category' ] ~= nil and type( result[ 'Category' ] ) == 'table' then |
if result[ 'Category' ] ~= nil and type( result[ 'Category' ] ) == 'table' then |
||
for _, category in pairs( result[ 'Category' ] ) do |
for _, category in pairs( result[ 'Category' ] ) do |
||
if category == navplateRow[ 'conditions' ] then |
if category == navplateRow[ 'conditions' ] then |
||
if newData[ label ] == nil then |
|||
⚫ | |||
end |
|||
table.insert( newData[ label ], result.page ) |
table.insert( newData[ label ], result.page ) |
||
end |
end |
||
Line 67: | Line 68: | ||
function NavplateManufacturers.new( self, frameArgs ) |
function NavplateManufacturers.new( self, frameArgs ) |
||
local instance = { |
local instance = { |
||
category = 'Category: |
category = 'Category:Greycat Industrial' |
||
} |
} |
||
setmetatable( instance, metatable ) |
setmetatable( instance, metatable ) |
Revision as of 23:12, 5 February 2024
This documentation is transcluded from Module:Navplate/Manufacturers/doc. Changes can be proposed in the talk page.
Module:Navplate/Manufacturers is shared across the Star Citizen Wikis.
This module is shared across the Star Citizen Wikis. Any changes should also be relayed to the GitHub repository.
This module is unused.
This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add
{{Documentation}}
/{{No documentation}}
to the calling template's or parent's module documentation.Function list |
---|
local NavplateManufacturers = {}
local metatable = {}
local methodtable = {}
metatable.__index = methodtable
local navplate = require( 'Module:Navplate' )
local template = mw.loadJsonData( 'Module:Navplate/Manufacturers/data.json' );
--- Queries the SMW Store
--- @return table
--- TODO: Need a lot of clean up to make this generic
function methodtable.getSmwData( self, category )
local askData = {
'[[:+]]',
'[[' .. self.category .. ']]',
'?#-=page',
'?Category#'
}
local data = mw.smw.ask( askData )
--mw.logObject( data )
local newData = {}
for _, navplateRow in ipairs( template[ 'content' ] ) do
local label = navplateRow[ 'label' ]
for _, result in pairs( data ) do
if result[ 'Category' ] ~= nil and type( result[ 'Category' ] ) == 'table' then
for _, category in pairs( result[ 'Category' ] ) do
if category == navplateRow[ 'conditions' ] then
if newData[ label ] == nil then
newData[ label ] = {}
end
table.insert( newData[ label ], result.page )
end
end
end
end
end
mw.logObject( newData )
end
--- Outputs the table
---
--- @return string
function methodtable.make( self )
local args = {
subtitle = 'Products of',
title = 'Manufacturer'
}
local data = self:getSmwData( self.category )
-- mw.logObject( args )
return navplate.navplateTemplate({
args = args
})
end
--- New Instance
---
--- @return table NavplateManufacturers
function NavplateManufacturers.new( self, frameArgs )
local instance = {
category = 'Category:Greycat Industrial'
}
setmetatable( instance, metatable )
return instance
end
--- "Main" entry point
---
--- @param frame table Invocation frame
--- @return string
function NavplateManufacturers.main( frame )
local instance = NavplateManufacturers:new()
return instance:make()
end
return NavplateManufacturers