diff options
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>, |