Creating a new template (slightly different... - no preview, only a JSON output)

Status
Not open for further replies.

WayneOPUK

New Member
Joined
May 15, 2013
Messages
5
Lightroom Experience
Beginner
Lightroom Version
Hi guys.

After succeeding with working with JSON parsing etc with an earlier project, ive decided to try and integrate my website with some JSON code.

My hosting provider has a limit of 10,000 files on the server, which can soon fill up (000webhost free hosting)

so, ive already created one template (very basic edit) from the original html gallery... so as my own website design is on the gallery, (edit headers footers and css)... i knew to edit the "galleryInfo" file to rename the gallery and ID of it - and thus created my own OPUK gallery.

Now, I want to create a gallery which outputs just a set of text files, in the format of:
Code:
[
    {
        "numpages": 5,
        "images": [
            {
                "id": "20130427-DSC_1059",
                "smallimage": "images/thumb/20130427-DSC_1059.jpg",
                "largeimage": "images/large/20130427-DSC_1059.jpg"
            },
            {
                "id": "20130427-DSC_1060",
                "smallimage": "images/thumb/20130427-DSC_1060.jpg",
                "largeimage": "images/large/20130427-DSC_1060.jpg"
            },
            {
                "id": "20130427-DSC_1064",
                "smallimage": "images/thumb/20130427-DSC_1064.jpg",
                "largeimage": "images/large/20130427-DSC_1064.jpg"
            },
            {
                "id": "20130428-DSC_1072",
                "smallimage": "images/thumb/20130428-DSC_1072.jpg",
                "largeimage": "images/large/20130428-DSC_1072.jpg"
            },
            {
                "id": "20130428-DSC_1073",
                "smallimage": "images/thumb/20130428-DSC_1073.jpg",
                "largeimage": "images/large/20130428-DSC_1073.jpg"
            },
            {
                "id": "20130428-DSC_1074",
                "smallimage": "images/thumb/20130428-DSC_1074.jpg",
                "largeimage": "images/large/20130428-DSC_1074.jpg"
            },
            {
                "id": "20130428-DSC_1075",
                "smallimage": "images/thumb/20130428-DSC_1075.jpg",
                "largeimage": "images/large/20130428-DSC_1075.jpg"
            },
            {
                "id": "20130428-DSC_1076",
                "smallimage": "images/thumb/20130428-DSC_1076.jpg",
                "largeimage": "images/large/20130428-DSC_1076.jpg"
            },
            {
                "id": "20130428-DSC_1077",
                "smallimage": "images/thumb/20130428-DSC_1077.jpg",
                "largeimage": "images/large/20130428-DSC_1077.jpg"
            },
            {
                "id": "null"
            }
        ]
    }
]

so ive edited the gridpages to:

Code:
[{
"numpages": <% =numGridPages %>,
"images": [ 
<% --[[ Main grid area ]] %>
<lr:ThumbnailGrid>
<% --[[ The grid ]] %>
<lr:GridPhotoCell>
{
"id": "<%= image.exportFilename %>",
"smallimage": "images/thumb/<%= image.exportFilename %>.jpg",
"largeimage": "images/large/<%= image.exportFilename %>.jpg"
},
</lr:GridPhotoCell>
</lr:ThumbnailGrid>
{
"id": "null"
}
]
}]

this part works fine... however, I dont want it to output to 5/6/7 differnt files... i want ALL image paths of the album on one file... In addition to that, I dont want the file to be named "index.html" but instead "my choice.json"

anybody know how to make it loop through ALL images on the current collection...

Also, as i will parse the json files with PHP, i dont want it to export the html file either... ive not looked at that... but i assume its something to do with :

Code:
AddPhotoPages {
 template='detail.html',
 variant='_large',
 destination="content",
}
AddGridPages {
 template='grid.html',
 rows=model.nonCSS.numRows,
 columns=model.nonCSS.numCols,
}
AddCustomCSS {
 filename='content/custom.css',
}
in the manifest.lrweb

I dont need any resources to be uploaded...

all i want is:

thumbnails created, "large" images created. (possible to upload "original edited" in full size too?), and the "custom name".json file uploading...

i can manually delete the html files, but i dont want the hassle of this. my plan is to minimise files stored, and only store what i need.
As i use cloudflare, i can utilise serverside modrewrite to make browsers redirect x.com/file/imagename.html to gallery.php?gallery=FILE&image=IMAGENAME and thus still keep the original functionality etc... - but with the obvious flexibility of managing a custom php page too.

anybody know how to do this? (not the php part, the removing the html files and custom naming the index.html to XXX.JSON
 
ahhh, right, so after a lot of editing, ive sorted most of my code... i have bodged a work around for the index.html filename to become "????.js/.json/"etc.

index.html - template file - blank. - i stick this file into my thumbnail directory...

grid.html - template file - becomes the json file to parse on php... - filename is gathered from within lightroom.
Code:
[{
"website": [{ "title": "$model.metadata.siteTitle.value",
   "contactname": "$model.metadata.contactInfo.value",
            "contactdetails": "$model.metadata.contactInfo.link"
            }],
"collection": [{
   "password": "$model.metadata.groupPass.value",
            "title": "$model.metadata.groupTitle.value",
            "description": "$model.metadata.groupDescription.value",
            "thumbnails": "$model.photoSizes.thumb.directory",
            "larges": "$model.photoSizes.large.directory"
            }],
"images": [ 
<% 
 for i=1, numImages do
 
 myvCount = i
%>
{
"id": "<% = myvCount %>",
"filename": "<%= getImage(i).exportFilename %>.jpg",
"title": "<%= getImage(i).metadata.title %>",
"description": "<%= getImage(i).metadata.description %>"
},
<%
end
%>
{
"id": "null"
}
],
"count": <% =myvCount %>
}]

manifest.lrweb - how do i append ".json" onto the end of "model.metadata.groupFilename.value" ?
Code:
--[[
 Lightroom Web Gallery manifest.  This file maps various template files to actual
 files to be produced for your website.
 ]]
importTags( "lr", "com.adobe.lightroom.default" )

AddGridPages {
 template='index.html',
 rows=1000,
 columns=1000,
 destination=model.photoSizes.thumb.directory,
}
AddPage {
 template='grid.html',
 filename=model.metadata.groupFilename.value,
}

galleryInfo.lrweb: (i need to append the "file name" before the "images/thumb" to make it "filename/thumb" and "filename/large")
Code:
local warningFontName, warningFontSize
if MAC_ENV then
 warningFontName = LOC "$$$/locale_metric/Mac/Panel/Content/Italic/FontName=MyriadWebPro-Italic"
 warningFontSize = LOC "$$$/locale_metric/Mac/Panel/SmallBodyText/SmallFontSize=11"
else
 warningFontName = LOC "$$$/locale_metric/Win/Panel/Content/Italic/FontName=MyriadWebPro-Italic"
 warningFontSize = LOC "$$$/locale_metric/Win/Panel/SmallBodyText/SmallFontSize=10"
end
local warningFont = {
 name = warningFontName,
 size = tonumber( warningFontSize ),
}
local useMultiBind = false
return {
 LrSdkVersion = 2.0,
 LrSdkMinimumVersion = 2.0, -- minimum SDK version required by this plugin
 title = LOC "$$$/AgWPG/Templates/HTML/Title=OPUK JavaScript",
 id = "com.adobe.wpg.templates.OPUKJS",
 galleryType = "lua",
 maximumGallerySize = 50000,
 aboutBoxFile = "about.html",
 supportsLiveUpdate = true,
 model = {
  ["photoSizes.large.directory"] = "images/large",
  ["photoSizes.large.cropMode"] = "normal",
  ["photoSizes.large.height"] = useMultiBind and 450
   or function() return photoSizes.large.width end,
  ["photoSizes.large.maxHeight"] = 2701,
  ["photoSizes.large.maxWidth"] = 2701,
  ["photoSizes.large.metadataExportMode"] = useMultiBind and "copyright"
   or function() return photoSizes.thumb.metadataExportMode end,
  ["photoSizes.large.width"] = 450,
  ["photoSizes.thumb.directory"] =  "images/thumb",
  ["photoSizes.thumb.cropMode"] = "normal",
  ["photoSizes.thumb.height"] = 130,
  ["photoSizes.thumb.metadataExportMode"] = "copyright",
  ["photoSizes.thumb.width"] = 130,
  ["photoSizes.tracking"] = false,
  ["lightroomApplication.jpegQuality"] = 70,
  ["lightroomApplication.sizeBeingViewed"] = "thumb",
  ["lightroomApplication.useWatermark"] = true,
  ["lightroomApplication.watermarkID"] = "",
  ["lightroomApplication.outputSharpeningOn"] = true,
  ["lightroomApplication.outputSharpening"] = 2,
  ["metadata.siteTitle.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/properties/SiteTitle=blank",
  ["metadata.contactInfo.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/properties/ContactInfo=blank",
  ["metadata.contactInfo.link"] = {
   value = LOC "$$$/AgWPG/Templates/HTML/Defaults/ContactLink=mailto:user@domain",
   metadata = { [ "ag:dataType" ] = "webLink" },
  },
  ["metadata.groupTitle.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/ExampleGroupTitle=My Photographs",
  ["metadata.groupDescription.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/ExampleGroupDescription=blank",
  ["metadata.groupFilename.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/ExampleGroupTitle=myalbum",
  ["metadata.groupPass.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/ExampleGroupTitle=blank",
  ["perImageSetting.description"] = {
   enabled = true,
   value = "{{com.adobe.caption}}",
   title = LOC "$$$/WPG/HTML/CSS/properties/ImageCaption=Caption",
  },
  ["perImageSetting.title"] = {
   enabled = true,
   value = "{{com.adobe.title}}",
   title = LOC "$$$/WPG/HTML/CSS/properties/ImageTitle=Title",
  },
 },
 iconicPreview = {
  flashMovie = "iconic_preview/flash_gallery_preview.swf",
  flashvars = function()
   local iconicData = {
    foregroundColor = #000000,
    showLogo = "",
    cellBorderColor = #FF0000,
    cellRolloverColor = #000000,
    cellBackgroundColor = #000000,
    bodyBackgroundColor = #FFFFFF,
    numRows = 1,
    numCols = 1,
   }
   return iconicData
  end,
 },
 views = function( controller, f )
  local LrView = import "LrView"
  local bind = LrView.bind
  -- doesn't work with undo yet
  local multibind = f.multibind
  return { 
   labels = f:panel_content {
    bindToObject = controller,
    f:subdivided_sections {
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/GroupTitle=Collection Title (100 chars)",
      value = bind "metadata.groupTitle.value",
      max_length = 100,
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/GroupDescription=Collection Description (500 chars)",
      value = bind "metadata.groupDescription.value",
      max_length = 500,
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/GroupTitle=Collection Filename (20 chars)",
      value = bind "metadata.groupFilename.value",
      max_length = 20,
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/CollectionPass=Collection Password (20 chars)",
      value = bind "metadata.groupPass.value",
      max_length = 20,
     },
    },
    f:subdivided_sections {
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/SiteTitle=Site Title",
      value = bind "metadata.siteTitle.value",
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/ContactInfo=Contact Info",
      value = bind "metadata.contactInfo.value",
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/link=Web or Mail Link",
      value = bind "metadata.contactInfo.link",
      wraps = false,
     },
    },
   },
   outputSettings = f:panel_content {
    bindToObject = controller,
    f:subdivided_sections {
     f:header_section_label {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/OutputSettings=Output Directories",
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/thumbDir=images/thumbs",
      value = bind "photoSizes.thumb.directory",
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/largeDir=images/large",
      value = bind "photoSizes.large.directory",
     },
    },
    f:subdivided_sections {
     f:header_section_label {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/ImageHandling=Large Images",
     },
     f:slider_content_column {
      f:slider_row {
       title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/MaximumImageSizeLabel/JPEGQualityLabel=Quality",
       value = bind "lightroomApplication.jpegQuality",
       tracking = bind "lightroomApplication.jpegQuality.tracking",
       tracking_value = "qualityTracking",
       unit = "",
       max = 100,
       min = 0,
       width_in_digits = 4,
       precision = 0,
      },
      f:metadataModeControl {
       value = useMultiBind and multibind {
        "photoSizes.thumb.metadataExportMode",
        "photoSizes.large.metadataExportMode",
       }
       or bind "photoSizes.thumb.metadataExportMode",
      },
     },
     f:watermark_section( controller ),
    },
    f:subdivided_sections {
     f:header_section {
      ui.popup_row {
       title = LOC "$$$/AgWPG/Templates/HTML/Panel/PopupMenu/Sharpening=Sharpening :", 
       checkbox = {
        bindingValue = "lightroomApplication.outputSharpeningOn",
       },
       bindingValue = "lightroomApplication.outputSharpening",
       items = { { title = LOC( "$$$/AgWPG/Templates/HTML/PopupMenu/SharpeningLow=Low" ), value = 1 }, 
          { title = LOC( "$$$/AgWPG/Templates/HTML/PopupMenu/SharpeningStandard=Standard" ), value = 2 }, 
          { title = LOC( "$$$/AgWPG/Templates/HTML/PopupMenu/SharpeningHigh=High" ), value = 3 } },
       bindingEnabled = "lightroomApplication.outputSharpeningOn",
      },
     },
     f:content_section {
      margin_left = 30,
      f:static_text {
       fill_horizontal = 1,
       title = LOC "$$$/AgWPG/Templates/HTML/SharpeningMessage=Sharpening is applied on output.",
       font = warningFont,
      },
     },
    },
   },
  }
 end,
}
 
How to do it ? Never mind that, if I was just able to understand what your post was about and be able to read it right through without passing out that would be something !!!!
 
".." is used to concatenate.

@Mark ;)

John
 
How to do it ? Never mind that, if I was just able to understand what your post was about and be able to read it right through without passing out that would be something !!!!

sorry, was i being a little bit confusing (it was early hours and i didnt realise too much what i was saying...), but basically, what i want to do is make it possible to create an album without thousands of individual files for each image (and thus update thousands of exports if i update my website design).

- this has now been sorted - although i still need to sort out the PHP code.

".." is used to concatenate.

@Mark ;)

John

Will give that a bash, right after I eat my tea. - but i assume it will be
Code:
AddPage {
 template='grid.html',
 filename=model.metadata.groupFilename.value..'.json',
}

and

Code:
["photoSizes.large.directory"] = "images/large",

... will become a function?...

Im guessing:

Code:
["photoSizes.large.directory"] = function() return metadata.groupFilename.value.."/"..photoSizes.thumb.directory end

and linking directly like this could cause a problem (ie: end up with "myalbum/myalbum/myalbum/directory", so create a new "metadata.groupthumbsdir.value" etc to store the directory, and then link the "path" to this, and join the 'groupfilename / groupthumbsdir' using the function...? correct or?

Also, on the "preview display"... is there a way to make that just text there... ?
 
ok, its sort of working... I added this code into my index.html file... and it outputs

Code:
<p>Filename: <%= model.metadata.groupFilename.value %></p>
<p>Images Directory: <%= model.photoSizes.large.directory%></p>
<p>Thumbnails Directory: <%= model.photoSizes.thumb.directory %></p>

Code:
Filename: myalbum
Images Directory: myalbum/large
Thumbnails Directory: myalbum/thumb

I coded the LRWeb template:
Code:
  ["photoSizes.large.directory"] = useMultiBind and "large" or function()
   return metadata.groupFilename.value.."/"..metadata.groupLargefile.value end,

.....

  ["photoSizes.thumb.directory"] = useMultiBind and "thumb" or function()
   return metadata.groupFilename.value.."/"..metadata.groupThumbfile.value end,
....
  ["metadata.groupLargefile.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/GroupLargeImages=large",
  ["metadata.groupThumbfile.value"] = LOC "$$$/AgWPG/Templates/HTML/DefaultValues/GroupThumbImages=thumb",

....
...
...
...

   outputSettings = f:panel_content {
    bindToObject = controller,
    f:subdivided_sections {
     f:header_section_label {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/OutputSettings=Output Directories",
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/thumbDir=Thumbnail Dir",
      value = bind "metadata.groupThumbfile.value",
     },
     f:labeled_text_input  {
      title = LOC "$$$/AgWPG/Templates/HTML/Panel/Labels/largeDir=Large Image Dir",
      value = bind "metadata.groupLargefile.value",
     },
    },

the two "grid" files (index.html and "myalbum.json" file) but no images get exported...

if i change the directories back to "images/thumb" it works, not if i gather the filepath from the variables though...??? something im missing? - like i say: the directory outputs the correct text...
 
Status
Not open for further replies.
Back
Top