Data formats

Feeds

RSS, Atom and JSON Feed read as one shape: news on a dashboard, a podcast's episodes, a blogroll.

Version 1.0.0 · 1 function · 1 crate

#rss#atom#news#podcasts

Functions

What use feed.qwer gives a program, with the types Quillo sees. To take only some, or under other names: use feed_parse from feed (Quillo 0.6).

feed_parse(text: str) → anyor an error

A feed as { title, link, entries: [{ id, title, link, published, summary, authors }] }, newest as the feed orders them; times are RFC 3339 text.

Get it

$ quillo install feed               # feed.qwer into this folder$ quillo install feed --example     # and its example, feed.qwe

Or with curl:

$ curl -O https://quillolang.org/plugins/files/feed.qwer$ curl -O https://quillolang.org/plugins/files/feed.qwe

Then, in your program, all of it or only what you call:

main.qwe
use feed.qweruse feed_parse from feed      // Quillo 0.6: only these

It uses this crate, which cargo fetches the first time the plugin is built:

[dependencies]
feed-rs = "2"

Example

feed.qwe
// The newest posts of a feed (here a sample; `http.get(url)?.body` reads a live one).////   quillo run feed.qwe      then open http://localhost:8080/newsuse "feed.qwer"let sample = `<?xml version="1.0"?><rss version="2.0"><channel><title>Quillo blog</title><link>https://quillolang.org/blog/</link><item><title>Quillo is the accidental name</title><link>https://quillolang.org/blog/the-accidental-name/</link><pubDate>Tue, 02 Jul 2024 09:00:00 GMT</pubDate></item><item><title>A Node is not Enough</title><link>https://quillolang.org/blog/a-node-is-not-enough/</link><pubDate>Mon, 12 Jan 2026 09:00:00 GMT</pubDate></item></channel></rss>`route GET /news {    let f = feed_parse(sample)?    { site: f.title, posts: f.entries | map((e) => { title: e.title, link: e.link, published: e.published }) }}
$ quillo run feed.qwe$ curl 'localhost:8080/news'

Source

feed.qwer
//! RSS, Atom and JSON Feed read as one shape: news on a dashboard, a podcast's episodes, a blogroll.//! version: 1.0.0//!//! [dependencies]//! feed-rs = "2"use serde_json::{json, Value};/// A feed as `{ title, link, entries: [{ id, title, link, published, summary, authors }] }`, newest as the feed orders them; times are RFC 3339 text.pub fn feed_parse(text: &str) -> Result<Value, String> {    let f = feed_rs::parser::parse(text.as_bytes()).map_err(|e| e.to_string())?;    let entries: Vec<Value> = f.entries.iter().map(|e| json!({        "id": e.id,        "title": e.title.as_ref().map(|t| t.content.clone()),        "link": e.links.first().map(|l| l.href.clone()),        "published": e.published.or(e.updated).map(|d| d.to_rfc3339()),        "summary": e.summary.as_ref().map(|t| t.content.clone()),        "authors": e.authors.iter().map(|a| a.name.clone()).collect::<Vec<_>>(),    })).collect();    Ok(json!({        "title": f.title.map(|t| t.content),        "link": f.links.first().map(|l| l.href.clone()),        "entries": entries,    }))}
Thread
97Useful? Like it, or add to its thread below.

Thread 0 posts

On Feeds: questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.