diff --git a/src/subreddit.rs b/src/subreddit.rs index 1ae90d3..f12bbb1 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -12,7 +12,8 @@ use rinja::Template; use once_cell::sync::Lazy; use regex::Regex; -use time::{Duration, OffsetDateTime}; +use time::{Duration, OffsetDateTime,macros::format_description}; + use log::trace; // STRUCTS @@ -467,6 +468,10 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result { // Metadata regarding the subreddit let members: i64 = res["data"]["subscribers"].as_u64().unwrap_or_default() as i64; let active: i64 = res["data"]["accounts_active"].as_u64().unwrap_or_default() as i64; + + // Grab creation date as unix timestamp + let created_unix = res["data"]["created"].as_f64().unwrap_or(0.0).round() as i64; + let created = OffsetDateTime::from_unix_timestamp(created_unix).unwrap_or(OffsetDateTime::UNIX_EPOCH); // Fetch subreddit icon either from the community_icon or icon_img value let community_icon: &str = res["data"]["community_icon"].as_str().unwrap_or_default(); @@ -481,6 +486,7 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result { icon: format_url(&icon), members: format_num(members), active: format_num(active), + created: created.format(format_description!("[month repr:short] [day] '[year repr:last_two]")).unwrap_or_default(), wiki: res["data"]["wiki_enabled"].as_bool().unwrap_or_default(), nsfw: res["data"]["over18"].as_bool().unwrap_or_default(), }) diff --git a/src/utils.rs b/src/utils.rs index b8105c3..dd8014e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -587,6 +587,7 @@ pub struct Subreddit { pub icon: String, pub members: (String, String), pub active: (String, String), + pub created: String, pub wiki: bool, pub nsfw: bool, } diff --git a/static/style.css b/static/style.css index 9567a81..b37d7e2 100644 --- a/static/style.css +++ b/static/style.css @@ -531,11 +531,14 @@ aside { grid-template-columns: auto 4fr 1fr; } -#user_details, -#sub_details { +#user_details { display: grid; grid-template-columns: repeat(2, 1fr); } +#sub_details { + display: grid; + grid-template-columns: repeat(3, 1fr); +} @media screen and (max-width: 279px) { #sub_actions { display: unset; } } @@ -547,13 +550,9 @@ aside { /* Subscriptions */ -#sub_subscription, #user_subscription, -#sub_filter, #user_filter, -#sub_quicklist, #user_quicklist, -#sub_rss, #user_rss { margin-top: 20px; } diff --git a/templates/subreddit.html b/templates/subreddit.html index 5584863..8856fcd 100644 --- a/templates/subreddit.html +++ b/templates/subreddit.html @@ -120,9 +120,12 @@
+
{{ sub.members.0 }}
{{ sub.active.0 }}
+
{{ sub.created }}
+
{% if prefs.subscriptions.contains(sub.name) %}