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

NAME

Bookmarks::Parser - A class to parse and represent collections of bookmarks.

VERSION

This documentation refers to version 0.01.

SYNOPSIS

    use Bookmarks::Parser;
    my $parser = Bookmarks::Parser->new();
    my $bookmarks = $parser->parse({filename => 'bookmarks.html'});
    my @rootitems = $bookmarks->get_top_level();

DESCRIPTION

The Bookmarks::Parser class implements a collection of bookmarks. Supported representations currently include:

Netscape/Mozilla
Opera
A9
Delicious

The various types of collections are automatically recognised. Each is parsed into a tree like structure which can then be accessed in parts or re-written as any of the supported bookmark collection types. Two types of bookmark item are distinguished, folder objects can contain other items, url objects cannot. For bookmark collections with tagging instead of folders, the tags are stored as folders. Each unique URL is stored exactly once, but can appear under many folder items.

SUBROUTINES/METHODS

new (constructor)

Parameters: none

Create a new parser object, no parameters as yet.

parse (method)

Parameters: hashref of named arguments: filename, url, user, passwd

Parse a collection of bookmarks. This can be passed a filename of a bookmarks file on a local disk, or a url and user/passwd combination of a bookmarks collection stored on a remote server.

Currently, best guesses are made as to which type of bookmarks collection is being parsed, Opera, Netscape/Mozilla and Delicious are supported so far.

set_title (method)

Parameters: title - String

Some bookmarks collections (Netscape) have an overall title for the collection, this method can be used to set/change the title.

add_bookmark (method)

Parameters: bookmark - Bookmarks::Bookmark parent - Bookmarks::Bookmark

Add a new Bookmarks::Bookmark object somewhere in the tree. If no parent object is given, the insertion is made as a top level bookmark folder/tag. If a parent object is given, the item appears under it in a tree-like fashion. The parent object needs to be of type folder.

as_a9 (constructor)

Returns a copy of this object as a Bookmarks::A9 object, which can be imported into a9.

as_opera (constructor)

Parameters: none

Returns a copy of this object as a Bookmarks::Opera object, which can be written out as an Opera bookmarks file.

as_netscape (constructor)

Parameters: none

Returns a copy of this object, as a Bookmarks::Netscape object, which can be written out as an Opera bookmarks file.

as_xml (constructor)

Parameters: none

Returns a copy of this object, as a Bookmarks::XML object, which can be saved as an XML file.

write_file (method)

Parameters: a hashref of named arguments: filename, type

Create a file containing the bookmarks collection to disk. The default type will be the same as the parsed in file, or the type converted to last by one of the as_ functions. Types that can be given are: opera, netscape and delicious.

as_string (method)

Parameters: type (optional) - String

Return the contents of the bookmarks collection as a string. This is just the same content as will be written to the file by the write_file method.

get_header_as_string (method)

Parameters: type (optional) - String

Called by as_string to get a header for the bookmarks collection. This is defined as all the text that appears in the bookmarks file before the actual bookmarks.

Parameters: type (optional) - String

Called by as_string to get a footer for the bookmarks collection. This is defined as all the text that appears in the bookmarks file after the actual bookmarks.

get_top_level (method)

Parameters: none

Returns a list of the top level (root) items in the collection.

set_top_level

Parameters: none

Add a list of top level (root) items to the collection.

rename (method)

Parameters: item - Bookmarks::Bookmark newname - String

Rename an item in the collection. (Should be in Bookmarks::Bookmark).

find_items

Parameters url name

Will look through the parsed bookmarks and return bookmarks that matches either url or name (based on a regex match)

merge <bookmarks object>

Takes another bookmark object, and merges it into this one.

get_folder_contents (method)

Parameters: folder - Bookmarks::Bookmark

Returns a list of items that are children of the given folder item.

get_from_id <id>

Returns an element based on the element id.

get_path_of <elem>

Returns the full path of a given element.

write_url

Not yet implemented.

DEPENDENCIES

WWW::A9TToolbar

HTML::TreeBuilder

Net::Delicious

XML::Simple

Test::More

BUGS AND LIMITATIONS

None known currently, please email the author if you find any.

AUTHOR

Jess Robinson <castaway@desert-island.demon.co.uk>

Marcus Ramberg <mramberg@cpan.org>

Cosimo Streppone <cosimo@cpan.org>

LICENSE

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