Data::Microformat::hFeed - A module to parse and create hFeeds


Data-Microformat documentation  | view source Contained in the Data-Microformat distribution.

Index


NAME

Top

Data::Microformat::hFeed - A module to parse and create hFeeds

SYNOPSIS

Top

    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);

DESCRIPTION

Top

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.

SUBROUTINES/METHODS

Top

class_name

The microformat class name for a feed; to wit, "hfeed"

singular_fields

This is a method to list all the fields on an address that can hold exactly one value.

plural_fields

This is a method to list all the fields on an address that can hold multiple values.

Data::Microformat::organization->from_tree($tree [, $source_url])

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.

id

The id of this feed.

title

The title of this feed.

base

The base of this feed if available.

language

The language of this feed.

tagline

The tagline of this feed if available.

description

The description of this feed if available.

modified

When this feed was modified - returns a DateTime object.

generator

The name of the feed generator.

categories

All the categories for this feed.

author

The author of this feed. Returns a Data::Microformat::hCard object.

geo

The geo location information for this feed. Returns a Data::Microformat::geo object.

entries

The entries for this feed. Returns Data::Microformat::hFeed::hEntry objects.

to_html

Return this hFeed as HTML

BUGS

Top

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.

AUTHOR

Top

Simon Wistow, <swistow@sixapart.com>

COPYRIGHT

Top

LICENSE

Top

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.


Data-Microformat documentation  | view source Contained in the Data-Microformat distribution.