{"id":11162,"date":"2006-07-21T11:29:20","date_gmt":"2006-07-21T11:29:20","guid":{"rendered":"http:\/\/blogs.adobe.com\/jnackdev\/2006\/07\/next-gen-web-galleries-xslt-flash-css-for-all.html"},"modified":"2006-07-21T11:29:20","modified_gmt":"2006-07-21T11:29:20","slug":"next_gen_web_galleries_xslt_flash_css_for","status":"publish","type":"post","link":"http:\/\/jnack.com\/blog\/2006\/07\/21\/next_gen_web_galleries_xslt_flash_css_for\/","title":{"rendered":"Next-gen Web galleries: XSLT, Flash, &amp; CSS for all"},"content":{"rendered":"<p>As you might have heard in <a href=\"http:\/\/blogs.adobe.com\/jnack\/2006\/07\/lightroom_podcast_9.html\">Lightroom Podcast #9<\/a> (starting around the 25-minute mark), we&#8217;re working on a fresh, new Web Photo Gallery engine for Lightroom.  For those wanting to dig under the hood and start creating or modifying galleries, Adobe engineer Andy Rahn has created an overview, which I&#8217;ve included in this post&#8217;s <a href=\"http:\/\/blogs.adobe.com\/jnack\/2006\/07\/nextgen_web_galleries.html#more\">extended entry<\/a>.<\/p>\n<p>We think this new engine provides a great foundation for the future, and while we really can&#8217;t comment on upcoming products, we&#8217;d like to see the engine make its way to, ah, other applications (<i>something something, rhymes with &#8220;Shmoatoshop&#8221;&#8230;<\/i>).  So, with any luck, the time you spend working with this new engine will end up being broadly applicable down the road (no promises, of course).<\/p>\n<p><!--more--><\/p>\n<hr \/>\n<p><b>A quick introduction to Lightroom Web Module templates.<\/b><br \/>\n[By Andy Rahn]<\/p>\n<p>\nLightroom web module supports templates which allow designers to create new web photo galleries which can be previewed live inside of Lightroom.  Lightroom actually supports two kinds of templates: Flash templates, and HTML templates.  In this article, I&#8217;m going to focus on HTML templates.<\/p>\n<p>\nThe HTML templates are composed of a number of parts:<\/p>\n<ul>\n<li> A galleryMaker.xml file which describes the appearance of the side panel for the template, lists the sizes of images needed, and defines variables which are used by the template to build the output files.\n<li> A transformer.xslt file which converts an internal XML representation of the web gallery into the resulting HTML, dynamic CSS or other output files.\n<li> Other collateral files, such as icons or CSS files.<\/ul>\n<p>\nIn this blog entry, I&#8217;ll take you through a quick tour of the capabilities of this system by example.  At the bottom of this page is a link to a ZIP file containing the example template.  The gallery system utilizes XSLT as the language for creating the HTML, so you should be somewhat familiar with that programming language to get the most out of the example.  Several good XSLT tutorials are available on the internet: <a href=\"http:\/\/www.w3schools.com\/xsl\/\">[W3Schools]<\/a>, <a href=\"http:\/\/www.zvon.org\/xxl\/XSLTutorial\/Books\/Book1\/index.html\">[ZVON.org]<\/a><\/p>\n<p><h3>The Gallery Maker File<\/h3>\n<p>\nThe gallery maker file has basically three sections in it:<\/p>\n<ul>\n<li> Information about the template, including its name and who created.  This is stored in the galleryInfo section.\n<li> Definitions of variables that can be used to connect information that the user types in the panels into the XSLT transform.  For example, the &#8220;site title&#8221; is stored in a variable.\n<li> A description of the right hand &#8220;Custom Settings&#8221; and &#8220;Image Settings&#8221; panels.<\/ul>\n<p>\nHere is the example file.  Note: This file is contained in the ZIP file (link at the end of the article).  If you want to build it yourself, you can copy and paste this into a text editor and save it with the name &#8216;galleryMaker.xml&#8217; in a new empty folder called DemoTemplate.  (Note: TextEdit defaults to &#8220;rich text&#8221; format.  To save it so that Lightroom can read the resulting file, follow these steps: 1) Copy the text below 2) Switch to TextEdit and create a new document 3) Paste 4) Choose &#8220;Make Plain Text&#8221; from the Format menu 5) Save as&#8230;, choosing &#8220;Unicode (UTF-8)&#8221; from the &#8220;Plain Text Encoding&#8221; popup menu. )<\/p>\n<p><pre>\n&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;galleryMaker xmlns:ag=\"http:\/\/ns.adobe.com\/silver\/1.0\"&gt;\n&lt;galleryInfo&gt;\n&lt;amg ver=\"0.5\" \/&gt;\n&lt;thumbnail path=\"preview.jpg\" \/&gt;\n&lt;galleryName&gt;Demo Template&lt;\/galleryName&gt;\n&lt;galleryDescription&gt;&lt;\/galleryDescription&gt;\n&lt;gallerVersion ver=\"1.0\" \/&gt;\n&lt;livePreview enabled=\"yes\" \/&gt;\n&lt;creator company=\"Adobe Systems, Inc.\" designer=\"Adobe Lightroom Engineering\" \/&gt;\n&lt;category&gt;Web photo gallery&lt;\/category&gt;\n&lt;identifier&gt;com.adobe.wpg.demo1t&lt;\/identifier&gt;\n&lt;ag:galleryType&gt;HTML&lt;\/ag:galleryType&gt;\n&lt;ag:maximumGallerySize&gt;20&lt;\/ag:maximumGallerySize&gt;\n&lt;\/galleryInfo&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;ag:compatabilty&gt;\n&lt;ag:id&gt;com.adobe.lightroom.default2&lt;\/ag:id&gt;\n&lt;\/ag:compatabilty&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;ag:perImage&gt;\n&lt;description heightInLines=\"3\" title=\"Caption\" \/&gt;\n&lt;\/ag:perImage&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;sizes&gt;\n&lt;size height=\"130\" name=\"thumb\" width=\"130\" \/&gt;\n&lt;\/sizes&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;mx:Application xmlns:mx=\"http:\/\/www.macromedia.com\/2005\/mxml\"&gt;\n&lt;mx:Model id=\"metadata\"&gt;\n&lt;siteInfo&gt;\n&lt;title ag:liveUpdateTarget=\"#liveUpdateSiteTitle\"&gt;Site Title&lt;\/title&gt;\n&lt;\/siteInfo&gt;\n&lt;\/mx:Model&gt;\n&lt;mx:Model id=\"appearance\"&gt;\n&lt;body&gt;\n&lt;cssID&gt;body&lt;\/cssID&gt;\n&lt;background-color&gt;#4c4c4c&lt;\/background-color&gt;\n&lt;\/body&gt;\n&lt;\/mx:Model&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;mx:VBox ag:layout=\"fill_horizontal=1,\"&gt;\n&lt;mx:HBox ag:layout=\"fill_horizontal=1,\"&gt;\n&lt;mx:Label text=\"Site Title\" \/&gt;\n&lt;\/mx:HBox&gt;\n&lt;mx:HBox ag:layout=\"fill_horizontal=1,\"&gt;\n&lt;mx:TextInput ag:layout=\"fill_horizontal=1,width=1,\" id=\"siteTitle\" \/&gt;\n&lt;\/mx:HBox&gt;\n&lt;\/mx:VBox&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;mx:Binding destination=\"appearance.siteTitle.color\" source=\"foregroundColor.selectedColor\" \/&gt;\n&lt;mx:Binding destination=\"foregroundColor.selectedColor\" source=\"appearance.siteTitle.color\" \/&gt;\n&lt;mx:Binding destination=\"metadata.siteInfo.title\" source=\"siteTitle.text\" \/&gt;\n&lt;mx:Binding destination=\"siteTitle.text\" source=\"metadata.siteInfo.title\" \/&gt;\n&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;\n&lt;\/mx:Application&gt;\n&lt;\/galleryMaker&gt;\n<\/pre>\n<p><h3>transformer.xslt<\/h3>\n<p>\nThe transformer XSLT file transforms an intermediate XML format into the HTML files for the gallery.  It should be called transformer.xslt and be saved on disk next to the galleryMaker.xml file.<\/p>\n<p>\nTo get started, here is a very simple transformer.xslt that simply writes the intermediate XML format out to disk.  (The final version of this file is in the ZIP file attachment below, or you can copy and paste using the same steps as above.):<\/p>\n<p><pre>\n&lt;?xml version=\"1.0\"?&gt;\n&lt;xsl:stylesheet\nversion=\"1.0\"\nxmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\"\n&gt;\n&lt;xsl:output method=\"xml\" indent=\"yes\"\/&gt;\n&lt;xsl:param name=\"siteTitle\" select=\"\/photoCollection\/display\/metadata\/siteInfo\/@title\" \/&gt;\n&lt;xsl:template match=\"photoCollection\"&gt;\n&lt;files&gt;\n&lt;!-- copy source xml to a file for ease of development --&gt;\n&lt;file name=\"source.xml\"&gt;\n&lt;xsl:copy-of select=\"\/\" \/&gt;\n&lt;\/file&gt;\n&lt;!-- A ultra simple index page --&gt;\n&lt;xsl:call-template name=\"index.html\" \/&gt;\n&lt;\/files&gt;\n&lt;\/xsl:template&gt;\n&lt;\/xsl:stylesheet&gt;\n<\/pre>\n<p><h3>Try it out<\/h3>\n<p>\nNow move the DemoTemplate folder into &lt;your home directory&gt;\/Library\/Adobe Lightroom\/WebTemplates .  The folder WebTemplates  won&#8217;t exist,  so you&#8217;ll have to create that.  Note, that the folder name is &#8216;WebTemplates&#8217; with no spacess.  There may also be a folder called &#8220;WPG Templates&#8221;, which contains the web gallery preset items.  You can ignore that other folder.<\/p>\n<p>\nNow launch Lightroom Beta 3.  Select one or two images and switch to the Web Module.  You should see &#8220;Demo Template&#8221; as one of the options in the Gallery Template popup menu.  There won&#8217;t be much to see when you switch to it, but as soon as you do your transform is invoked to create a file called &#8220;source.xml&#8221; on disk.<\/p>\n<p>\nLet&#8217;s find that file.  Open a new Finder window.  Go to the temporary directory by pressing command-shift-g and typing \/tmp.  Switch to list view (command-2) and sort by date modified.  There should be a directory with a random name near the top of the list.  Open that folder; it should contain a file called &#8220;source.xml&#8221;.<\/p>\n<p>\nWith one image selected, this is my source.xml file:<\/p>\n<p><pre>\n&lt;photoCollection&gt;\n&lt;display&gt;\n&lt;style css=\"body {   background-color: #4C4C4C !important; } \"&gt;&lt;\/style&gt;\n&lt;metadata&gt;\n&lt;siteInfo title=\"Site Title\"&gt;&lt;\/siteInfo&gt;\n&lt;\/metadata&gt;\n&lt;localization&gt;&lt;\/localization&gt;\n&lt;\/display&gt;\n&lt;head&gt;\n&lt;siteTitle&gt;Tjuf Ujumf&lt;\/siteTitle&gt;\n&lt;collectionName&gt;&lt;\/collectionName&gt;\n&lt;collectionTitle&gt;&lt;\/collectionTitle&gt;\n&lt;collectionDescription&gt;&lt;\/collectionDescription&gt;\n&lt;contactInfo&gt;&lt;\/contactInfo&gt;\n&lt;slideDuration&gt;&lt;\/slideDuration&gt;\n&lt;sizes&gt;\n&lt;size height=\"130\" name=\"thumb\" width=\"130\"&gt;&lt;\/size&gt;\n&lt;\/sizes&gt;\n&lt;\/head&gt;\n&lt;samples&gt;\n&lt;img filename=\"CRW_3141\" imageID=\"4D4B0C47-928D-11DA-A6BF-000A95C37190\"&gt;\n&lt;text&gt;\n&lt;description&gt;&lt;\/description&gt;\n&lt;\/text&gt;\n&lt;rendition height=\"86\" path=\"bin\/images\/thumb\/CRW_3141.jpg\" width=\"130\" size=\"thumb\"&gt;&lt;\/rendition&gt;\n&lt;\/img&gt;\n&lt;\/samples&gt;\n&lt;\/photoCollection&gt;\n<\/pre>\n<p><h3>Crafting your site<\/h3>\n<p>\nYou can use the source.xml file generated above to create an actual web template.  There are a variety of tools out there for working with XSLT.  One example for the Mac OS is Marc Liyanage&#8217;s TestXSLT : <a href=\"http:\/\/www.entropy.ch\/software\/macosx\/\">http:\/\/www.entropy.ch\/software\/macosx\/<\/a> .  Cooktop, found at <a href=\"http:\/\/www.xmlcooktop.com\/\">http:\/\/www.xmlcooktop.com\/<\/a> , looks like a good tool for Windows.  These tools allow you to quickly run your new XSLT against the source xml in order to check for errors and inspect the HTML output.<\/p>\n<p>\nHere is a slightly more complicated example to get you started:<\/p>\n<p><pre>\n&lt;?xml version=\"1.0\"?&gt;\n&lt;xsl:stylesheet\nversion=\"1.0\"\nxmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\"\n&gt;\n&lt;xsl:output method=\"xml\" indent=\"yes\"\/&gt;\n&lt;xsl:param name=\"siteTitle\" select=\"\/photoCollection\/display\/metadata\/siteInfo\/@title\" \/&gt;\n&lt;xsl:template match=\"photoCollection\"&gt;\n&lt;files&gt;\n&lt;!-- copy source xml to a file for ease of development --&gt;\n&lt;file name=\"source.xml\"&gt;\n&lt;xsl:copy-of select=\"\/\" \/&gt;\n&lt;\/file&gt;\n&lt;!-- A ultra simple index page --&gt;\n&lt;xsl:call-template name=\"index.html\" \/&gt;\n&lt;\/files&gt;\n&lt;\/xsl:template&gt;\n&lt;!-- Generate an index page --&gt;\n&lt;xsl:template name=\"index.html\" &gt;\n&lt;file name=\"index.html\"&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;&lt;xsl:value-of select=\"$siteTitle\" \/&gt;&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;ol&gt;\n&lt;xsl:for-each select=\"samples\/img\"&gt;\n&lt;xsl:call-template name=\"indexImage\" \/&gt;\n&lt;\/xsl:for-each&gt;\n&lt;\/ol&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n&lt;\/file&gt;\n&lt;\/xsl:template&gt;\n&lt;!-- Add one image to the list --&gt;\n&lt;xsl:template name=\"indexImage\"&gt;\n&lt;xsl:param name=\"path\" select=\"rendition[@size='thumb']\/@path\" \/&gt;\n&lt;li&gt;&lt;img src=\"{$path}\" \/&gt;&lt;\/li&gt;\n&lt;\/xsl:template&gt;\n&lt;\/xsl:stylesheet&gt;\n<\/pre>\n<p>\nDownload the demo template:<a href=\"http:\/\/blogs.adobe.com\/jnack\/lightroom_wpg_example.zip\">lightroom_wpg_example.zip<\/a><\/p>\n<p>\nExpand and place it in &lt;your home directory&gt;\/Library\/Adobe Lightroom\/WebTemplates\/ .  In your experimentation, try creating multiple files and link between them.  Or, add additional elements to the &lt;sizes&gt; list in the galleryMaker.xml file.  Add text for each image.  Good luck!  Feel free to discuss your progress on the <a href=\"http:\/\/www.adobe.com\/cfusion\/webforums\/forum\/categories.cfm?forumid=72&amp;catid=589&amp;entercat=y\">Adobe Lightroom beta forums<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you might have heard in Lightroom Podcast #9 (starting around the 25-minute mark), we&#8217;re working on a fresh, new Web Photo Gallery engine for Lightroom. For those wanting to dig under the hood and start creating or modifying galleries, Adobe engineer Andy Rahn has created an overview, which I&#8217;ve included in this post&#8217;s extended [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[32,40,54],"tags":[],"_links":{"self":[{"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/posts\/11162"}],"collection":[{"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/comments?post=11162"}],"version-history":[{"count":0,"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/posts\/11162\/revisions"}],"wp:attachment":[{"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/media?parent=11162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/categories?post=11162"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jnack.com\/blog\/wp-json\/wp\/v2\/tags?post=11162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}