The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Netscape::Bookmarks::Category - manipulate, or create Netscape Bookmarks files

SYNOPSIS

  use Netscape::Bookmarks;

  #parse an existing file
  my $bookmarks = new Netscape::Bookmarks $bookmarks_file;

  #print a Netscape compatible file
  print $bookmarks->as_string;

DESCRIPTION

The Netscape bookmarks file has several basic components:

        title
        folders (henceforth called categories)
        links
        aliases
        separators

On disk, Netscape browsers store this information in HTML. In the browser, it is displayed under the "Bookmarks" menu. The data can be manipulated through the browser interface.

This module allows one to manipulate the bookmarks file programmatically. One can parse an existing bookmarks file, manipulate the information, and write it as a bookmarks file again. Furthermore, one can skip the parsing step to create a new bookmarks file and write it in the proper format to be used by a Netscape browser.

The Bookmarks.pm module simply parses the bookmarks file passed to it as the only argument to the constructor:

        my $bookmarks = new Netscape::Bookmarks $bookmarks_file;

The returned object is a Netscape::Bookmarks::Category object, since the bookmark file is simply a collection of categories that contain any of the components listed above. The top level (i.e. root) category is treated specially and defines the title of the bookmarks file.

Methods

Netscape::Bookmarks::Category->new( \%hash )

The new method creates a Category. It takes a hash reference that specifies the properties of the category. The valid keys in that hash are

        folded                  collapsed state of the category ( 1 or 0 )
        title
        add_date
        description
$category->add( $object )

The add() function adds an element to a category. The element must be a Alias, Link, Category, or Separator object. Returns TRUE or FALSE.

$category->add_desc( $object )

Adds a description to the category.

$category->title()

Returns title to the category.

$category->id()

Returns the ID of the category. This is an arbitrary, unique number.

$category->description

Returns the description of the category

$category->folded( $object )

Returns the folded state of the category (TRUE or FALSE). If the category is "folded", Netscape shows a collapsed folder for this category.

$category->add_date()

Returns the ADD_DATE attribute of the category.

$category->elements()

Returns an array reference to the elements in the category.

$category->categories()

Returns a list of the Category objects in the category.

$category->links()

Returns a list of the Link objects in the category.

$category->as_headline()

Returns an HTML string representation of the category, but not the elements of the category.

$category->as_string()

Returns an HTML string representation of the category as the top level category, along with all of the elements of the category and the Categories that it contains, recursively.

SOURCE AVAILABILITY

This source is part of a SourceForge project which always has the latest sources in CVS, as well as all of the previous releases.

        http://sourceforge.net/projects/nsbookmarks/

If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.

AUTHOR

brian d foy, <bdfoy@cpan.org>

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

If you send me modifications or new features, I will do my best to incorporate them into future versions. You can interact with the Sourceforge porject for this module at http://sourceforge.net/projects/nsbookmarks/.

SEE ALSO

Netscape::Bookmarks