The following applies to any version of netcomics, including the current one because of backwards-compatibility. However, Starting with version 0.5, it is recommended you use the new version.
The following table describes the RLI hash structure.
Field | Format | Example | Description |
---|---|---|---|
name | Full_Name- YYMMDD.filetype |
strftime("My_Comic- %y%m%d.gif",@ltime) |
The name of the file the comic is to be saved as. There isn't much flexibility here with what you can do, because this field is used to obtain several key pieces of information. When the -l option is given to netcomics, it will take this field from every RLI, and strip away the date & file extension, and remove any underscores to create the name of the comic. This same thing is performed for webpage creation, too. |
base | URL | http://www.company.com/ | This should be the part of the URL that is common between the page's URL and the comic's URL. Typically, this is just the main URL for the website. |
page | part of a URL or undef |
strftime(archives/mycomic- %y%m%d.html",@ltime) |
This field is either set to undef, or completes the URL when appended to base for the HTML page that contains a link to the comic. When set to undef, the next field, expr, is not used as a regular expression, but instead is appended to base as-is to complete the URL used to obtain the comic strip. |
expr | regular expression or part of a URL |
(comics/mycomic-\\d+.gif) | This field is either a regular expression used to find the last part of the URL for the comic, or is the last part of the URL for the comic itself. When the page field is left undefined, this field will not be used as a regular expression, but will be appended to base, as-is to complete the URL used to obtain the comic strip. When page is defined, this field is used to match on some text in the page downloaded by the URL made up of base and page. When used as a regular expression, it is required that a pair of parenthesis is left around the part of the text being matched on to be used as the completing part of the URL to obtain the comic strip. There only needs to be one set of parenthesis. If more than one pair exists, only the one that causes $1 to be defined in the perl code will be used (IOW, nothing fancy here. netcomics doesn't have any special logic, and is coded to only deal with $1). |
The global @lof list variable contains the names of all of the functions that return RLI hashes. Add your function's name to this list with the code:
push(@lof,"myfunction");If you have more than one function to add, use write code like this:
push(@lof,("myfunction1","myfunction2"));
An RLI function takes one argument: the time as returned by time(). Your function should expect this to be today's time, so if the website you're getting a comic from, names its comics files with dates, you can use the time given to your function by subtracting from it the number of seconds prior to today the comic is. So, if the comics posted on the website are one week old, subtract from the argument given to your function (7*24*60*60). That is, the number of seconds in one week. You can then use the standard POSIX functions to produce strings from the time you calculated. Here's an example:
push(@lof,"uf"); #UserFriendly http://www.userfriendly.org/cartoons/ sub uf { my @ltime = gmtime(shift(@_)); my $rec = { 'name' => strftime("User_Friendly-%y%m%d.gif",@ltime), 'base' => "http://www.userfriendly.org", 'page' => lc strftime("/cartoons/archives/%y%b/%Y%m%d.html", @ltime), 'expr' => lc strftime("(\/cartoons\/archives\/%y%b\/uf\\d+\.gif)", @ltime) }; return $rec; }
Note that the perl function, lc() (lower case) is also used to help produce the proper string.
Your function should then return the RLI (as a reference, not as the hash itself), and it will be used by netcomics. Put the function in a file that is readible to all users in /usr/lib/netcomics, and netcomics will find it and use it without any modification to its own code.