NAME

URI::Collection - Input and output link collections in different formats

SYNOPSIS

use URI::Collection;

$c = URI::Collection->new(links => $bookmark_file);
$c = URI::Collection->new(links => $favorite_directory);
$c = URI::Collection->new(
    links => [ $bookmark_file, $favorite_directory ],
);

$links = $c->fetch_items(
    category => $regexp_1,
    title    => $regexp_2,
    url      => $regexp_3,
);

if ($items = $c->is_item($regexp)) {
    print Data::Dumper($items);
}

$bookmarks = $c->as_bookmark_file;
$c->as_bookmark_file(save_as => $filename);

$favorites = $c->as_favorite_directory;
$c->as_favorite_directory(save_as => $directory);

DESCRIPTION

An object of class URI::Collection represents the links and categories in parsed Netscape style bookmark files and Windows "Favorites" directories, with output in either style.

METHODS

new

$c = URI::Collection->new(links => $bookmark_file);
$c = URI::Collection->new(links => $favorite_directory);
$c = URI::Collection->new(
    links => [ $bookmark_file, $favorite_directory ],
);

Return a new URI::Collection object.

This method mashes link store formats together, simultaneously.

as_bookmark_file

$bookmarks = $c->as_bookmark_file;
$c->as_bookmark_file(save_as => $filename);

Output a Netscape style bookmark file as a string with the file contents.

Optionally, save the bookmarks as a file to disk, if given a save_as argument.

as_favorite_directory

$favorites = $c->as_favorite_directory;
$c->as_favorite_directory(save_as => $directory);

Output a M$ Windows "Favorites" tree as a hash reference, where the keys are the subdirectories (categories) and the values are array references with the contents of M$ Windows *.url files as string elements.

This tree is one dimensional. That is, the nested categories are represented by "slash separated paths". An example will elucidate:

{ 'foo'     => [ $link1, $link2, ],
  'foo/bar' => [ $link3, $link4, ],
  'baz'     => [ $link5, ],
  'baz/x/y' => [ $link6, $link7, ], }

This path representation is magically converted to the proper Win32 scheme when expressed with the as_favorite_directory method.

If a save_as argument is provided, this method will write the "Favorites" directory to disk with the value as the top level directory name (and then return that same name).

fetch_items

$items = $c->fetch_items(
    category => $regexp_1,
    title    => $regexp_2,
    url      => $regexp_3,
);

Return a list of links that have titles, urls or categories similar to the given regular expressions.

Note that if a category argument is supplied, only links under matching categories will be found. If no category argument is provided, any link with a matching title or url will be returned. If no arguments are provided, all links are returned.

is_item

$items = $c->is_item($regexp);

Return the items whose titles or urls match the given regular expression.

Note that this method is just fetch_items with the no category argument and identical title and url pattern.

DEPENDENCIES

Carp

Cwd

File::Spec

File::Find

File::Path

IO::String

Config::IniFiles

Netscape::Bookmarks::Link

TO DO

Ignore redundant links.

Optionally return the M$ Favorites directory structure (as a variable) instead of writing it to disk.

Allow input/output of file and directory handles.

Allow slicing of the category-links structure.

Allow link munging to happen under a given category or categories only.

Check if links are active.

Update link titles and URLs if changed or moved.

Mirror links?

Handle other bookmark formats (including some type of generic XML), and "raw" (CSV) lists of links, to justify such a generic package name. This includes different platform flavors of every browser.

Move the Favorites input/output functionality to a seperate module like URI::Collection::Favorites::IE::Windows and URI::Collection::Favorites::IE::Mac, or some such. Do the same with the above mentioned "platform flavors", such as Opera and Mosaic "Hotlists", and OmniWeb bookmarks, etc.

SEE ALSO

http://www.cyanwerks.com/file-format-url.html

There are an enormous number of web-based bookmark managers out there (see http://useful.webwizards.net/wbbm.htm), which I don't care about at all. What I do care about are multi-format link converters. Here are a few that I found:

Online manager: http://www.linkagogo.com/

CDML Universal Bookmark Manager (for M$ Windows only): http://www.cdml.com/products/ubm.asp

OperaHotlist2HTML: http://nelson.oit.unc.edu/~alanh/operahotlist2html/

bk2site: http://bk2site.sourceforge.net/

Windows favorites convertor: http://www.moodfarm.demon.co.uk/download/fav2html.pl

bookmarker: http://www.renaghan.com/pcr/bookmarker.html

Columbine Bookmark Merge: http://home.earthlink.net/~garycramblitt/

XBEL Bookmarks Editor: http://pyxml.sourceforge.net/topics/xbel/

And here are similar perl modules:

URI::Bookmarks

BabelObjects::Component::Directory::Bookmark

WWW::Bookmark::Crawler

Apache::XBEL

THANK YOU

A special thank you goes to my friends on rhizo #perl for answering my random questions. : )

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2003 by Gene Boggs

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