Skip to content

Commit

Permalink
cargofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBiscardi committed Mar 19, 2024
1 parent 75a1d4c commit 2fc1027
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
6 changes: 4 additions & 2 deletions src/app/routes/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
<div class="pb-12 sm:pb-4">
Expand Down
77 changes: 38 additions & 39 deletions src/atom_feed.rs
Original file line number Diff line number Diff line change
@@ -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<AppState>,
) -> 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<SqlIssueShort> = sqlx::query_as!(
SqlIssueShort,
r#"
let issues: Vec<SqlIssueShort> = sqlx::query_as!(
SqlIssueShort,
r#"
SELECT
id,
slug,
Expand All @@ -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<IssueShort> = issues.into_iter().map(IssueShort::from).collect();
let issues: Vec<IssueShort> =
issues.into_iter().map(IssueShort::from).collect();

let mut newest_issue_date = None;
let mut newest_issue_date = None;

let entries: Vec<Entry> = issues.into_iter().filter_map(|issue| {
let entries: Vec<Entry> = issues.into_iter().filter_map(|issue| {
let date = issue.issue_date.and_then(|v| {
use atom_syndication::FixedDateTime;
use std::str::FromStr;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -173,4 +173,3 @@ impl From<SqlIssueShort> for IssueShort {
}
}
}

5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand All @@ -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);
Expand All @@ -30,4 +30,3 @@ pub fn hydrate() {
// leptos::mount_to_body(App);
leptos::leptos_dom::HydrationCtx::stop_hydrating();
}

5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2fc1027

Please sign in to comment.