From ff66332ea76be0b6d2660d20ec5433a6e1f32924 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 4 Oct 2019 15:02:01 +0200 Subject: [PATCH] news: add atom feed --- dist/templates/atom.xml.hbs | 19 +++++++++++++++++++ dist/templates/layout.html.hbs | 1 + hagrid-routes.conf | 6 ++++++ src/web/mod.rs | 13 +++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 dist/templates/atom.xml.hbs diff --git a/dist/templates/atom.xml.hbs b/dist/templates/atom.xml.hbs new file mode 100644 index 0000000..9d1614a --- /dev/null +++ b/dist/templates/atom.xml.hbs @@ -0,0 +1,19 @@ + + + keys.openpgp.org + + urn:uuid:8e783366-73b1-460e-83d3-42f01046646d + 2019-09-12T12:00:00Z + + Launching a new keyserver! 🚀 + + 2019-06-12T12:00:00Z + urn:uuid:a071a6dc-f8ea-43de-b853-bd6d8bbe063f + + + Three months after launch ✨ + + 2019-09-12T12:00:00Z + urn:uuid:1bd5412a-f480-4c3f-a72d-c9b7a849f544 + + diff --git a/dist/templates/layout.html.hbs b/dist/templates/layout.html.hbs index 80a803c..4444747 100644 --- a/dist/templates/layout.html.hbs +++ b/dist/templates/layout.html.hbs @@ -3,6 +3,7 @@ + keys.openpgp.org diff --git a/hagrid-routes.conf b/hagrid-routes.conf index 613ea5e..ef683de 100644 --- a/hagrid-routes.conf +++ b/hagrid-routes.conf @@ -195,6 +195,12 @@ location = / { proxy_pass http://127.0.0.1:8080; } +# cache "about" pages +location = /atom.xml { + proxy_cache static_cache; + proxy_pass http://127.0.0.1:8080; +} + # cache "about" pages location /about { proxy_cache static_cache; diff --git a/src/web/mod.rs b/src/web/mod.rs index c1b6bad..f38130a 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -68,6 +68,8 @@ pub enum MyResponse { Success(HagridTemplate), #[response(status = 200, content_type = "plain")] Plain(String), + #[response(status = 200, content_type = "xml")] + Xml(HagridTemplate), #[response(status = 200, content_type = "application/pgp-keys")] Key(String, ContentDisposition), #[response(status = 200, content_type = "application/pgp-keys")] @@ -101,6 +103,11 @@ impl MyResponse { MyResponse::Success(HagridTemplate(tmpl, context_json)) } + pub fn xml(tmpl: &'static str) -> Self { + let context_json = serde_json::to_value(templates::Bare { dummy: () }).unwrap(); + MyResponse::Xml(HagridTemplate(tmpl, context_json)) + } + pub fn plain(s: String) -> Self { MyResponse::Plain(s) } @@ -311,6 +318,11 @@ fn news() -> MyResponse { MyResponse::ok_bare("about/news") } +#[get("/atom.xml")] +fn news_atom() -> MyResponse { + MyResponse::xml("atom") +} + #[get("/about/faq")] fn faq() -> MyResponse { MyResponse::ok_bare("about/faq") @@ -367,6 +379,7 @@ fn rocket_factory(mut rocket: rocket::Rocket) -> Result { root, about, news, + news_atom, privacy, apidoc, faq,