diff options
Diffstat (limited to 'pkgs/by-name/ba/back/src')
-rw-r--r-- | pkgs/by-name/ba/back/src/main.rs | 3 | ||||
-rw-r--r-- | pkgs/by-name/ba/back/src/web/mod.rs | 26 |
2 files changed, 28 insertions, 1 deletions
diff --git a/pkgs/by-name/ba/back/src/main.rs b/pkgs/by-name/ba/back/src/main.rs index b75737a..961c39b 100644 --- a/pkgs/by-name/ba/back/src/main.rs +++ b/pkgs/by-name/ba/back/src/main.rs @@ -14,6 +14,7 @@ use std::process; use clap::Parser; use config::BackConfig; use rocket::routes; +use web::feed; use crate::web::{closed, open, show_issue, styles}; @@ -39,7 +40,7 @@ async fn rocket_main() -> Result<(), error::Error> { let config = BackConfig::from_config_file(&args.config_file)?; rocket::build() - .mount("/", routes![open, closed, show_issue, styles]) + .mount("/", routes![open, closed, show_issue, styles, feed]) .manage(config) .ignite() .await 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>, |