Data::Microformat::hFeed - A module to parse and create hFeeds
use Data::Microformat::hFeed; my $feed = Data::Microformat::hFeed->parse($a_web_page); print "Feed title is ".$feed->title; print "Feed author is ".$feed->author->fullname; foreach my $entry ($feed->entries) { print $entry->title."\n"; } # Create a new feed from scratch my $feed = Data::Microformat::hFeed->new; $feed->id(rand().time().$$); $feed->title("A feedtitle"); $feed->tagline("Some pithy tagline"); $feed->description("Somebody did something"); $feed->modified(DateTime->now); $feed->copyright({ href => $url, text => 'Some licence' }); foreach my $category (qw(cat1 cat2 cat3)) { $feed->categoriess($tags); } $feed->author($hcard); $feed->entries($entry);
An hFeed is a microformat used to contain hEntries.
This module exists both to parse existing hFeeds from web pages, and to create new hFeeds so that they can be put onto the Internet.
To use it to parse an existing hFeed (or hFeeds), simply give it the content of the page containing them (there is no need to first eliminate extraneous content, as the module will handle that itself):
my $feed = Data::Microformat::hFeed->parse($content);
If you would like to get all the feeds on the webpage, simply ask using an array:
my @feeds = Data::Microformat::hFeed->parse($content);
To create a new hFeed, first create the new object:
my $feed = Data::Microformat::hFeed->new;
Then use the helper methods to add any data you would like. When you're ready to output in the hFeed HTML format, simply write
my $output = $feed->to_html;
And $output will be filled with an hFeed representation, using <div> tags exclusively with the relevant class names.
The microformat class name for a feed; to wit, "hfeed"
This is a method to list all the fields on an address that can hold exactly one value.
This is a method to list all the fields on an address that can hold multiple values.
This method overrides but provides the same functionality as the method of the same name in Data::Microformat, with the optional addition of $source_url. If present, this latter term will set the link and the base of the feed automatically.
The id of this feed.
The title of this feed.
The base of this feed if available.
The permalink of this feed.
The language of this feed.
The tagline of this feed if available.
The description of this feed if available.
When this feed was modified - returns a DateTime object.
Returns a hash ref containing the copyright information for this feed.
The hash ref may have any or all of the following keys: text, href.
text
href
The name of the feed generator.
All the categories for this feed.
The author of this feed. Returns a Data::Microformat::hCard object.
The geo location information for this feed. Returns a Data::Microformat::geo object.
The entries for this feed. Returns Data::Microformat::hFeed::hEntry objects.
Return this hFeed as HTML
Please report any bugs or feature requests to bug-data-microformat at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Microformat. I will be notified,and then you'll automatically be notified of progress on your bug as I make changes.
bug-data-microformat at rt.cpan.org
Simon Wistow, <swistow@sixapart.com>
<swistow@sixapart.com>
Copyright 2008, Six Apart Ltd. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install Data::Microformat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Microformat
CPAN shell
perl -MCPAN -e shell install Data::Microformat
For more information on module installation, please visit the detailed CPAN module installation guide.