audible.pl Script : Documentation  

Home > audible.pl > Documentation

audible.pl Script Documentation

Browse audible.pl Script Documentation
 

Note about "cgi-bin" directory: The instructions in this documentation assume that your web server has a directory called cgi-bin where scripts are stored on the web server. Some web servers use a cgi-local directory or a cgi directory rather than a cgi-bin directory. In that case, where you see cgi-bin in any instruction, substitute it with the directory name that your web sever uses.


Introduction

The audible.pl script is a Perl script program that will create HTML pages showing products offered by Audible.com. A live example website that was created using the audible.pl script is myAudioBooks.com

Note that the audible.pl script is a "run-once" script; you run it and it creates HTML files. When you want to update the created HTML files, you run the script again.

You can install and run the audible.pl script on either your Windows PC, or on your linux/unix server if you have telnet or SSH access. Throughout the following documentation, you will see sections entitled "Installation on Windows PC" and "Installation on linux/unix server". Depending upon where you install and run the audible.pl script, read the appropriate section.

Depending upon the speed of your Windows PC (or your linux/unix server), it may take up to 1 hour for the audible.pl script to create all the HTML files for the approximately 8,000 products that Audible.com offers.


To use the audible.pl script:

  1. Setup an affiliate account with cj.com and add Audible.com as one of your advertisers.

    • If you do have an affiliate account with cj.com, then all you have to do is add Audible.com to your list of advertisers. Search for "audible.com" as an advertiser then click Apply, or click here.

    • If you do not have an affiliate account with cj.com, then you can open a cj.com account and add Audible.com to your list of advertisers in one easy step by clicking here. Alternatively, you can go to cj.com and open an account, and then add Audible.com to your list of advertisers by searching for "audible.com" as an advertiser then click Apply.

  2. Download the audible.pl script.

  3. Request an audible.key key file to unlock the demo audible.pl script so it becomes the full-version.

The rest of what you need to do is summarized in the following points and elaborated upon in full detail in the rest of this documentation.

  1. Download and unpack the audible.pl script. It comes compressed in a .zip file (or a .tar.gz file). See: Downloading and Unpacking below.

  2. After you receive your audible.key file from us, put it in the same directory where audible.pl is located. This will unlock the script. Note: You can run the audible.pl script without a audible.key file but the script will run in demo mode. In demo mode, all product links go to the Audible.com home page (and do not contain any affiliate ID).

  3. (optional) Download the Audible.com datafeed files. Alternatively, the audible.pl script can auto-download the latest datafeed files for you whenever you run the audible.pl script. See: Datafeed Files below.

  4. Modify the audible.ini configuration file. See: Configuration below.

  5. Modify the templates files, or create your own, or use the samples supplied.

  6. If you are going to run the audible.pl script on your Windows PC computer, then install ActivePerl. If you are going to run the audible.pl script on your linux/unix server, then upload all the files (script, data, and templates files) to your web server.

  7. Run the audible.pl script. See: Running audible.pl Script.

  8. If you ran the audible.pl script on your Windows PC, then upload the created HTML files to your web server.


If you have any questions about the audible.pl script, contact us.


Downloading

Request the audible.pl script.
You will automatically receive an email that contains download instructions.


Installation on Windows PC:


Installation on linux/unix server:


Unpacking


Installation on Windows PC:

Create a new directory, such as "c:\www\audible". If you use one of our other scripts in the future, you could put that script's files into "c:\www\SCRIPTNAME" -- this way all the files will be kept organized.

Novice User: To create the c:\www\audible directory, double click your "My Documents" folder. In the Address bar, type c:\ and press enter (the Address bar should now say "c:\"). If there is no "Address" bar, select View > Toolbars > Address Bar. If it says "These files are hidden", then click "Show the contents of this folder". Now create a new folder and call it www then open that folder (the Address bar should now say "c:\www\"). In there, create a new folder and call it audible then open that folder (the Address bar should now say "c:\www\audible\")..

Now unpack audible-######.zip (such as audible-040123.zip) into it using WinZip or equivalent Zip compression software.


Installation on linux/unix server:

Using your FTP program, create a "audible" directory in your "cgi-bin" directory. Upload audible-######.tar.gz into your audible directory using ftp BINARY transfer mode.

Login using telnet/SSH and go into the cgi-bin/audible directory. Then type:

gzip -c -d audible*.tar.gz | tar xf -


Contents:

When you unpack the file, you will get:

Item Description

audible.ini

Configuration file.

audible.pl

The audible.pl script.

audible-data/

Subdirectory where datafeed files will be stored.

audible-template/

Subdirectory containing template files.

audible-include/

Subdirectory containing include files.

Edit audible.ini.lnk

(in .zip file only). Windows shortcut to open audible.ini for editing using Windows Notepad program.

Edit audible.pl.lnk

(in .zip file only). Windows shortcut to open audible.pl for editing using Windows Notepad program.

htmlgz-######.zip
htmlgz-######.tar.gz

The htmlgz.pl script which can be used to save disk space; use of this script is optional. See: htmlgz.pl Script.



Datafeed Files

The audible.pl script works with the datafeed files available directly from Audible.com. See the following instructions to download the datafeed files either automatically or manually (we recommend that you let the script auto-download the datafeed files for you since it is much easier).

Audible.com updates their datafeed file weekly, each Wednesday.

Automatic Download

The default configuration of the audible.pl script is to automatically download the latest Audible.com datafeed files whenever you run the audible.pl script. See the download.* configuration variables. With this configuration, all you have to do is run the audible.pl script; the script will download the datafeed files for you.

Manual Download

You can manaully download the Audible.com datafeed files rather than having the audible.pl script download files for you

To manually download the Audible.com datafeed files:

  1. Login to Audible.com. If you do not have an Audible.com account (this is not the same as your cj.com account), then sign up with Audible.com.

  2. Request access to the datafeed files by sending an email to affiliate@audible.com and make sure to include: (1) your name, (2) your cj.com publisher PID, and (3) your website URL's.

  3. Wait to receive an email from the Audible.com affiliate manager granting you access to the datafeed files.

  4. Login to Audible.com.

  5. Scroll to the bottom of the home page and click on "Become an Affiliate" to go to the Affiliates section.

  6. In the right column, click on "Data feeds / Keywords".

  7. Scroll down to the links in the middle column. Right-click on the "All products in the Audible database" link and select "Save Target as..." and save it to your computer as all_products.txt (the default name) Note: The file is about 11MB so it may take a while to download depending upon your connection speed.

  8. If you are going to run audible.pl on your linux/unix server, then upload all_products.csv to the cgi-bin/audible/data directory on your server. Use ASCII transfer mode.

In the future whenever a newer datafeed is available, you can manually re-download the datafeed by repeating steps 4 through 7.



Configuration

The configuration of the audible.pl script is specified via a .ini configuration file called "audible.ini". Included with the script is a sample audible.ini file that you can start with.

In the audible.ini configuration file, each variable setting is specified on a separate line with the variable name first and then followed by the value. Comments are preceeded by a "#" symbol therefore you can comment out a line by adding a "#" to the start.


Installation on Windows PC:

To edit the audible.ini file, double-click on "Edit audible.ini" or run Windows Notepad and open the audible.ini file.


Installation on linux/unix server:

To edit the audible.ini file on your linux/unix server, use a plain text editor such as vi or pico.

Alternatively, you can edit the audible.ini file on your Windows PC and then upload the audible.ini file; see instructions in the "Installation on Windows PC" section above.


For a list of the configuration variables and their meaning, see the audible.ini file itself.

Note: Your cj.com publisher PID is set by us in your audible.key file that we send to you. You do not set your cj.com publisher PID in the audible.ini file.


write.html.gzip Configuration Variable

If you use a linux or unix web server, you can reduce the amount of disk space that the created HTML files use by about 50%. Set the write.html.gzip configuration variable to yes and install the htmlgz.pl script. See: htmlgz.pl Script for installation instructions and SSI limitations when using htmlgz.pl.


Template Files


Purpose of Template Files

Template files let you customize the created pages so that they match the look and feel of the rest of your website. A template file is just a regular HTML file just like the kind you normally create for the rest of your website. Basically, the script takes a template, fills in the category and item information and saves that HTML to disk as a new file -- the script does that repeatedly for all the categories and items. To tell the script where in the template to fill in the information, you type in "substitation variables" -- they look like text such as {item.price} or as HTML comments such as <!--item.price--> (see below for full details about substitution variables).


Template Types and Filenames

Template files are located in the directory specified via the template.dir configuration variable (default is audible-template/set1). There are three types of template files:

  1. Store home page template:

    • home.html : (required) This is the "store home page" template. This page is where the list of main Categories will appear. The "store home page" can be the home page of your website but it does not have to be; it is the front page of your Audible.com store.

      Note: The filename of the created home page file is set via the write.fn.home configuration variable (default is index.html).

  2. Category page templates:

    • cats-main.html : (optional) This template is used by each Main-Category to display a list of its Sub-Categories. If this template does not exist, then the cats.html template is used instead.

    • cats-sub.html : (optional) This template is used by each Sub-Category to display a list of its items. If this template does not exist, then the cats.html template is used instead.

    • cats.html : (optional) If you want all the Main/Sub-Category pages to look the same, you can use this one template file. If any of the Main/Sub-Category template files are missing, then this cats.html template file is required.

  3. Item page template:

    • items.html : (required) This template is used to display details about each item.


Filenames of Created Files

The names of the above template files is independent of the filenames used when the audible.pl scripts writes the created files to disk. The write.fn.* configuration variables control the filenames:

Variable Default Description
write.fn.home index.html

Filename of home page.

write.fn.ext html

Filename extension of item pages only. Note: For home page, see write.fn.home); for category index pages, see write.fn.index

write.fn.length 32

Maximum filename length (including extension)

write.fn.index index.html

Filename of category and sub-category index files. Note: For the home page, see write.fn.home

write.fn.dup.count yes
yes = if more than one products has the same product name, add the duplication count to the filename to distinquish products and create unique filenames.
no = don't
write.fn.dup.sku yes
yes = if more than one product has the same product name, add the product SKU to the filename to distinquish products and create unique filenames.
no = don't


Sample Template Sets

Several sample sets of templates are included with the script. They are located in the "audible-template" directory. See screen snapshots below.

You are not limited to using the sample template sets. You can use a set of templates as is, or you can copy then modify one of these sets of templates, or you can create your own templates from scratch.

The template.dir configuration variable controls which template set to use. For example, if you want to use the templates "set1", then set template.dir to "audible-template/set1".


myAudioBooks.com

(templates "set1")


myAudioBooks.com

(templates "set2")


myAudioBooks.com

(templates "set3")


myAudioBooks.com

(templates "set4")


myAudioBooks.com

(templates "set5")

 

Template Substitution Variables

To use a substitution variable in your template, type it as text {variableName} or as an HTML comment <!--variableName-->. For example, {date} and <--date--> are substituted with today's date.

To learn more about substitution variables, see: Template Substitution Variables below.


Template Directives

Template directives let you direct the script as to what to do at various points in the template. For example, you could use an {include} directive to include a file, or use an {if} directive to conditionally include a section of HTML based on the value of a variable.

To learn more about template directives, see: Template Directives below.


Running audible.pl Script


Installation on Windows PC:

If you plan on running the audible.pl script on your Windows PC computer, you will need to install ActivePerl. ActivePerl is free and we use it ourselves to run our scripts.

  1. Open an MS-DOS window.

    Novice: To open an MS-DOS window, select "Run..." from the Windows Start menu and type the word "command" (no quotation marks). See "How to use an MS-DOS window".

  2. "cd" to the directory where you have the audible.pl file (e.g.: "cd \www\audible").

    Novice: See "How to use an MS-DOS window". The MS-DOS window lets you work with one directory at a time. The prompt tells you what the current working directory is. When you first open an MS-DOS window, its default is typically the directory "c:\windows\desktop" as indicated in the prompt. You need to change to the directory where you unpacked the audible.pl file. So, type "cd \www\audible" (no quotation marks). The command line prompt will change to "c:\www\audible>".

  3. If you haven't already done so, edit the template files so that they match the look and feel of your website. Or you can just use one of the sample template sets provided.

  4. If you haven't already done so, edit the audible.ini file. You may want to change some of the configuration variables. To edit the file, type "notepad audible.ini" (no quotation marks) or double-click on the "Edit audible.ini" icon.

  5. For testing purposes, you might want to set the "test" configuration variable in audible.ini to "500". This will cause audible.pl to process only the first 500 product records rather than process all product records (the datafeed file typically contains about 8,000 product records). Later when you are satisfied that the created HTML files look okay, you can change the "test" configuration variable back to "0" (i.e.: zero) so that all product records are processed.

    NOTE: If you set the write.html.gzip configuration variable to yes, you should install and test the htmlgz.pl script to verify that it works on your server before you run audible.pl with "test" set to "0" (i.e.: zero; all products). There's no point in creating all files as .html.gz and then finding out that your web server can't handle them!

  6. You're ready to run the script. Type "perl audible.pl" (no quotation marks). As the script runs, it will display status information as it progresses.

    You may see this error:

    ./audible.key: key file not found

    See "Errors" below.


    You may see this error:

    all_products.txt: couldn't download datafeed file

    500 Can't connect to download.audible.com:80 (Bad hostname 'download.audible.com')

    You must be connected to the internet so that audible.pl can automatically download the datafeed file from Audible.com.

    If you have a firewall, then you must configure your firewall so that the program called "perl" is allowed access to the internet. See your firewall documentation about how to allow access to programs.

    If you want to turn off auto-download, edit audible.ini and set the configuration variable called download to no. Then see Datafeed File for steps to manually download the datafeed file.

  7. After the script creates all your HTML files, they will be in the "html" directory (or the directory specified in the write.dir configuration variable). If you want, you can view the index.html file in your web browser -- open your web browser and view the file "c:\www\audible\html\index.html" (the write.fn.home configuration variable specifies the filename "index.html" as the home page file).

  8. If you want to revise the templates, do that and then go back and re-run the audible.pl script.

  9. If you set the "test" configuration variable to a non-zero value, change the "test" configuration variable back to "0" (i.e.: zero) and then re-run the audible.pl script so that all product records are processed.

  10. After you run the audible.pl script with the "test" configuration variable set to "0", there should be about 18,000 HTML files in the "html" directory that take up about 150MB of disk space (the number of HTML files and the amount of disk space used depends upon the number of records in the datafeed file).

  11. Use your FTP program to upload the contents of the "html" directory to your web server. If you want the webpages to appear at your home page, upload the files to your home page directory. If you want the webpages to appear at a subdirectory (e.g.: www.mydomain.com/audiobooks/), then create a subdirectory (e.g.: audiobooks) in your home page directory and upload the files into that directory. The files are regular .html files so upload them to your website as you would any other .html files. Since there are about 18,000 HTML files, it may take several hours to upload all the files.

Advanced: If you have telnet/ssh access to your linux/unix server, you can use WinZip to zip the files on your Windows PC computer, FTP upload the .zip file to your server, login to telnet/ssh, then run the linux/unix unzip command. To see if the unzip command is installed on your linux/unix server, just type "unzip" and you should see usage instructions. To unzip the file filename.zip into the current directory (and create any new subdirectories if there are any subdirectories in the .zip file), use the linux/unix command "unzip filename.zip" (without quotation marks).


Installation on linux/unix server:

To run the audible.pl script on your linux/unix server, you must have telnet/SSH access. If you don't have telnet/SSH access then you must run the audible.pl script on your Windows PC instead.

  1. Edit your audible.ini file if you have not already done so. In particular, be sure that the write.dir configuration variable specifies the path to the directory where you want the created HTML files to be written to.

  2. Run your FTP program and connect to your server.

  3. Create a directory called "audible" inside your "cgi-bin" directory.

  4. In this new "audible" directory, upload the following files using ASCII transfer mode:

    1. the audible.pl script file.
    2. your audible.ini configuratoin file.
    3. your audible.key key file; without this, the script will run in demo mode.
    4. your .html template files
    5. (skip this step if doing auto-downloading) the audible-data/all_products.txt datafeed files.

  5. Change file permissions of audible.pl to CHMOD 744 (rwx r-- r--).

  6. Login to your server using telnet/SSH.

  7. "cd" to the cgi-bin/audible directory.

  8. For testing purposes, you might want to set the "test" configuration variable in audible.ini to "500". This will cause audible.pl to process only the first 500 product records rather than process all product records (the datafeed file typically contains about 8,000 product records). Once you are satisfied that the created HTML files look okay, you can change the "test" configuration variable back to "0" (i.e.: zero) so that all product records are processed.

    NOTE: If you set the write.html.gzip configuration variable to yes, you should install and test the htmlgz.pl script to verify that it works on your server before you run audible.pl with "test" set to "0" (i.e.: zero; all products). There's no point in creating all files as .html.gz and then finding out that your web server can't handle them!

  9. Now type the following linux/unix command to run the audible.pl script:

    nohup perl audible.pl &

    The "&" at the end of the above command is required. This command will cause the audible.pl script to be run in such a way that it will continue even if your internet connection is interrupted. If you have a dialup connection, you can disconnect at any time and the script will continue to completion. "nohup", an acronym for "no hangup", is a linux/unix command that causes the specified program to be run immune to disconnections.

    Status output is sent to the audible-log.txt file. On some linux/unix systems output also appears on the screen; if that does not happen with your server, then you can type "tail -n50 -f audible-log.txt" to view the log file (press ctrl-C to stop viewing).

    When you use this "nohup ..." command you can then disconnect (the script will keep running) and you can then reconnect later. When you reconnect later, cd to the directory where the audible-log.txt log file is located then use "tail -n50 -f audible-log.txt" to view the log file (press Ctrl-C to stop viewing).

    Note about Ctrl-C:

    If you press Ctrl-C while tail is running, only the tail program (the log viewer) will be stopped. The perl audible.pl program will still be running in the background. Do not run perl audible.pl again otherwise you will have two perl audible.pl programs running simultaneously! To stop the perl audible.pl program, type the command fg (and press Enter) to bring the perl audible.pl program to the foreground. Then press Ctrl-C to stop it.

    You may see this error:

    ./audible.key: key file not found

    See "Errors" below.


    You may see this error:

    all_products.txt: couldn't download datafeed file

    500 Can't connect to download.audible.com:80 (Bad hostname 'download.audible.com')

    You must be connected to the internet so that audible.pl can automatically download the datafeed file from Audible.com.

    If you have a firewall, then you must configure your firewall so that the program called "perl" is allowed access to the internet. See your firewall documentation about how to allow access to programs.

    If you want to turn off auto-download, edit audible.ini and set the configuration variable called download to no. Then see Datafeed File for steps to manually download the datafeed file.

  10. After you run the audible.pl script with the "test" configuration variable set to "0", there should be about 18,000 HTML files in the "html" directory that take up about 150MB of disk space (the number of HTML files and the amount of disk space used depends upon the number of records in the datafeed file).


Errors:

./audible.key: key file not found
./audible-key.txt: key file not found

  1. Have you receive an audible.key file from us? If yes, continue to the next step. If you have not request one, request it now. If you have request it but have not receive it yet, then wait until you receive it.

  2. Did you "cd" (change directory) to the directory where audible.pl is located and then do the perl audible.pl command? Do not include a path in the command, such as perl /home/mydomain.com/cgi-bin/audible.pl. You have to be in the same directory where audible.pl is located when you run it.

  3. Verify that the audible.key file is in the same directory where audible.pl is located.

  4. Verify that the name of the file is audible.key and not something else such as audible.key.txt


!!! key not found; running in demo mode

  1. If the error "key file not found" also appeared, then fix that error. See above.

  2. If you're running audible.pl on your server, then reupload the audible.key file using ASCII transfer mode.

  3. Open the audible.key file in a text editor (e.g.: run Windows Notepad and then drag the audible.key file icon into Notepad; or run a linux editor such as pico or vi). Open the email that the key was attached to and you'll see that the body of the email contains a text copy of the key's contents. Verify that the contents is the same. You cannot change the ID in a key file.

  4. Start again with a fresh copy of the audible.key file. Delete the audible.key file (from your Windows PC and/or server). Open the email that the key was attached to. Save the key to your hard drive. Put the audible.key file in the same directory where audible.pl is located.


!!! key expired on xx/xx/xx (YY/MM/DD); running in demo mode


Template Substitution Variables

To learn more about templates, see: Template Files


audible.*

The audible.* substitution variables can be used in all templates.

Variable Description
audible.home

URL of Audible.com home page (link includes cj.com publisher PID). Use this as the URL in a link.

audible.id

cj.com publisher PID. This variable is set in the audible.key key file. If no valid key is found, then this variable is empty.

audible.search

URL of Audible.com search page (link includes cj.com publisher PID). Use this as the URL in a link.

audible.signup

URL of Audible.com affiliate signup page (link does not include cj.com publisher PID since cj.com does not support sub-affiliates). Use this as the URL in a link.



cfg.*

The cfg.* substitution variables can be used in all templates.

Variable Description
cfg.NAME

The configuration variable cfg.NAME. For example, cfg.navbar.home would be the value of the navbar.home configuration variable.

NAME

Same as cfg.NAME if NAME is not one of the built-in variables.



credit.*

The credit.* substitution variables can be used in all templates.

Variable Description
credit

"Powered by c3scripts.com" credit line. Use this substitution variable if you want the credit line to appear in a specific location in your template. Otherwise, the credit line will be added just before the closing </BODY> tag. The credit line is contained inside a right-aligned table. See also: credit and credit.color configuration variables to not show the credit line and to set its color, respectivley.



date.*

The date.* substitution variables can be used in all templates.

Variable Description
date

Today's short date, e.g.: 01/31/2002

date.long

Today's long date, e.g.: Thursday, January 31, 2002

date FORMAT

Today's date formatted using FORMAT clock codes (see Clock Codes as described in the Associate Engine documentation).


Variable Description
date.asof

The "as of" short date, e.g.: 01/31/2002
The "as of" date is the last modified date of the datafeed file.

date.asof.long

The "as of" long date, e.g.: Thursday, January 31, 2002

date.asof FORMAT

The "as of" date formatted using FORMAT clock codes (see Clock Codes as described in the Associate Engine documentation).



item.*

The item.* substitution variables can be used only in an item template.

Variable Description
item.author

Author of item.

item.cats.main
item.cats.related
item.cats.related.list
item.cats.related.menu
item.cats.related.text
item.cats.sub

Same as page.cats.*

item.currency

Currency. This is supplied by Audible.com and you can expect this to be "USD" which indicates U.S. dollar.

item.desc

Description of item.

item.desc.short

Short description of item. This is supplied by Audible.com and is typically the first 100 characters of the longer item.desc description, chopped at the nearest word boundary and "..." added.

item.id

ID (SKU) of item.

item.img

URL of image of item.

item.img.thumb

URL of thumbnail image of item.

item.isbn

ISBN of item.

item.keywords

Keywords of item. If the item has no keywords, then this will be the name of the item.

item.length

Length (in time) of the item. Examples: "10 hours and 7 min.", "1 hour", "daily", "varies", "1 hour / weekly".

item.name

Name of item.

item.name.short

Name of item without any "(text)" at the end. For example, for the item "A Short History of Nearly Everything (Unabridged)", this variable would return "A Short History of Nearly Everything".

item.price

Price of item. Does include $ sign and cents, e.g.: "$153.00".

item.price.retail

Retail price of item. Does include $ sign and cents, e.g.: "$153.00".

item.price.sale

Price of item (same as item.price). Does include $ sign and cents, e.g.: "$153.00".

item.publisher

Publisher of item.

item.rating

Average Customer Rating of item. For example, "4.72". Possible values are real numbers, with minimum of 0 and maximum of 5, and with 0 or 1 or 2 decimal digits.

item.rating.int

Average Customer Rating of item as a whole number. Possible values are exactly, 1, 2, 3, 4, 5.

item.rating.stars

Average Customer Rating of item shown as a grahic. Returns an <IMG> tag showing 1 to 5 stars or no graphic at all if the rating is exactly zero. If the rating is non-zero, it is converted to an integer (e.g.: 4.72 is converted to 4 so 4 stars are shown) and that number of stars is shown.

item.sample.real

URL of RealAudio audio sample of item. The sample is typically 30 seconds or longer. Use this URL in a link, such as: <A HREF="{item.sample.real}">Hear sample (RealAudio)</A>

item.sample.wmp

URL of Windows Media Player audio sample of item. The sample is typically 30 seconds or longer. Use this URL in a link, such as: <A HREF="{item.sample.wmp}">Hear sample (Windows Media Player)</A>

item.save

Savings between retail price and sale price. This will be empty if the retail and sale prices are the same or if either is empty. Does include $ sign and cents, e.g.: $0.42

item.save.percent

Percentage savings between retail price and sale price. This will be empty if the retail and sale prices are the same or if either is empty. Includes % percent sign and is a whole number (no decimal place digits), e.g.: 17%

item.updated

Update date of item. In the datafeed, Audible.com sets this field to the date that the datafeed was created. For example, "May 18, 2004".

item.url

URL to buy item. Contains your cj.com Publisher ID. Use this URL in a link, such as: <A HREF="{item.url}">Click here to buy {item.name}</A>

item.worldwide

Indicates if item is available worldwide. Possible values are "Y" and "N".



page.*

The page.* substitution variables can be used in those templates indicated in the "Where" column below (home = home page, main = main category page, sub = sub-category page, item = item page). If a variable cannot be used on a certain page, it returns empty on those pages.

Variable Where Description
page.cats.main

main
sub
item

Main category of page.

page.cats.main.url

main
sub
item

URL of audible.com home page (currently audible.com does not support linking to a main category at their website therefore this variable returns the URL of the audible.com home page instead).

page.cats.sub

sub
item

Sub-category of page.

page.cats.sub.url

sub
item

URL of audible.com home page (currently audible.com does not support linking to a sub-category at their website therefore this variable returns the URL of the audible.com home page instead).

page.elders
page.elders.list
page.elders.menu
page.elders.text

sub
item

All categories above the current page.

Formats are: .list = bulleted list, .menu = drop-down menu, and .text = text links with <BR>. The default is .list

page.items
page.items.list
page.items.menu
page.items.text

sub
item

All items in this sub-category.

Formats are: .list = bulleted list, .menu = drop-down menu, and .text = text links with <BR>. The default is .list

page.items.grid

sub

Grid showing thumbnail graphics of all the items in this sub-category. Equivalent to page.kids.grid

page.keywords

item

Keywords of the current page. If this is a category page or the product has no keywords, then this will be the name of the page, that is, the name of the current category or product.

page.kids
page.kids.list
page.kids.menu
page.kids.text

home
main
sub

On the home page, lists the main categories.
On a main category page, lists its sub-categories.
On a sub-category page, lists its items.

Formats are: .list = bulleted list, .menu = drop-down menu, and .text = text links with <BR>. The default is .list

page.kids.grid

item

Grid showing thumbnail graphics of all the items in this sub-category. Equivalent to page.items.grid

page.main
page.main.list
page.main.menu
page.main.text

home
main
sub
item

List of all the main categories.

Formats are: .list = bulleted list, .menu = drop-down menu, and .text = text links with <BR>. The default is .list

page.name

home
main
sub
item

Name of the current page. If this is an item page, then this will be the name of the product. Otherwise, if this is a main/sub category page, this will be the name of the main/sub category.

page.navbar

home
main
sub
item

Navigation bar.

page.navbar.nohome

home
main
sub
item

Navigation bar, without "Home" link.

page.pagebar

sub

If the current sub-category page is split across multiple pages, this will be links to next/previous pages otherwise it will be empty.

page.siblings

main
sub
item

On a main category page, list of all main categories.
On a sub-category page, list of all sub-categories in this main category.
On an item page, list of all items in this sub-category.

Formats are: .list = bulleted list, .menu = drop-down menu, and .text = text links with <BR>. The default is .list

page.sub
page.sub.list
page.sub.menu
page.sub.text

main
sub
item

List of all sub-categories in this main category.

Formats are: .list = bulleted list, .menu = drop-down menu, and .text = text links with <BR>. The default is .list

page.type.home
page.type.main
page.type.sub
page.type.item

home
main
sub
item

Type of the current page. Depending upon the type of the current page, one of these variables will have the value "1" and the others will have the vale "0" (zero). You can use it with an {if} directive.

Example:

<!--if page.type.main-->
  this is a main-category page
<!--elsif page.type.sub-->
  this is a sub-category page
<!--elsif page.type.item-->
  this is a product page
<!--endif-->

page.url

home
main
sub
item

On home page or main category or sub-category page: URL of audible.com home page (currently audible.com does not support linking to a main category at their website therefore this variable returns the URL of the audible.com home page instead).

On item page: URL to buy item. Equivalent toitem.url



path.*

The path.* substitution variables can be used in all templates.

Variable Description
path.home

Relative directory path to the home page directory. For example, to access the home page from within any template, you could use:

<A HREF="{path.home}/{write.fn.home}>Home</A>

path.img

Relative directory path to the images directory which contains images used by some templates (note: not all template sets use graphics such as "Add to Cart"). To use a template image in a template, preceed its filename with {path.img}, such as:

<IMG SRC="{path.img}/buy.gif">

See also: img.dir configuration variable.


Template Directives

To learn more about templates, see: Template Files


cfg

The cfg directive can be used in all templates.

Directive Description
cfg VARIABLE "VALUE"

Set the specified configuration variable VARIABLE to the specified VALUE.

Example:

<!--cfg navbar.link.style "color: white"-->

This sets the navbar.link.style configuration variable to "color: white"

Duration: The duration of the cfg directive is temporary and only applies to the current template.

Read-Only: Some configuration variables are "read-only" and cannot be set inside a template using the cfg directive, e.g.: make.home and audible.id. Instead, set those configuration variables globally in the .ini configuration file.

if Directive: All the cfg directives are processed (in order from the start of the template file to the end of the file), even those that are inside an if directive that evaluates to false. Thus if there are two or more cfg directives for the same configuration variable, then the last configuration variable value is the one that "sticks".



if

The if directive can be used in all templates.

The if directive allows for conditional inclusion or exclusion of sections of HTML depending upon the specified condition. The simplest format of the if directive is:

{if CONDITION}
   some HTML to be included if CONDITION is true
{endif}

or, alternatively, you can use the equivalent <!--...--> style:

<!--if CONDITION-->
   some HTML to be included if CONDITION is true
<!--endif-->

Note: For each particular set of if/endif, the style of the if (i.e.: {if} or <!--if-->) must be the same as the style of the endif (i.e.: {endif} or <!--endif-->). You cannot use {if} and then close it off with <!--endif-->; you would have to use {endif} in that case; and vice versa.

If the CONDITION turns out to be true (e.g. "Is the price less than $100?"), then everything up to the endif is included. If the CONDITION turns out to be false, then everything up to the endif is excluded.

You can also specify an else section that will be included if the condition is false. That way you can alternatively include the first section or the second section depending upon the CONDITION. Example:

{if CONDITION}
   some HTML to be included if CONDITION is true
{else}
   some HTML to be included if CONDITION is false
{endif}

or, alternatively, you can use the equivalent <!--...--> style:

<!--if CONDITION-->
   some HTML to be included if CONDITION is true
<!--else-->
   some HTML to be included if CONDITION is false
<!--endif-->

Note: For each particular set of if/endif, the style of the if (i.e.: {if} or <!--if-->) must be the same as the style of the endif (i.e.: {endif} or <!--endif-->). You cannot use {if} and then close it off with <!--endif-->; you would have to use {endif} in that case; and vice versa.

You can also specify optional elsif CONDITION sections. Each CONDITION is evaluated in turn. If one is found to be true, then that section is included only, otherwise the else section is included (if present). Example:

{if CONDITION1}
   some HTML to be included if CONDITION1 is true
{elsif CONDITION2}
   some HTML to be included if CONDITION2 is true
{elsif CONDITION3}
   some HTML to be included if CONDITION3 is true
{else}
   some HTML to be included if CONDITION3 is false
{endif}

The CONDITION can be a VARIABLE or an EXPRESSION. See the following table:

Directive Description
if VARIABLE

Conditional if. If VARIABLE is non-empty and not value zero then keep everything up to next matching elsif or else or endif. Example:

{if cfg.credit}
   Powered by c3scripts.com
{else}
   no credit
{endif}

if !VARIABLE

Negated conditional if. If VARIABLE is empty or is value zero then keep everything up to next matching elsif or else or endif. This is the opposite of what {if VARIABLE} does.

Note: There is no space between the ! and VARIABLE.

Example:

{if !cfg.credit}
   no credit
{else}
   Powered by c3scripts.com
{endif}

if EXPRESSION

Conditional if. If EXPRESSION is true then keep everything up to next matching elsif or else or endif.

The format of the EXPRESSION is:

VARIABLE OPERATOR "VALUE"

Note: The " quotation marks around the VALUE are required only if VALUE contains spaces, e.g.: "hot water".

OPERATOR indicates how the VARIABLE and VALUE are to be compared, e.g.: = compares for an exact match. See tables below for meanings of the comparison operators and of the pattern match operators.

Example:

{if item.price > 100}
   This item is over $100
{else}
   This item is $100 or less
{endif}


Comparison
Operator
Meaning Example

<

Less than.

item.price < 100

<=
=<

Less than or equal.

item.price <= 100
item.price =< 100

=
==
is

Equal.

item.price = 100
item.price == 100
item.price is 100

!=
<>
!is
isnot

Not equal.

item.price !=100
item.price <> 100
item.price !is 100
item.price isnot 100

>=
=>

Equal or greater than.

item.price >= 100
item.price => 100

>

Greater than.

item.price > 99.95

Note: If both VARIABLE and VALUE are numeric then they are compared numerically; otherwise, they are compared lexicographically (case-insensitive text comparison).

Pattern Match Operator Meaning Example

^~

Starts with VALUE text followed by a word break (e.g.: space, comma, dash, etc.) (note: "cat" would not match "caterpillar").

page.name ^~ "soap"

^*

Starts with VALUE text (note: "cat" would match "caterpillar").

page.name ^* "soap"

~^~

Contains VALUE text preceeded and followed by a word break (e.g.: space, comma, dash, etc.) (note: "cat" would only match word "cat"). Note: Will not match at the start or end; will only match somewhere in the middle.

page.name ~^~ "soap"

*^*

Contains VALUE text anywhere except at start or end (note: "cat" would match "cat", "catch", "vacation", etc.) Note: Will not match at the start or end; will only match somewhere in the middle.

page.name *^* "soap"

~

Contains VALUE text preceeded and followed by a word break (e.g.: space, comma, dash, etc.) (note: "cat" would only match word "cat"). Note: Can match at the start or end or somewhere in the middle.

page.name ~ "soap"

*

Contains VALUE text anywhere (note: "cat" would match "cat", "catch", "vacation", etc.)

page.name * "soap"

~^

Ends with VALUE text preceeded by a word break (e.g.: space, comma, dash, etc.) (note: "pillar" would not match "caterpillar").

page.name ~^ "soap"

*^

Ends with VALUE text. (note: "pillar" would match "caterpillar").

page.name *^ "soap"

Acronyms:

  • ^ : anchor the match to start, end, or somewhere in between.
  • * : wildcard match with partial words, e.g.: cat in caterpillar.
  • ~ : match on complete words, e.g.: cat will not match caterpillar.

Word List: For a pattern match, the VALUE can be a list of words/phrases to match, e.g.: "hot water|warm drink|ice" would match any of the words/phrases "hot water", "warm drink", or "ice". This is useful if you want to match a word and its plural, e.g.: "beverage|beverages" .

if !EXPRESSION

Negated conditional if. If EXPRESSION is flase then keep everything up to next matching else or endif. This is the opposite of what if EXPRESSION does (see above).

Note: There is no space between the ! and EXPRESSION.

Note: Unlike other programming languages, the boolean negation operator ! has lower precedence than the OPERATOR. Thus the expression !VARIABLE > VALUE is evaluated internally as !(VARIABLE > VALUE) rather than (!VARIABLE) > VALUE.

if ?VARIABLE

Conditional if. If VARIABLE is defined then keep everything up to next matching elsif or else or endif.

Note: There is no space between the ? and VARIABLE.

Example:

{if ?cfg.myvariable}
   myvariable is {cfg.myvariable}
{else}
   myvariable has no value
{endif}

The condition can be negated using the format:
if !?VARIABLE
which can be read as "if not defined VARIABLE, then ..."



include.*

The include.* directive can be used in all templates.

Variable Description
include FILENAME

Include the specified file FILENAME located in the include directory (see include.dir configuration variable). Do not include the filename extension (.html, .htm, .shtml, .txt) as part of FILENAME. If the file contains a <BODY> tag, then only the contents of the <BODY> is inserted instead of all of the file's contents. For example, {include hdr} would include file hdr.html

include.all FILENAME

Include all of the specified file FILENAME located in the include directory (see include.dir configuration variable). Do not include the filename extension (.html, .htm, .shtml, .txt) as part of FILENAME. For example, {include.all hdr} would include file hdr.html


htmlgz.pl Script

Use of the htmlgz.pl script is optional. You do not have to use it.


Note: The htmlgz.pl script works only on linux/unix web servers; it will not work on Windows NT servers. This limitation is because mod_rewrite is required.

IMPORTANT: Use of Server-Side-Includes (SSI) is restricted when using the htmlgz.pl script. See "Disadvantages" below.


Purpose

The htmlgz.pl script lets you save disk space on your web server by allowing you to have your HTML files as compressed .html.gz files (.gz is the filename extension associated with the linux/unix gzip compression program).

When a user requests any .html file, the htmlgz.pl script will decompress the corresponding .html.gz file "on-the-fly" and show the original HTML to the user. This is all transparent to the user; they think that they are accessing a .html file.

Advantages of using htmlgz.pl:

Disadvantages of using htmlgz.pl:


Creation of .html.gz files

To have audible.pl create .html.gz files rather than .html files, set the write.html.gzip configuration variable in audible.ini to yes.

If you already have .html files, you can compress them to .html.gz files by using the linux/unix gzip compression program. To do this, telnet/SSH into your web server and cd to the directory that contains your .html files then type gzip *.html (this command compresses all .html files in the current directory) or if your files are in several subdirectories, you can type:

find -name '*.html' | xargs gzip

The above command will compress all .html files in the current directory and in all subdirectories. If necessary, you can add -f to the end of the above command (after gzip) to force overwriting of existing .html.gz files.


Installation instructions

  1. Unpack the htmlgz-######.zip (or htmlgz-######.tar.gz) file. It is found in the audible-######.zip (or audible-######.tar.gz) file. The ###### will be a number indicating the version number.

    If you are logged into your web server using telnet/SSH, then you can unpack the .tar.gz file by using the following command:

    gzip -c -d htmlgz*.tar.gz | tar xf -

    When you unpack the file, you will get:

    File Description

    htmlgz.pl

    The htmlgz.pl script.

    htmlgz-htaccess.txt

    Sample .htaccess file.

    test.html.gz

    Test file to verify installation of htmlgz.pl.


  2. Upload htmlgz.pl to your cgi-bin directory using ASCII mode.

    Note: If your web server uses some other directory than cgi-bin for scripts, such as cgi-local or cgi, then upload htmlgz.pl there instead. When you get to Step 4 below, read the Note.

  3. Use CHMOD 755 on htmlgz.pl to enable execute permissions so that the htmlgz.pl script can be run.

  4. Open htmlgz-access.txt and copy its contents to your .htaccess file located in the root directory of your website, i.e.: in the directory where your home page is located. If you do not already have a .htaccess file in that directory, then create a blank file and then copy the contents of htmlgz-access.txt into it.

    Note: If your web server uses some other directory than cgi-bin for scripts, such as cgi-local or cgi, then you must modify the lines that you added to your .htaccess file so that the text /cgi-bin/htmlgz.pl in the last line instead says /cgi-local/htmlgz.pl (or whatever directory you use instead of "cgi-bin").

  5. Upload test.html.gz to the root directory of your web server using BINARY mode. You must use BINARY mode for this particular upload since .html.gz files are BINARY files (just like a Windows .zip file is a binary file).

  6. In your web browser, go to http://www.DOMAIN.com/test.html (substitute in your own domain name); be sure to type test.html; do not type test.html.gz. You should see a webpage saying that htmlgz.pl is working.

    1. "403 Forbidden" Error: If you get this error, then:

      1. Edit your .htaccess file and add the following line at the top:

        Options FollowSymLinks

      2. Verify that your .htaccess file has been updated as indicated above in Step 4.

      3. Verify with your hosting company that RewriteEngine has not been disabled. If the hosting company has disabled RewriteEngine then you cannot enable it via your .htaccess file; your hosting company has to enable it. It may also be necessary for your hosting company to enable Options FollowSymLinks

    2. "404 File Not Found" Error: If you get this error, verify that your .htaccess file has been updated as indicated above in Step 4.

    3. "500 Internal Server Error": If you get this error, then:

      1. Verify that htmlgz.pl was uploaded in ASCII mode.

      2. Verify that test.html.gz was uploaded in BINARY mode. All .html.gz files are binary files.

      3. Verify that the file permissions of htmlgz.pl were set using CHMOD 755.

      4. Verify that the file ownership (user & group) of test.html.gz is correct. If not, change it to your user & group using the linux/unix chown user:group filename command.

      5. If necessary, change the first line of htmlgz.pl if perl is at a different path then /usr/local/bin/perl on your web server. If you have other perl scripts on your web server that you know work, see what their first line says and use the same first line.


http://www.c3scripts.com/audible/