diff --git a/src/app.rs b/src/app.rs
index d2ac9c2..a9bbee5 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -3,9 +3,9 @@ use crate::{
components::{AboutSection, TinyWaveFormIcon},
routes::{
admin::{self, AdminWrapper},
+ custom,
index::Home,
issue,
- custom,
},
},
error_template::{AppError, ErrorTemplate},
@@ -23,7 +23,8 @@ pub fn App() -> impl IntoView {
// titles, meta tags, etc.
provide_meta_context();
- let pkg_path: &'static str = std::option_env!("CDN_PKG_PATH").unwrap_or("/pkg");
+ let pkg_path: &'static str =
+ std::option_env!("CDN_PKG_PATH").unwrap_or("/pkg");
view! {
impl IntoView {
+pub fn Divider(
+ #[prop(into)] title: String,
+) -> impl IntoView {
view! {
@@ -96,4 +98,4 @@ pub fn Divider(#[prop(into)] title: String) -> impl IntoView {
}
-}
\ No newline at end of file
+}
diff --git a/src/app/routes.rs b/src/app/routes.rs
index a74885b..e9a2201 100644
--- a/src/app/routes.rs
+++ b/src/app/routes.rs
@@ -1,9 +1,9 @@
use crate::app::components::Container;
use leptos::*;
pub mod admin;
+pub mod custom;
pub mod index;
pub mod issue;
-pub mod custom;
#[component]
fn PauseIcon(
diff --git a/src/app/routes/admin.rs b/src/app/routes/admin.rs
index b6abb0c..d5ef689 100644
--- a/src/app/routes/admin.rs
+++ b/src/app/routes/admin.rs
@@ -1,13 +1,13 @@
use leptos::*;
use leptos_router::*;
-pub mod issue;
-pub mod issues;
-pub mod showcase;
pub mod crate_release;
-pub mod educational;
pub mod devlog;
+pub mod educational;
pub mod image;
+pub mod issue;
+pub mod issues;
+pub mod showcase;
#[component]
pub fn AdminHomepage() -> impl IntoView {
@@ -213,5 +213,3 @@ pub fn AdminWrapper() -> impl IntoView {
}
}
-
-
diff --git a/src/app/routes/admin/crate_release.rs b/src/app/routes/admin/crate_release.rs
index 63d350a..dc4d2f1 100644
--- a/src/app/routes/admin/crate_release.rs
+++ b/src/app/routes/admin/crate_release.rs
@@ -1,6 +1,5 @@
use leptos::*;
-
#[component]
pub fn CrateRelease() -> impl IntoView {
view! { CrateRelease
}
diff --git a/src/app/routes/admin/devlog.rs b/src/app/routes/admin/devlog.rs
index bce705d..50e40db 100644
--- a/src/app/routes/admin/devlog.rs
+++ b/src/app/routes/admin/devlog.rs
@@ -1,7 +1,6 @@
use leptos::*;
-
#[component]
pub fn Devlog() -> impl IntoView {
view! { Devlog
}
-}
\ No newline at end of file
+}
diff --git a/src/app/routes/admin/educational.rs b/src/app/routes/admin/educational.rs
index f517c71..5a91ff3 100644
--- a/src/app/routes/admin/educational.rs
+++ b/src/app/routes/admin/educational.rs
@@ -1,7 +1,6 @@
use leptos::*;
-
#[component]
pub fn Educational() -> impl IntoView {
view! { Educational
}
-}
\ No newline at end of file
+}
diff --git a/src/app/routes/admin/image.rs b/src/app/routes/admin/image.rs
index b9c45bf..c2a4e6d 100644
--- a/src/app/routes/admin/image.rs
+++ b/src/app/routes/admin/image.rs
@@ -1,9 +1,9 @@
-use leptos::*;
use crate::app::components::Divider;
-use leptos_router::*;
-use serde::{Deserialize, Serialize};
#[cfg(feature = "ssr")]
use crate::app::server_fn::error::NoCustomError;
+use leptos::*;
+use leptos_router::*;
+use serde::{Deserialize, Serialize};
#[cfg(feature = "ssr")]
use tracing::error;
@@ -59,12 +59,10 @@ pub fn Image() -> impl IntoView {
}
}
-
-
#[server]
async fn add_image(
cloudinary_public_id: String,
- description: String
+ description: String,
) -> Result<(), ServerFnError> {
let pool = crate::sql::pool()?;
let _username = crate::sql::with_admin_access()?;
@@ -90,7 +88,8 @@ async fn add_image(
#[component]
fn Images() -> impl IntoView {
- let images = create_resource(move || {}, |_| fetch_images());
+ let images =
+ create_resource(move || {}, |_| fetch_images());
view! {
impl IntoView {
}
#[component]
-fn ImageLi(id: String, url: String, description: String) -> impl IntoView {
+fn ImageLi(
+ id: String,
+ url: String,
+ description: String,
+) -> impl IntoView {
view! {
@@ -154,25 +157,33 @@ fn ImageLi(id: String, url: String, description: String) -> impl IntoView {
struct SqlImage {
id: Vec
,
description: String,
- cloudinary_public_id: String
+ cloudinary_public_id: String,
}
#[derive(Deserialize, Serialize, Clone)]
pub struct Image {
pub id: String,
pub description: String,
- pub url: String
+ pub url: String,
}
#[cfg(feature = "ssr")]
impl From for Image {
fn from(value: SqlImage) -> Self {
use cloudinary::transformation::{
- Transformations::Resize, resize_mode::ResizeMode::ScaleByWidth, Image as CImage
+ resize_mode::ResizeMode::ScaleByWidth,
+ Image as CImage, Transformations::Resize,
};
-
- let image = CImage::new("dilgcuzda".into(), value.cloudinary_public_id.into())
- .add_transformation(Resize(ScaleByWidth{ width:300, ar: None, liquid:None }));
+
+ let image = CImage::new(
+ "dilgcuzda".into(),
+ value.cloudinary_public_id.into(),
+ )
+ .add_transformation(Resize(ScaleByWidth {
+ width: 300,
+ ar: None,
+ liquid: None,
+ }));
let id_str =
rusty_ulid::Ulid::try_from(value.id.as_slice())
@@ -182,15 +193,14 @@ impl From for Image {
Image {
id: id_str.to_string(),
description: value.description,
- url: image.to_string()
+ url: image.to_string(),
}
}
}
-
#[server]
-async fn fetch_images(
-) -> Result, ServerFnError> {
+async fn fetch_images() -> Result, ServerFnError>
+{
let pool = crate::sql::pool()?;
let _username = crate::sql::with_admin_access()?;
@@ -208,7 +218,9 @@ limit 5"#
.await
.map_err(|e| {
error!(?e);
- ServerFnError::::ServerError("sql failed".to_string())
+ ServerFnError::::ServerError(
+ "sql failed".to_string(),
+ )
})?;
Ok(images.into_iter().map(Image::from).collect())
diff --git a/src/app/routes/admin/issue.rs b/src/app/routes/admin/issue.rs
index 5c83c56..be05ce8 100644
--- a/src/app/routes/admin/issue.rs
+++ b/src/app/routes/admin/issue.rs
@@ -1,7 +1,7 @@
+use crate::app::components::Divider;
use leptos::*;
use leptos_router::*;
use serde::{Deserialize, Serialize};
-use crate::app::components::{Divider};
#[component]
pub fn Issue() -> impl IntoView {
@@ -293,7 +293,7 @@ fn Showcases() -> impl IntoView {
},
fetch_showcases_for_issue_id,
);
-
+
view! {
impl IntoView {
}
}
-
#[cfg(feature = "ssr")]
#[derive(Debug, sqlx::FromRow)]
struct SqlShowcaseData {
id: Vec,
title: String,
posted_date: Option,
- image_count: Option
+ image_count: Option,
}
#[derive(Deserialize, Serialize, Clone)]
@@ -387,7 +386,7 @@ pub struct ShowcaseData {
pub id: String,
pub title: String,
pub posted_date: Option,
- pub image_count: u32
+ pub image_count: u32,
}
#[cfg(feature = "ssr")]
@@ -402,14 +401,17 @@ impl From for ShowcaseData {
id: id_str.to_string(),
title: value.title,
posted_date: value.posted_date,
- image_count: value.image_count.unwrap_or_default() as u32
+ image_count: value
+ .image_count
+ .unwrap_or_default()
+ as u32,
}
}
}
#[server]
pub async fn fetch_showcases_for_issue_id(
- issue_id: String
+ issue_id: String,
) -> Result, ServerFnError> {
let pool = crate::sql::pool()?;
let _username = crate::sql::with_admin_access()?;
@@ -441,5 +443,8 @@ issue_id.as_slice()
.fetch_all(&pool)
.await?;
- Ok(showcases.into_iter().map(ShowcaseData::from).collect())
+ Ok(showcases
+ .into_iter()
+ .map(ShowcaseData::from)
+ .collect())
}
diff --git a/src/app/routes/admin/showcase.rs b/src/app/routes/admin/showcase.rs
index d12ad69..e3ecb45 100644
--- a/src/app/routes/admin/showcase.rs
+++ b/src/app/routes/admin/showcase.rs
@@ -1,8 +1,8 @@
-use leptos::*;
-use leptos_router::*;
-use serde::{Serialize, Deserialize};
use crate::app::components::Divider;
use futures::future::join;
+use leptos::*;
+use leptos_router::*;
+use serde::{Deserialize, Serialize};
pub mod id;
#[server]
@@ -42,8 +42,10 @@ async fn add_showcase(
pub fn Showcase() -> impl IntoView {
let add_showcase =
create_server_action::();
- let showcases =
- create_resource(move || {}, |_| join(fetch_showcases(), fetch_issues()));
+ let showcases = create_resource(
+ move || {},
+ |_| join(fetch_showcases(), fetch_issues()),
+ );
view! {
@@ -166,8 +168,13 @@ pub fn Showcase() -> impl IntoView {
}
#[component]
-fn AddShowcaseToIssueForm(showcase: ShowcaseData, issue_id: Option
) -> impl IntoView {
- let associate_showcase_with_issue = create_server_action::();
+fn AddShowcaseToIssueForm(
+ showcase: ShowcaseData,
+ issue_id: Option,
+) -> impl IntoView {
+ let associate_showcase_with_issue =
+ create_server_action::(
+ );
view! {
-
@@ -264,7 +271,10 @@ ORDER BY showcase.id"
.fetch_all(&pool)
.await?;
- Ok(showcases.into_iter().map(ShowcaseData::from).collect())
+ Ok(showcases
+ .into_iter()
+ .map(ShowcaseData::from)
+ .collect())
}
#[server]
@@ -300,7 +310,6 @@ async fn associate_showcase_with_issue(
Ok(())
}
-
#[cfg(feature = "ssr")]
#[derive(Debug, sqlx::FromRow)]
struct SqlIssueShort {
@@ -324,7 +333,7 @@ impl From for IssueShort {
);
IssueShort {
id: id_str.to_string(),
- display_name: value.display_name
+ display_name: value.display_name,
}
}
}
@@ -348,4 +357,4 @@ ORDER BY issue_date DESC"#
.await?;
Ok(issues.into_iter().map(IssueShort::from).collect())
-}
\ No newline at end of file
+}
diff --git a/src/app/routes/admin/showcase/id.rs b/src/app/routes/admin/showcase/id.rs
index 2370ddf..c080ee5 100644
--- a/src/app/routes/admin/showcase/id.rs
+++ b/src/app/routes/admin/showcase/id.rs
@@ -1,7 +1,7 @@
+use crate::app::components::Divider;
use leptos::*;
use leptos_router::*;
-use serde::{Serialize, Deserialize};
-use crate::app::components::Divider;
+use serde::{Deserialize, Serialize};
#[cfg(feature = "ssr")]
use crate::app::server_fn::error::NoCustomError;
@@ -19,9 +19,13 @@ async fn update_showcase(
let _username = crate::sql::with_admin_access()?;
let id: [u8; 16] = showcase_id
- .parse::()
- .map_err(|_| ServerFnError::::ServerError("expected a valid showcase id".to_string()))?
- .into();
+ .parse::()
+ .map_err(|_| {
+ ServerFnError::::ServerError(
+ "expected a valid showcase id".to_string(),
+ )
+ })?
+ .into();
dbg!(title);
// sqlx::query!(
@@ -55,14 +59,14 @@ pub fn Showcase() -> impl IntoView {
let update_showcase =
create_server_action::();
- let showcase =
- create_resource(move || {
+ let showcase = create_resource(
+ move || {
params.with(|p| {
p.get("id").cloned().unwrap_or_default()
})
- },
- fetch_showcase_by_id
- );
+ },
+ fetch_showcase_by_id,
+ );
view! {
@@ -216,7 +220,6 @@ pub fn Showcase() -> impl IntoView {
}
}
-
#[cfg(feature = "ssr")]
#[derive(Debug, sqlx::FromRow)]
struct SqlShowcaseData {
@@ -226,7 +229,7 @@ struct SqlShowcaseData {
posted_date: Option
,
discord_url: String,
description: String,
- images: serde_json::Value
+ images: serde_json::Value,
}
#[derive(Deserialize, Serialize, Clone)]
@@ -237,77 +240,98 @@ pub struct ShowcaseData {
pub posted_date: Option,
pub discord_url: String,
pub description: String,
- pub images: Vec
-
+ pub images: Vec,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
struct ImgData {
id: String,
- cloudinary_public_id: String
+ cloudinary_public_id: String,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
struct ImgDataTransformed {
id: String,
- url: String
+ url: String,
}
#[cfg(feature = "ssr")]
impl From for ShowcaseData {
fn from(value: SqlShowcaseData) -> Self {
use data_encoding::BASE64;
-
+
let id_str =
rusty_ulid::Ulid::try_from(value.id.as_slice())
.expect(
"expect valid ids from the database",
);
- let images = serde_json::from_value::>(value.images)
- .inspect_err(|e| {tracing::warn!(?e);})
- .unwrap_or_default()
- .into_iter()
- .map(|img_data| {
- use cloudinary::transformation::{
- Transformations::Resize, resize_mode::ResizeMode::ScaleByWidth, Image as CImage
- };
-
- let base_id = BASE64.decode(img_data.id.as_bytes()).expect("a valid id in base64 format");
- let img_ulid = rusty_ulid::Ulid::try_from(base_id.as_slice())
- .expect(
- "expect valid ids from the database",
- );
- let image = CImage::new("dilgcuzda".into(), img_data.cloudinary_public_id.into())
- .add_transformation(Resize(ScaleByWidth{ width:300, ar: None, liquid:None }));
- ImgDataTransformed {
- id: img_ulid.to_string(),
- url: image.to_string()
- }
- }).collect();
+ let images =
+ serde_json::from_value::>(
+ value.images,
+ )
+ .inspect_err(|e| {
+ tracing::warn!(?e);
+ })
+ .unwrap_or_default()
+ .into_iter()
+ .map(|img_data| {
+ use cloudinary::transformation::{
+ resize_mode::ResizeMode::ScaleByWidth,
+ Image as CImage,
+ Transformations::Resize,
+ };
+
+ let base_id = BASE64
+ .decode(img_data.id.as_bytes())
+ .expect("a valid id in base64 format");
+ let img_ulid = rusty_ulid::Ulid::try_from(
+ base_id.as_slice(),
+ )
+ .expect(
+ "expect valid ids from the database",
+ );
+ let image = CImage::new(
+ "dilgcuzda".into(),
+ img_data.cloudinary_public_id.into(),
+ )
+ .add_transformation(Resize(ScaleByWidth {
+ width: 300,
+ ar: None,
+ liquid: None,
+ }));
+ ImgDataTransformed {
+ id: img_ulid.to_string(),
+ url: image.to_string(),
+ }
+ })
+ .collect();
ShowcaseData {
id: id_str.to_string(),
title: value.title,
-url: value.url,
-posted_date: value.posted_date,
-discord_url: value.discord_url,
-description: value.description,
-images
+ url: value.url,
+ posted_date: value.posted_date,
+ discord_url: value.discord_url,
+ description: value.description,
+ images,
}
}
}
-
#[server]
pub async fn fetch_showcase_by_id(
- showcase_id: String
+ showcase_id: String,
) -> Result
}
}
-
-
diff --git a/src/app/routes/issue.rs b/src/app/routes/issue.rs
index 2ccb571..1874023 100644
--- a/src/app/routes/issue.rs
+++ b/src/app/routes/issue.rs
@@ -103,10 +103,10 @@ struct Educational {
#[derive(Debug, Clone, Serialize, Deserialize)]
struct Showcase {
title: String,
-url: String,
-discord_url: String,
-description: String,
-images: Vec
+ url: String,
+ discord_url: String,
+ description: String,
+ images: Vec,
}
#[derive(Clone, Serialize, Deserialize)]
@@ -141,7 +141,6 @@ struct SqlIssueData {
description: String,
youtube_id: String,
// prs: Vec,
-
}
#[cfg(feature = "ssr")]
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
@@ -152,11 +151,17 @@ struct SqlShowcaseData {
display_name: String,
description: String,
youtube_id: String,
- showcases: Option>>
+ showcases:
+ Option>>,
}
#[cfg(feature = "ssr")]
-#[derive(Debug, serde::Deserialize, serde::Serialize, sqlx::FromRow)]
+#[derive(
+ Debug,
+ serde::Deserialize,
+ serde::Serialize,
+ sqlx::FromRow,
+)]
struct ShowcaseData2 {
title: String,
url: String,
@@ -170,15 +175,14 @@ struct ShowcaseData2 {
struct ImgData {
id: String,
description: String,
- cloudinary_public_id: String
+ cloudinary_public_id: String,
}
-
#[derive(Debug, Deserialize, Serialize, Clone)]
struct ImgDataTransformed {
id: String,
description: String,
- url: String
+ url: String,
}
#[server]
@@ -186,41 +190,43 @@ async fn fetch_issue(
date: time::Date,
) -> Result
}
}
-
-