From 2fc102796f986b018ea70351f53257cba960d66d Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Mon, 18 Mar 2024 20:02:22 -0700 Subject: [PATCH] cargofmt --- src/app/routes/index.rs | 6 ++-- src/atom_feed.rs | 77 ++++++++++++++++++++--------------------- src/lib.rs | 5 ++- src/main.rs | 5 ++- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/app/routes/index.rs b/src/app/routes/index.rs index a7f2688..148353c 100644 --- a/src/app/routes/index.rs +++ b/src/app/routes/index.rs @@ -94,8 +94,10 @@ fn IssueEntry(issue: IssueShort) -> impl IntoView { #[component] pub fn Home() -> impl IntoView { - let issues = - create_blocking_resource(move || {}, |_| fetch_issues()); + let issues = create_blocking_resource( + move || {}, + |_| fetch_issues(), + ); view! {
diff --git a/src/atom_feed.rs b/src/atom_feed.rs index de5f7c6..a3775a8 100644 --- a/src/atom_feed.rs +++ b/src/atom_feed.rs @@ -1,23 +1,23 @@ -use serde::{Serialize, Deserialize}; +use crate::state::AppState; +use atom_syndication::*; use axum::{ extract::{Path, State}, http::Request, response::{IntoResponse, Response}, routing::get, }; -use atom_syndication::*; -use crate::state::AppState; +use serde::{Deserialize, Serialize}; pub async fn atom_feed( State(app_state): State, ) -> impl IntoResponse { + use atom_syndication::Feed; use std::fs::File; -use std::io::{BufReader, sink}; -use atom_syndication::Feed; + use std::io::{sink, BufReader}; -let issues: Vec = sqlx::query_as!( - SqlIssueShort, - r#" + let issues: Vec = sqlx::query_as!( + SqlIssueShort, + r#" SELECT id, slug, @@ -29,15 +29,17 @@ FROM issue WHERE status = "publish" ORDER BY status, issue_date DESC LIMIT 5"# -) -.fetch_all(&app_state.pool) -.await.unwrap(); + ) + .fetch_all(&app_state.pool) + .await + .unwrap(); -let issues: Vec = issues.into_iter().map(IssueShort::from).collect(); + let issues: Vec = + issues.into_iter().map(IssueShort::from).collect(); -let mut newest_issue_date = None; + let mut newest_issue_date = None; -let entries: Vec = issues.into_iter().filter_map(|issue| { + let entries: Vec = issues.into_iter().filter_map(|issue| { let date = issue.issue_date.and_then(|v| { use atom_syndication::FixedDateTime; use std::str::FromStr; @@ -82,39 +84,37 @@ Some( EntryBuilder::default() content_type: Some("text/html".to_string()), })).build()) }).collect(); -let mut feed = Feed::default(); + let mut feed = Feed::default(); -feed.set_id("https://thisweekinbevy.com/".to_string()); -feed.set_updated(newest_issue_date.expect("having an issue should mean there is a most recent date")); -feed.set_title("This Week in Bevy"); -feed + feed.set_id("https://thisweekinbevy.com/".to_string()); + feed.set_updated(newest_issue_date.expect("having an issue should mean there is a most recent date")); + feed.set_title("This Week in Bevy"); + feed .set_logo("https://res.cloudinary.com/dilgcuzda/image/upload/v1708481576/thisweekinbevy/this-week-in-bevylight_uddwes.avif".to_string()); - feed - .set_icon("https://cdn.thisweekinbevy.com/favicon-32x32.png".to_string()); - feed - .set_authors(vec![ - Person { - name: "Chris Biscardi".to_string(), - email: None, - uri: Some("https://www.christopherbiscardi.com/".to_string()) - }]); - feed - .set_links(vec![ - Link { + feed.set_icon( + "https://cdn.thisweekinbevy.com/favicon-32x32.png" + .to_string(), + ); + feed.set_authors(vec![Person { + name: "Chris Biscardi".to_string(), + email: None, + uri: Some( + "https://www.christopherbiscardi.com/" + .to_string(), + ), + }]); + feed.set_links(vec![Link { href: "https://thisweekinbevy.com".to_string(), rel: "alternate".to_string(), hreflang: Some("en".to_string()), mime_type: Some("text/html".to_string()), title: Some("This Week in Bevy".to_string()), length: None, - } - ]); - feed + }]); + feed .set_subtitle(Text::from("What happened this week in the Bevy Engine ecosystem")); - feed - .set_entries(entries); -feed.to_string() - + feed.set_entries(entries); + feed.to_string() } #[cfg(feature = "ssr")] @@ -173,4 +173,3 @@ impl From for IssueShort { } } } - diff --git a/src/lib.rs b/src/lib.rs index 16c78b6..615e83b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ pub mod app; #[cfg(feature = "ssr")] +pub mod atom_feed; +#[cfg(feature = "ssr")] pub mod auth; pub mod error_template; #[cfg(feature = "ssr")] @@ -16,8 +18,6 @@ pub mod sql; pub mod state; #[cfg(feature = "ssr")] pub mod users; -#[cfg(feature = "ssr")] -pub mod atom_feed; #[derive(Debug, Clone, Eq, PartialEq)] pub struct Username(pub String); @@ -30,4 +30,3 @@ pub fn hydrate() { // leptos::mount_to_body(App); leptos::leptos_dom::HydrationCtx::stop_hydrating(); } - diff --git a/src/main.rs b/src/main.rs index 47d314d..a12d616 100644 --- a/src/main.rs +++ b/src/main.rs @@ -173,7 +173,10 @@ async fn main() { // build our application with a route let app = Router::new() - .route("/feed.xml", get(this_week_in_bevy::atom_feed::atom_feed)) + .route( + "/feed.xml", + get(this_week_in_bevy::atom_feed::atom_feed), + ) .route( "/api/*fn_name", get(server_fn_handler).post(server_fn_handler),