diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-27 22:40:56 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-27 22:47:46 +0100 |
commit | 261a71a0a4ad42da84d310d86137aac3de9f843b (patch) | |
tree | 5d04ef8c9e13bee56f8152e62dd4f35c7ef24478 /pkgs/by-name/ba/back/src/web/mod.rs | |
parent | feat(back/src/issues/issue): implement Display for Author (diff) | |
download | nixos-server-261a71a0a4ad42da84d310d86137aac3de9f843b.zip |
feat(back): add rss feed
Co-authored-by: Silas Schöffel <sils@sils.li>
Diffstat (limited to 'pkgs/by-name/ba/back/src/web/mod.rs')
-rw-r--r-- | pkgs/by-name/ba/back/src/web/mod.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/by-name/ba/back/src/web/mod.rs b/pkgs/by-name/ba/back/src/web/mod.rs index 35dc59f..c7ba9d9 100644 --- a/pkgs/by-name/ba/back/src/web/mod.rs +++ b/pkgs/by-name/ba/back/src/web/mod.rs @@ -106,6 +106,32 @@ pub fn closed(config: &State<BackConfig>) -> error::Result<RawHtml<String>> { issue_list_boilerplate(config, Status::Closed, Status::Open) } +#[get("/issues/feed")] +pub fn feed(config: &State<BackConfig>) -> error::Result<RawHtml<String>> { + use rss::{ChannelBuilder, Item, ItemBuilder}; + + let items: Vec<Item> = issues_from_repository(&config.repository.to_thread_local())? + .into_iter() + .map(|issue| issue.collapse()) + .map(|issue| { + ItemBuilder::default() + .title(issue.title.to_string()) + .author(issue.author.to_string()) + .description(issue.message.to_string()) + .pub_date(issue.timestamp.to_string()) + .build() + }) + .collect(); + + let channel = ChannelBuilder::default() + .title("Issues") + .link("http://example.com") + .description("An RSS feed.") + .items(items) + .build(); + Ok(RawHtml(channel.to_string())) +} + #[get("/issue/<prefix>")] pub fn show_issue( config: &State<BackConfig>, |