<% --[[ grid.html This file displays a thumbnail grid of the images with dimensions specified in the galleryInfo.lrweb file. Define some variables to make locating other resources easier.]] local mySize = "thumb" local theRoot = "." local resolution = ""; %> <% local LrLogger = import "LrLogger" local myLogger = LrLogger("Logger") myLogger:enable("print") function LOG(message) myLogger:trace(message) end function quote(text) return text:gsub("'", "\\'") end -- Minimal reimplementation of Masonry in lua -- -- So that non Javascript viewers see something reasonable local singleMode = false local keepCentred = true local collapseBorders = true local minColumns = 1 local colW = 0 local colCount = 0 local colY = {} local wallH = 0 local posTop = 0 local posLeft = 0 local bricks = {} function getTotalWidth(width) if model.nonCSS.brick.borders then return width + model.nonCSS.brick.border else return width end end function getTotalHeight(height) if model.nonCSS.brick.borders then return height + model.nonCSS.brick.border else return height end end function masonrySetup() LOG("Initialising") colW = model.photoSizes.thumb.width if model.nonCSS.brick.borders then colW = colW + model.nonCSS.brick.border end if model.nonCSS.wall.fixedNumColumns then colCount = model.nonCSS.wall.cols else colCount = math.floor(980 / colW) ; colCount = math.max(colCount, 1, minColumns); end posLeft = 0; posTop = 0; for i=0, colCount-1 do colY[i] = posTop end LOG("colW = "..colW..", colCount = "..colCount) end function masonryArrange(width, height) width = getTotalWidth(width) height = getTotalHeight(height) LOG("width = "..width..", height="..height) colSpan = math.ceil(width / colW); colSpan = math.min(colSpan, colCount); if (colSpan == 1) then LOG("Span = 1") return placeBrick(height, colCount, colY, 1) else groupCount = colCount + 1 - colSpan groupY = {} for i=0, groupCount-1 do groupY[i] = 0 for j=0, colSpan-1 do groupY[i] = math.max(groupY[i], colY[i + j]) end end return placeBrick(height, groupCount, groupY, colSpan) end end function placeBrick(height, setCount, setY, setSpan) shortCol = 0; for i=0, setCount-1 do if setY[i] < setY[shortCol] then shortCol = i end end LOG("shortCol = "..shortCol) top = setY[shortCol] left = colW * shortCol + posLeft for i=0, setSpan-1 do colY[shortCol+i] = setY[shortCol] + height end LOG("Positionning at "..left..", "..top) return { top = top, left = left } end -- Initialise masonrySetup() %> <% --[[ Include the page header]] %> <%@ include file="header.html" %> <% menuHeight = 100 menuWidth = colW * colCount - 2 * model.nonCSS.menubar.lrpadding + model.nonCSS.brick.border %>
<% if model.nonCSS.displayIdentityPlate then pos = masonryArrange(logowidth, logoheight) if #model.nonCSS.identityPlateLink > 0 then %> <% else %> <% end %> <% end %> <% local i = 0 %> <% if i <= model.nonCSS.width then pos = masonryArrange(image.renditions.thumb.width, image.renditions.thumb.height) %> <% i = i + 1 end %>
<% --[[ Include the page footer]] %> <%@ include file="footer.html" %>