Skip to main content
Skip to navigation
Blog XML feed

Blog entry archive // Posts from a desiging, gaming, comic-reading nerd

Mar 31

Publish template info for Delicious Library 2

I’ve been wanting to customize the templates, for the Publish feature in Delicious Library 2 for a long time. The ones it comes with are nice, but I want to be able to pull the data and display it in my own way, so I reverse engineered one of the default templates to see how it all functioned. This is a work-in-progress, so I’ll update as I figure stuff out.

Disclaimer: Be sure to back up everything you plan on editing. This is unsupported hacking. I am not responsible for any data loss.

If you are unsure about this, you could try Bruji.com’s pedia software first. Unlike Delicious Library, it actually allows you to create your own HTML publish templates and there’s documentation to go with it. I’d use Bruji’s stuff, but I’ve invested a lot of time in DL and I like the way it creates box art, so I’m sticking with it.

The ideal thing I wanted to create was an XML feed of my shelves so I could display a “Now Playing” sidebar with box art on my Web site. XML publishing isn’t possible with DL, so I had to create a basic XHTML template that could be used instead.

Locating the templates

To get to the templates, find the DL application and “Show Package Contents.”

 Delicious Library 2 (Show Package Contents)/Contents/Resources/Templates/HTML Templates/

Copy a template and create a new one

Inside the HTML Templates folder you’ll find the template packages. Copy a default one and rename it. Then browse inside with “Show Package Contents.”

 YOURTEMPLATE.libraryhtmltemplate(Show Package Contents)/Contents/
File structure

The bare-bones template file structure will look something like this.

Info.plist
PkgInfo
Resources/
    English.lproj/
        Template.strings
    thumbnail
    zh-Hans.lproj/
Template/
    images/
    index.library.html

You can add more files as you need for your template, like JavaScript, in the Template folder.

Name the new template

You’ll need to edit the Template.strings file to give your template a name so DL will see it.

 "Name" = "Basic Info"; /* The name of the template */
 "Description" = "Basic publishing for reuse."; /* Summary of the template */
Thumbnail

You can create a thumbnail preview of your template by createing a 128 x 128px png image.

Images

The images folder contains all of your template images and the image assets DL will publish. If you use the rating variable, you’ll need the star images: star-filled.png, star-empty.png and star-half.png.

Basic template structure

The file index.library.html is the main template file. Here’s the basic code structure to start.

DL will automatically add a !DOCTYPE, XML namespace and character encoding if you don’t.

 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">

Meta: number of items per page, number of table columns.

<head>      
    <meta name="media-per-column" content="100" />
    <meta name="columns-per-page" content="1" />
    <title>Basic Publish</title>
</head>

As far as I can tell, the template system requires this table.

<body>
    <table>
       <tr>
         <td>

The <div class="medium"> is required for the output for each item.

             <div class="medium">
                <span class="title">$title</span>
                <span class="asin">$asin</span>
                <span class="cover-image-sm">$coverImage90</span>
                <span class="cover-image-lg">$coverImage180</span>
                <span class="creator">$creatorsCompositeString</span>
                <span class="rating">$rating</span>
                <span class="description">$primaryDescriptionAttributedString</span>
             </div>

Close the table.

          </td>
       </tr>
    </table>
</body>

Close the HTML.

</html>
Sub templates

You can also nest sub templates, like a mobile version, in folders below your main template. Create a new folder and a new index.library.html page. It will share the same images folder. See a default DL iPhone template for an example.

Template Variables:

Here’s the list of variables that you can use in your template. I haven’t figured out what all of them do. I also came across a few variables that appear to do nothing, so I left them out.

  • $coverImage90 : Item cover image with max width/height pixel dimensions
  • $asin : Amazon item number
  • $title : Item title
  • $fullName : Name of library owner
  • $addressBookImage60 : Image of library owner
  • $totalItems : Total items in Library
  • $publishDate : Published date
  • $rating : Outputs rating star images: star-filled.png, star-empty.png, star-half.png
  • $creatorsCompositeString
  • $primaryDescriptionAttributedString : Item description
  • $pageNavigation
  • $shelfNavigationPopup
  • $uuidString
  • $notes
  • $isbn

About this entry

  • Published: Mar 31, 2009
  • Tags: Delicious Library, tutorial
  • Comments: 2

← Previous // Next →

Recent entries

Browse the archive →

Comments // What has been said about this entry

Paul
Mar 9, 2010, 1:42pm

I’ve found i can use both $notes and $isbn variables. Have you found any others in the last 12 months?

Josh N.
Mar 9, 2010, 1:52pm

I haven’t found any others, but the $notes variable would be really handy.

Leave a comment // Have something to say?

Comment rules

Real names are preferred. Comments are moderated before being published.