Adding new PCast menus for the LinkTheatre

Originally by Mike Smith from linkstationwiki.org

Introduction
This investigation was inspired by Articles/GeneralFunWithPCast. It looked like it would be possible to change the PCast html files stored on the LinkStation to extend the menus and functionality of the LinkTheatre. I had the idea of checking for new emails in the lounge/kitchen/wherever, but the possibilities are probably endless. In fact this intrigue even caused me to buy a LinkTheatre to satisfy my curiosity - I didn't have one already!!

The current set of files held in /etc/pcast/theme/pcast from this project are available here: pcast themes

Prerequisites
I had already replaced the original LinkStation firmware on a MIPSel device with an Projects/OpenLink firmware downloaded from LinkStationWiki. This enables command-line access using ssh (I use the PuTTY client). I have made various changes, and installed some additional packages, but these are not relevent to the PCast functionality.

You may also need a graphics editor such as Photoshop, Paint Shop Pro, The Gimp or even Microsoft Paint.

PCast HTML Setup
PCast holds it's HTML templates in a directory structure. The skin_root entry in the /etc/pcast/pcast.conf file points to that directory. The default is /etc/pcast/theme/pcast. When experimenting with a theme/skin it makes sense to copy an existing theme to a new diectory, changing the skin_root entry in the /etc/pcast/pcast.conf file to point to thart new directory and restart PCast. Should something go wrong it is easy to revert the settings in /etc/pcast/pcast.conf and continue with the original theme.

For this article, however, all work was performed in the /etc/pcast/theme/pcast directory on the LinkStation.

As noted in Articles/GeneralFunWithPCast, the html is prepocessed by the PCast executable /usr/sbin/pcastd as part of a templating system. This replaces variables embedded in the html files, and also builds pages using multiple files from the /etc/pcast/theme/pcast directory.

head_xxx.html is used for the menu functions

line_xxx.html is used for content

tail.html is a common trailer

There is a set of these files for each type of media, where xxx = image, movie and music. There are also some additional 'line' templates to create a content line (on the right hand side of the screen) containing a subdirectory (line_dir.html), blank line (line_space.html), and for when the file type is unknown (line_unknown.html).

The LinkTheatre provides support for standard and HD TV resolution menus. There is a checkbox in the LinkTheatre 'setup' menu to select the higher resolution menus. The effect is to use a different set of html files, suffexed by '_high.html' (and similarly for image files). I have ignored the 'high' files in the article, but changes to standard menus could equally apply to the high def set.

Adding a main menu entry
The first step I took in extending the functionality available to the LinkTheatre was to add a fifth entry to the main menu. The standard four are 'home' and buttons to select the video, image and music content. Each of these three buttons invoke the same (unknown, because of the templating system) PCast function with a filter parameter to list the appropriate type of media.

This was a simple task - editting top.html; repeating the html code of one of the previous menu entries and changing the A tag to simply load a new html file instead of using the PCast macro. This is what I included (it's just another row in the left hand side table)

                       

I've included the tvid="blue" tag - I made blue up, given that there was already red, green and yellow. The colours apparently refer to buttons on the remote control of some Syabas devices, but the LinkStation remote doesn't actually have the coloured buttons itself.

I originally used email.html, but have now generalised this to extras.html as the new page provides more services, not just email.

Changing the background
Adding a menu entry produces a new navigatable link, but there is a standard background graphic that contains the depiction of 4 buttons, on which the menu option text is overlaid (the main menu plus the three media functions.) To create the new button background image it is a simple task to copy the tv.jpg file across to a shared directory on the LinkStation, edit it using your favourite graphics editing tool and copy it back across again.

Note that there is also a background.jpg file. This is displayed when you point your web browser to the linkstation, but meta-tags within the html cause the LinkTheatre to use to tv.jpg file.

Menu background with additional button

Other menu changes
In a similar way to the top menu, each of the Photo, Music and Video header html files need to be updated to introduce the new menu entry. i.e. head_image.html, head_music.html and head_movie.html. (See the Automation section for a way to avoid this). They all use the same background graphic, so this is already addressed.

Automation
PCast does not provide any facility for dynamic updates to web pages (other than that built into the PCast executable - see the reference section). It is therefore necessary to dynamically recreate the HTML if you wish to inject other live content into the LinkTheatre pages. The OpenLink firmware includes cron which can be used to schedule automated updates. However to retrieve information from other systems it is necessary to install some additional software - such as an ftp client, telnet or netcat.

HTML Template Directives
Inside the template html files a number of PCast specific directives can be used. These directives have the form of HTML comments, so they do not interfere with normal HTML, and e.g. allow to edit a PCast template file with a normal HTML editor.

The spelling of the directives is rather strange. To simplify the interpretation, the following list provides the principle meaning of the phrases used in the directive names:


 * PCASTD_DEL_IS_... - Do not show the enclosed HTML, if...
 * PCASTD_DEL_IS_NO... - Show the enclosed HTML, if...
 * PCASTD_INS_... - Replace the directive with ...
 * PCASTD_INS_LINE... - Replace the directive with information/property ... of a media file.
 * PCASTD_..._LINK - Replace the directive with value ... formatted to be used in the href attribute of an HTML  anchor link. Often there is a corresponding directive, without the ..._LINK suffix. That one is supposed to be used as the anchor text which follows. For example:



The known directives are as follows:


 *  some html   - Show some html if file does not [sic!] have MP3 ID3 tags. This is the opposite of PCASTD_DEL_IS_NO_MP3_TAGS and is useful when dealing with MP3 files without ID3 tags. In this case it makes sense to e.g. include HTML and directives to display the file name, instead of  the non-existing artist and title tags. Note: The directive name is rather counter intuitive.
 *  some html   - Show some html if file is an image file type.
 *  some html   - Show some html if file is a movie file type.
 *  some html   - Show some html if file has [sic!] MP3 tags. This is the opposite of PCASTD_DEL_IS_HAVE_MP3_TAGS. It can be used to trigger the display of ID3 tags from an MP3 file in case this file contains ID3 tags. See the PCASTD_INS_LINE_MP3TAG_... directives for a list of tags PCast can extract from an MP3 file.
 *  some html  :Show some html if file is a sound file type.
 *  some html   - Show some html if file is not the media root directory.
 *  some html'''
 *   - Replaced by current active filer name.
 *   - Replaced by current page number. This is useful when assembling a navigation bar, e.g. together with the PCASTD_INS_MAX_PAGE directive to display Page X of Y.
 *   - Replaced by the current path name.
 *   - Replaced by a link to the current path. The data is supposed to be used in the href attribute of an HTML  anchor link.
 *   - Replaced by the current path, used to specify a particular sort. To be used in the href attribute of an HTML  anchor link.
 *   - Replaced by day of month as 2 digit value (01-31).
 *   - Replaced by last file number (useful in file X of Y displays).
 *   - Replaced by current file number.
 *   - Replaced by the client's (e.g. a LinkTheatre) IP address (Note: Once again, the seppling of the directive is strange, using the term HOST to indicate a client). PCast does not try to resolve the client's IP addres to the client's host name. Which is in general a good idea, since it would require a DNS server in the home network, or a correctly configured entry in the LinkStation /etc/hosts file. None of this is typically done.
 *   - Replaced by hour value of current time ss 2 digit value (00-23).
 *   - Replaced by the file extension of the file to be displayed in this line.
 *   - Replaced by a link to the PCast specific play information for the particular file. To be used in the href attribute of an HTML <A> anchor link.
 *   - Replaced by the file name of the file to be displayed in this line (including file name extension).
 *   - Replaced by the file name of the file to be displayed in this line (without file name extension).
 *   - Syabas POD information?
 *   - Replaced by the size of of the file to be displayed in this line.
 *   - Syabas VOD information?
 *   - Replaced by the MP3 Album name taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
 *   - Replaced by the MP3 artist name taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
 *   - Replaced by the MP3 comment taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
 *   - Replaced by the MP3 song title taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
 *   - Replaced by the MP3 title information taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
 *   - Replaced by the MP3 year information taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
 *   - LinkTheatre/syabas coloured button ID
 *   - Replaced by minutes value of current ss 2 digit value (00-59).
 *   - Replaced by month as 2 digit value (01-12).
 *   - Replaced by month as 2 digit value (01-12).
 *   - Replaced by a Next Page button.
 *   - Replaced by a button to go up a directory level.
 *   - Replaced by a Previous Page button.
 *   - Replaced by server name

Links
Links have been lost from the original article.