9
Web Gallery Plug-ins: A Tutorial Example This chapter provides a walkthrough example of how to build a Web Gallery plug-in, which uses a slightly different architecture from standard export and metadata plug-ins. This sample code produces a simple HTML gallery that shows a grid of thumbnail images, which respond to a click by showing a larger version of the clicked image. These concepts are introduced and explained in detail in Chapter 4, “Writing a Web-engine Plug-in.”
Creating a Web Gallery plug-in To begin creating the plug-in, we will create initial versions of the required files, then add code to them as we go on. 1. Create a single folder, mySamplePlugin.lrwebengine, to hold the plug-in files, in the following folder according to your operating system: ➣
In Mac OS: userhome/Library/Application Support/Adobe/Lightroom/ Web Galleries/mySamplePlugin.lrwebengine
➣
In Windows: LightroomRoot\shared\webengines\mySamplePlugin.lrwebengine
Add descriptive files 1.
In the myWebPlugin folder, create the information file that describes the plug-in, naming the file galleryInfo.lrweb. Add this initial Lua code to the file: return { LrSdkVersion = 2.0, LrSdkMinimumVersion = 2.0, -- minimum SDK version required by this plug-in title = "My Sample Plug-in", id = "com.adobe.wpg.templates.mysample", galleryType = "lua", maximumGallerySize = 50000, }
2.
In the myWebPlugin folder, create the manifest file that defines the contents of the plug-in, naming it manifest.lrweb. Include the first command, which specifies a template for a gallery page: AddGridPages { template = "grid.html", rows = 4, columns = 4, }
179