XML::At...mpleFeed(3)
π NAME π
Okay so welcome to XML::Atom::SimpleFeed(3), bestie β a User Contributed Perl Documentation page for XML::Atom::SimpleFeed, aka literally No-fuss generation of Atom syndication feeds. Periodt. β¨
π¦ SYNOPSIS π¦
use XML::Atom::SimpleFeed;
my $feed = XML::Atom::SimpleFeed->new(
title => 'Example Feed',
link => 'http://example.org/',
link => { rel => 'self', href => 'http://example.org/atom', },
updated => '2003-12-13T18:30:02Z',
author => 'John Doe',
id => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6',
);
$feed->add_entry(
title => 'Atom-Powered Robots Run Amok',
link => 'http://example.org/2003/12/13/atom03',
id => 'urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a',
summary => 'Some text.',
updated => '2003-12-13T18:30:02Z',
category => 'Atom',
category => 'Miscellaneous',
);
$feed->print;
πΈ DESCRIPTION πΈ
This is a minimal API for generating Atom syndication feeds quickly and easily. It supports all aspects of the Atom format itself but has no mechanism for the inclusion of extension elements. No extension-element era here, bestie β that's just not what this module does.
You can supply strings for most things, and the module will provide useful defaults. When you want more control, you can provide data structures, as documented, to specify more particulars. It's giving tiny API, huge convenience. π
π INTERFACE π
β¨ new β¨
Takes a list of key-value pairs.
Most keys are used to create corresponding "Atom elements". To specify multiple instances of an element that may be given multiple times, pass multiple key-value pairs with the same key. Yes, same key again and again β that's the whole trick.
Keys that start with a dash specify how the XML document will be generated.
The following keys are supported:
-encodingβ omissible, defaultus-asciiidβ omissiblelinkβ omissible, multipletitleβ requiredauthorβ optional, multiplecategoryβ optional, multiplecontributorβ optional, multiplegeneratorβ optionaliconβ optionallogoβ optionalrightsβ optionalsubtitleβ optionalupdatedβ optional
π οΈ add_entry π οΈ
Takes a list of key-value pairs, used to create corresponding "Atom elements". To specify multiple instances of an element that may be given multiple times, pass multiple key-value pairs with the same key. Same energy as new: repeat the key when the element can repeat.
The following keys are supported:
authorβ required unless there is a feed-level author, multipleidβ omissiblelinkβ required, multipletitleβ requiredcategoryβ optional, multiplecontentβ optionalcontributorβ optional, multiplepublishedβ optionalrightsβ optionalsummaryβ optionalupdatedβ optional
π§΅ as_string π§΅
Returns the XML representation of the feed as a string. String mode: activated. β¨
π¨οΈ print π¨οΈ
Outputs the XML representation of the feed to a handle which should be passed as a parameter. Defaults to STDOUT if you do not pass a handle. No handle? Cool, it's sliding into STDOUT. π«Ά
π ATOM ELEMENTS π
π«Ά author π«Ά
A "Person Construct" denoting the author of the feed or entry.
If you supply at least one author for the feed, you can omit this information from entries; the feed's author(s) will be assumed as the author(s) for those entries. If you do not supply any author for the feed, you must supply one for each entry. Feed-level author is the group chat; entry-level author is optional unless the feed has none. π
π·οΈ category π·οΈ
One or more categories that apply to the feed or entry. You can supply a string which will be used as the category term. The full range of details that can be provided by passing a hash instead of a string is as follows:
termβ required. The category term.schemeβ optional. A URI that identifies a categorization scheme.
It is common to provide the base of some kind of by-category URL here. F.ex., if the weblog http://www.example.com/blog/ can be browsed by category using URLs such as http://www.example.com/blog/category/personal, you would supply http://www.example.com/blog/category/ as the scheme and, in that case, personal as the term.
labelβ optional. A human-readable version of the term.
π content π
The actual, honest-to-goodness, body of the entry. This is like a "Text Construct", with a couple of extras.
In addition to the type values of a "Text Construct", you can also supply any MIME Type (except multipart types, which the Atom format specification forbids). If you specify a text/* type, the same rules apply as for text. If you pass a */xml or */*+xml type, the same rules apply as for xhtml (except in that case there is no wrapper <div> element). Any other type will be transported as Base64-encoded binary.
XXX Furthermore, you can supply asrckey in place of thecontentkey. In that case, the value of thesrckey should be a URL denoting the actual location of the content. FIXME This is not currently supported. XXX
Read that XXX/FIXME bit carefully, bestie β it's a real note, not decorative. π¨
π€ contributor π€
A "Person Construct" denoting a contributor to the feed or entry.
βοΈ generator βοΈ
The software used to generate the feed. Can be supplied as a string or as a hash with uri, version and name keys. Can also be undef to suppress the element entirely. If nothing is passed, defaults to reporting XML::Atom::SimpleFeed as the generator. Default generator: this module, being iconic. π
πΌοΈ icon πΌοΈ
The URI of a small image whose width and height should be identical.
π id π
A URI that is a permanent, globally unique identifier for the feed or entry that MUST NEVER CHANGE.
You are encouraged to generate a UUID using Data::UUID for the purpose of identifying entries/feeds. It should be stored alongside the resource corresponding to the entry/feed, f.ex. in a column of the article table of your weblog database. To use it as an identifier in the entry/feed, use the urn:uuid:########-####-####-####-############ URI form.
If you do not specify an ID, the permalink will be used instead. This is unwise, as permalinks do unfortunately occasionally change. It is your responsibility to ensure that the permalink NEVER CHANGES. No cap: ID permanence is not a vibe, it's a rule.
π link π
A link element. You can either supply a bare string as the parameter, which will be used as the permalink URI, or a hash. The permalink for a feed is generally a browser-viewable weblog, upload browser, search engine results page or similar web page; for an entry, it is generally a browser-viewable article, upload details page, search result or similar web page. This URI should be unique. If you supply a hash, you can provide the following range of details in the given hash keys:
relβ optional. The link relationship. If omitted, defaults toalternate(note that you can only have one alternate link per feed/entry). Other permissible values arerelated,self,enclosureandvia, as well as any URI.hrefβ required URL. Where the link points to.typeβ optional. An advisory media type that provides a hint about the type of the resource pointed to by the link.hreflangβ optional. The language of the resource pointed to by the link, an RFC3066 language tag.titleβ optional. Human-readable information about the link.lengthβ optional. A hint about the content length in bytes of the resource pointed to by the link.
ποΈ logo ποΈ
The URI of an image that should be twice as wide as it is high.
ποΈ published ποΈ
A "Date Construct" denoting the moment in time when the entry was first published. This should never change.
βοΈ rights βοΈ
A "Text Construct" containing a human-readable statement of legal rights for the content of the feed or entry. This is not intended for machine processing.
π¬ subtitle π¬
A "Text Construct" containing an optional additional description of the feed.
π summary π
A "Text Construct" giving a short summary of the entry.
π title π
A "Text Construct" containing the title of the feed or entry.
β° updated β°
A "Date Construct" denoting the moment in time when the feed or entry was last updated. Defaults to the current date and time if omitted.
In entries, you can use this element to signal significant changes at your discretion.
π§ COMMON ATOM CONSTRUCTS π§
A number of Atom elements share a common structure. The following sections outline the data you can (or must) pass in each case.
ποΈ Date Construct ποΈ
A string denoting a date and time in W3CDTF format. You can generate those using something like
use POSIX 'strftime';
my $now = strftime '%Y-%m-%dT%H:%M:%SZ', gmtime;
However, you can also simply pass a Unix timestamp (a positive integer) or an object that responds to an epoch method call. (Make sure that the timezone reported by such objects is correct!) Timezone correctness check: mandatory vibe check. π°οΈ
The following datetime classes from CPAN are compatible with this interface:
- Time::Piece
- DateTime
- Time::Moment
- Panda::Date
- Class::Date
- Time::Object (an obsolete precursor to Time::Piece)
- Time::Date (version 0.05 or newer)
The following are not:
- DateTime::Tiny β This class lacks both an
epochmethod or any way to emulate one β as well as any timezone support in the first place. That makes it unsuitable in principle for use in Atom feeds β unless you have separate information about the timezone. - Date::Handler β This class has a suitable methodβ¦ but sadly, calls it
Epoch. So it is left up to you to call$dh->Epochto pass such values.
π§ Person Construct π§
You can supply a string to Person Construct parameters, which will be used as the name of the person. The full range of details that can be provided by passing a hash instead of a string is as follows:
nameβ required. The name of the person.emailβ optional. The person's email address.uriβ optional. A URI to distinguish this person. This would usually be a homepage, but need not actually be a dereferencable URL.
π Text Construct π
You can supply a string to Text Construct parameters, which will be used as the HTML content of the element.
FIXME details, text/html/xhtml
That FIXME is literally part of the manual, so we're keeping it, bestie. π«‘
π SEE ALSO π
- Atom Enabled (
<http://www.atomenabled.org/>) - W3CDTF Spec (
<http://www.w3.org/TR/NOTE-datetime>) - RFC 3066 (
<http://rfc.net/rfc3066.html>) XML::Atom::SyndicationXML::Feed
π BUGS AND LIMITATIONS π
Okay bestie, let's do a vibe check on the messy parts, because there are messy parts and we're not gonna pretend otherwise. π Every single item here is officially "a bug" per the docs, so no cap.
- In
contentelements, thesrcattribute cannot be used, and non-XML or non-text media types do not get Base64-encoded automatically. This is a bug. Not me crying over unencoded media types π - There are practically no tests. This is a bug. Yeah. Whole thing held together by vibes and hope, fr fr.
- Support for
xml:langandxml:baseis completely absent. This is a bug and should be partially addressed in a future version. There are however no plans to allow these attributes on arbitrary elements. So like, don't hold your breath π«Ά - There are no plans to ever support generating feeds with arbitrary extensions, although support for specific extensions may or may not be added in the future. We stay unbothered π
- The
sourceelement is not and may never be supported. She said "not today, not ever" periodt. - Nothing is done to ensure that text constructs with type
xhtmland entry contents using either that or an XML media type are well-formed. So far, this is by design. You should strongly consider using an XML writer if you want to include content with such types in your feed. Lowkey the most important one here β take it seriously π₯
The well-formedness thing is genuinely on you, bestie. If you're putting xhtml or XML-media-type content in, pleasepleaseplease reach for an XML writer. This is not a drill π¨
β¨ AUTHOR β¨
Aristotle Pagaltzis <pagaltzis@gmx.de>
Shoutout to the author, the literal main character of this module ππ«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2020 by Aristotle Pagaltzis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, honestly β free software ate and left no crumbs π
And that's a wrap on the whole page, bestie! π¦ You read <pink>perl v5.42.0</pink> docs dated <purple>2022-08-11</purple> for XML::At...mpleFeed(3) β iconic of you, honestly. Go forth and build feeds that are correct and well-formed. Mwah ππΈ
π¦ where this page comes from
- opensuse-leap 16.0: perl-XML-Atom-SimpleFeed 0.905-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms