Create An Atom Feed In Rust
Introduction
This is what I'm doing to make an Atom feed for my site. More notes below the code.
//! ```cargo
//! [dependencies]
//! atom_syndication = "0.12.2"
//! chrono = { version = "0.4.26", features = ["std"] }
//! uuid = { version = "1.6.1", features = ["v5"] }
//! ```
use *;
use *;
use BTreeMap;
use fs;
use Uuid;
Results
<p>Hello, world</p>
My Example Feed
urn:uuid:b71fc261-fc1a-4220-b43f-2be4b216c0b2
2024-01-02T23:29:27.999342+00:00
Alan W. Smith
https://www.example.com/
This Is A Title
urn:uuid:b1507332-d46c-5bcf-929a-f89c59e01bac
2023-12-17T10:33:55+05:00
Alan W. Smith
https://www.example.com/
- This is for an Atom feed. A similar crate exists for RSS (linked below)
- I went with Atom based off > this post > https : //peterbabic.dev/blog/using - uuid - in - atom - feed/ >
- The UUIDs work by creating a UUID4 that stays the same every time the feed is generated and then a UUID5 for each file based off an ID that's attached to the file
- The UUID5 is a combination of the main feeds UUID4 + the unique ID for the file. Given those two inputs the output is always the same. That lets the individual entry IDs stay the same even if their content changes.
- The [TODO: Code shorthand span ] is a [TODO: Code shorthand span ] which is an alias of [TODO: Code shorthand span ] from the chrono crate
- My content file dates don't have a timezone (e.g. [TODO: Code shorthand span ] ). The [TODO: Code shorthand span ] is my offset from GMT which I use to calculate the data to get to the [TODO: Code shorthand span ] that's needed
- The rest of the date code converts to the necessary object format that then outputs with a timezone like : [TODO: Code shorthand span ] in the feed
- There's a bunch of things set to [TODO: Code shorthand span ] across the code. The docs (linked below) list all those details
- The content comes out as HTML escaped characters. (e.g. [TODO: Code shorthand span ] becomes [TODO: Code shorthand span ] I've seen a bunch of other feeds that use CDATE, but the escaping works just fine in my reader (NetNewsWire)
- I put two outputs in the example. The first one outputs to a file with a config attached that pretty prints the contents. The second one outputs a string. I haven't figure out a way to pretty print that though
- I'm not sure what the 'rel' should be. I tried "canonical" at first, but it didn't work with RSS Parrot. I've now changed it to "self" which is what I've now seen on other feeds. We'll see what happens
Footnotes And References
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •
- •