![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
ClariNet PhotoGrab TemplatesIf you are using ClariNet's photograb perl script to extract incoming photos on your system, you want to be able to insert the photos, captions, headlines and other materials into an attractive looking web page. To do this, you can edit a template file that lets you build the HTML you want. The HTML can then be inserted into a web page using the "server side include" mechanism of most web servers, assuming it is turned on. Your webmaster needs to configure the server to do this if it is not already configured.
Setting up the Page to include the HTMLYou must pick a page in which you want the live photo and text inserted. This may end up being your home page. Many sites like the idea that a live picture, changing many times per day with a hot photo of a current event can make a web site a more dynamic, interesting place. If people come to a web page and always see an interesting photo of a very current news event, they will really get a sense that this page is doing something for them, and be drawn into the news linked from the photo. ClariNet's goal is to help our subscribers make their systems, news servers and web pages more interesting for their users, to keep them coming back and keep them pleased with being a user on the system. Consult with your webmaster, but chances are this means the page that inserts the generated HTML needs to have the extension ".shtml" instead of ".html" This can complicate matters if the page is to be the master home page, normally known as index.html -- check with your webmaster. Pick a spot in the page where it would be suitable to include the photo. If you plan a photo and a caption, this will take up the whole width of the page. Photos usually are about half the width of a typical web browser's page, and the caption or headline take the other half. So just find a place where you can insert a box about 200 pixels high and the full width of the page. If you're being more creative, and want to put the photo and caption in a vertically stacked table, they will only take half the page and you can mix in other items and text. At the place where you wish to insert the HTML with the photo etc. include a string like this:
<!--#include file="claripic/main.txt" --> with a path to the HTML file (it ends in .txt but it is really html) relative to your page. This assumes you are inserting the main HTML page generated by photograb. If you are generating multiple pages, the location may differ. If you are not at the root of your server, you have to use a virtual path, as in:
<!--#include virtual="claripic/main.txt" -->
Editing The TemplatesThe template will be found in a directory in your web server tree, usually called claripic. The "main" template (usually all you use) is called main.template. We provide several sample templates and you and your webmaster can select the one you like best, or write your own to suit your tastes. The template is actually a Perl program but you don't need to care much about that. You will be editing the part of the file between the two lines with "END_HTML" on them. This part is HTML with some very minor tweaks we will explain here.
HTML differencesThe most important difference is that you can insert variables into the text. These will be strings, or perhaps you would prefer to think of them as "macros" which have been calculated by the program that extracted the picture. They can be inserted right into your text. For example, if you have the string $headline in your HTML, the actual headline of the photo story will be inserted there. Below we describe all the variables you can insert. Now, because the character "$" has become special, you need to know that a few special characters must be prefaced with a backslash (\) if you want to use them in your HTML and get the literal character out. These are the dollar sign ($), the at-sign (@) and of course the backslash itself. (To get a single backslash, you must type two.) Thus to say "The cost is $5" you must write "The cost is \$5" instead. Now it turns out there is actually the ability to do a tremendous amount here, and if you know your Perl, you can do that, but mostly you can just edit the HTML to provide a nice layout for the components extracted from the picture.
Three TrapsHere are the mistakes you might make that you should watch out for:
The VariablesHere are the variables you can insert into your HTML
Sample TemplateHere is a nice template that lays out the headline, picture and caption as a 3 column table, with the picture in the middle.
<TABLE COLSPEC "L20 L20 L20"> <TR>
TestingTo test a new template, you will need a photo story with a small photo in it. Go to the newsgroup from which you are extracting photos, such as clari.news.photos, and find a small photo story. Small photo stories are about 10K in size and have "[Sm..." at the start of their Subject: line. Save one of these away for testing, or always extract the newest each time, as you like. You can save in a newsreader or go directly to the directory (usually /usr/spool/news/clari/news/photos) to get the file. Find out where your sysadmin has installed photograb, and if you have permissions to run it. Your admin may also make a special version for testing that does not write on the live files, which is a good idea. You can do that yourself by using the "dir=." option to photograb when you run it, to have it read the template from the current directory and write its picture and main.txt file there.
photograb dir=. <sample_photo_article
Notes on synchronizationIf you plan to provide links from photos, captions etc. to "news:" URLs with the message-id of the story or large photo story, you must beware of potential synchonization problems. If the web page and the news server are not in sync, a link on the web server may end up pointing to a story that has not yet arrived, or possibly been updated (deleted and replaced with a newer version.) If you want, instead of linking to the story itself, you can link to the newsgroups it is in, either directly to clari.news.photos, for example, or to the main newsgroup of the story (provided to you in the variable $newsgroup). This will take the user to a menu of the related stories, including that story as one of the most recent. Such a link is a pain if the goal is to read just the story, but it is assured to work and sometimes leads to more interesting material.
ClariCGIAn ideal way to provide a link off the photo is with ClariCGI. You can use this in several ways to assure the link always works. For example, a ClariCGI link of the form /cgi-bin/claricgi/?;g+;m:$message_id will link to the message-id provided, but cause it to search for an update under the same slug if that message isn't found. Another way to do this is to have a ClariCGI query that will return the same story used to generate the photo. If you are always using the latest photo from clari.news.photos, then the simple URL of
/cgi-bin/claricgi/?;g:clari.news.photos will always return that latest photo. Of course it only works for users enabled for ClariCGI on your site, and not outsiders, which is how it should be.
|
||
|