NAME

Whatsnew - Automatic maintainance of the html file with links (URLS) to the latest updates (htmls)


SYNOPSIS

use Whatsnew;

  my $o = Whatsnew->new(
                        target=>'/full_path_to/whatsnew.html',
                        limit => 20,
                       );

  $o->add(
          link_url => 'http://nowhere.com/new_index.html',
          link_title => 'New link',
          dir_url => 'http://nowhere.com',
          dir_title => 'The main Dir',
          description => 'This is a description of the new link',
         );

  $o->delete(
             link_url => 'http://nowhere.com/index.html'
            );

  $o->save;


DESCRIPTION

This perl5 module updates the target file when some changes are done to the web site. When you add/update/remove some files use this module to keep the 'latest updates' file updated

The idea is to have a html file with special format (I made it with table), which is updated automatically when some change to your WWW site is done. Just add a little snippet of code to the function that changes the site (writes/deletes the file) to call this module, or run it manually in case you are the one who perform the changes.

The number of links to keep is specified by 'limit' parameter of the new() method If you add a link and your list of links cross the limit the oldest links will be removed (the ones at the bottom). The fresh links go to the top of the list.

The date of modification is automatically handled by the module, the html shows the modification dates.

When you do update, there is a big chance that the link is still on the whatsnew page. But you don't have to try to delete the previous version of the link, Whatsnew does it automatically, when you call the add() method, Whatsnew first deletes the previous instance of the link if it finds such.

After you create call new() method, you can add/delete as many links as you want and only when you call save() method the file will be updated and saved to the disk.

new()
Initialize the object. Specify the target file and the limit of links to keep.

  my $o = Whatsnew->new(
                        target=>'/full_path_to/whatsnew.html',
                        limit => 20,
                       );

  target is the full path to the file you want to work with (perl will
  die of the file will be not in place or it'll be inaccessable )

  limit is optional parameter, the default is specified by
  LIMIT_DEFAULT (=10). It tells how many links to keep on the page.
  When one cross the limit, the oldest files are getting deleted

add()
  add a new item to top of list of links. delete the old one if it
  existed before on the list.  The link_url parameter is unique per
  whatsnew file.

  $o->add(
          link_url => 'http://nowhere.com/new_index.html',
          link_title => 'New link',
          dir_url => 'http://nowhere.com',
          dir_title => 'The main Dir',
          description => 'This is a description of the new link',
         );

  link_url - the URL of the updated link (it's the key of the whole item)

  link_title - the title of the URL, the string that user will see

  dir_url - the URL of the parent Directory so user will be able to go
  directly to the updated directory

  dir_title - the title of the parent directory, the string that user will see

  description - when user put mouse over the link_url, the description
  will show up at the status bar of the browser (browser version < 4
  of netscape/explorer) or in a new layer (similar to ALT) using the
  dynamic html (browser version >= 4 of netscape/explorer)

delete()
  Delete some item from the list of links. The item is identified by 
  the unique link_url.

  $o->delete(
             link_url => 'http://nowhere.com/index.html'
            );

  link_url - pass the link_url of the item you want to delete

  or directly
  $o->delete('http://nowhere.com/index.html');

save()
  save the modified html into target file. This method was added to allow perfoming more than one
add/delete operation at once. So you can call a few add() and delete() methods and when you have
finished call the save() method to save the changes. 

  $o->save;

EXAMPLES

Example 1: add link
  use Whatsnew;

  my $o = Whatsnew->new(
                        target=>'/full_path_to/whatsnew.html',
                        limit => 20,
                       );

  $o->add(
          link_url => 'http://nowhere.com/new_index.html',
          link_title => 'New link',
          dir_url => 'http://nowhere.com',
          dir_title => 'The main Dir',
          description => 'This is a description of the new link',
         );

  $o->save;

Example 2: remove link
  use Whatsnew;

  my $o = Whatsnew->new(
                        target=>'/full_path_to/whatsnew.html',
                        limit => 20,
                       );

  $o->delete(
             link_url => 'http://nowhere.com/index.html'
            );

  $o->save;

Example 3: add and delete links
  use Whatsnew;

  my $o = Whatsnew->new(
                        target=>'/full_path_to/whatsnew.html',
                        limit => 20,
                       );

  $o->add(
          link_url => 'http://nowhere.com/new_index.html',
          link_title => 'New link',
          dir_url => 'http://nowhere.com',
          dir_title => 'The main Dir',
          description => 'This is a description of the new link',
         );

  $o->delete(
             link_url => 'http://nowhere.com/index.html'
            );

  $o->save;

Example 4: add and delete links without creating an object
  use Whatsnew;

  Whatsnew->new
  (
   target=>'/full_path_to/whatsnew.html',
   limit => 20,
  )->add
  (
   link_url => 'http://nowhere.com/new_index.html',
   link_title => 'New link',
   dir_url => 'http://nowhere.com',
   dir_title => 'The main Dir',
   description => 'This is a description of the new link',
  )->delete
  (
   link_url => 'http://nowhere.com/index.html'
  )->save;
 

CREATING NEW FILES

To create a new whatsnew file pick a file from ./tmpl directory or create you own. Whatsnew knows to work with 2 types of files.

Working with Server Side Includes
If the content of the file is located in the external include file, don't do a thing just when you call new(target=>'path/file') specify in the target the real file you want to edit

See the ./tmpl/whatsnew.shtml (see the includes)

Working with Plain HTML files
If you work directly with HTML files all you need is to separate the dynamic content (the one generated by this module) from the static one (that doesn't change: like your logo, background and other) so all you need is to add <!--end of top--> , <!--start of bottom--> tags to your HTML so you end up with HTML like this

  <HTML>
  YOUR HEADER custom html code and other stuff 
  <!--end of top-->
  Here Whatsnew will write the dynamic content
  <!--start of bottom-->
  Your BOTTOM custom html codeand other stuff
  </HTML>

See the ./tmpl/whatsnew.html template file

Important: When you edit the html file don't mangle with dynamic content section since it includes tags that essential to Whatsnew's parsing mechanism. If you break things Whatsnew will fail to parse the content and hence to update it

TODO

Empty

CHANGE LOG

  1. 01
            
      * Complete rewrite to make it OO Perl designed
      * New parsing scheme
      * Dynamic target and limit value specification 
    

      04/18/97 by Stas, Bekman <stas@stason.org> 
    

  2. 02
      * Internal locking, 
      * Custom Deletion, 
      * Converted to perl5 
    

      11/14/97 by Stas, Bekman <stas@stason.org> 
    

  3. 01
      * The first draft has been written 
    

      09/04/97 by Stas, Bekman <stas@stason.org>
    

AUTHOR

Stas, Bekman

SEE ALSO

perl(1).