17,230
edits
(remove OoX from staging, add TP+ST) |
m (fix image links to use the link in {{Main}}) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 20: | Line 20: | ||
end | end | ||
function buildGallery( sections ) | function buildGallery( sections, galArgs ) | ||
galArgs.widths = galArgs.widths or '62px' | |||
galArgs.heights = galArgs.heights or '62px' | |||
local gallery = Gallery.new( galArgs ) | |||
for _, section in ipairs( sections ) do | for _, section in ipairs( sections ) do | ||
-- !!!! This may break if Template:Main is modified !!!! | -- !!!! This may break if Template:Main is modified !!!! | ||
Line 46: | Line 45: | ||
end | end | ||
gallery:addFile( fileName or 'No Image.png', '[[' .. (link or section.name) .. '|' .. (fileCaption or section.name) .. ']]', { | gallery:addFile( fileName or 'No Image.png', '[[' .. (link or section.name) .. '|' .. (fileCaption or section.name) .. ']]', { | ||
link = section.name, | link = link or section.name, | ||
alt = fileCaption or section.name | alt = fileCaption or section.name | ||
} ) | } ) | ||
Line 62: | Line 61: | ||
function Galbox.new( args ) | function Galbox.new( args ) | ||
local obj = Navbox.new( args ) | local obj = Navbox.new( args ) | ||
obj.galArgs = Args.getTable( args.gallery ) | |||
return setmetatable( obj, Galbox ) | return setmetatable( obj, Galbox ) | ||
end | end | ||
Line 67: | Line 67: | ||
-- override | -- override | ||
function Galbox:renderContent() | function Galbox:renderContent() | ||
local listing = Listing._parseListing | local listing = Listing._parseListing( self.subject ) | ||
-- If categories weren't set already (because caller used single arg), then use the ones parsed from the page. | |||
-- CODE SMELL: setting unrelated state. this only works because renderFooter is called after renderContent. | |||
if #self.categories == 0 then self.categories = listing.categories end | |||
-- test if there are no sections at all | -- test if there are no sections at all | ||
Line 75: | Line 79: | ||
local defaultGallery | local defaultGallery | ||
if #listing.topLevelLeaves > 0 then | if #listing.topLevelLeaves > 0 then | ||
defaultGallery = buildGallery( listing.topLevelLeaves ) | defaultGallery = buildGallery( listing.topLevelLeaves, self.galArgs ) | ||
end | end | ||
Line 93: | Line 97: | ||
tabs:addTabTopWithContent{ | tabs:addTabTopWithContent{ | ||
contentId = group.name, | contentId = group.name, | ||
content = buildGallery( group.sections ) | content = buildGallery( group.sections, self.galArgs ) | ||
} | } | ||
end | end | ||
Line 116: | Line 120: | ||
getParent = function() return { | getParent = function() return { | ||
args = { | args = { | ||
[1] = "The Legend of Zelda | [1] = "The Legend of Zelda Characters" | ||
} | } | ||
} end | } end |