subreddit-created-date
This commit is contained in:
parent
138172b365
commit
49afd83ad3
@ -12,7 +12,8 @@ use rinja::Template;
|
|||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use time::{Duration, OffsetDateTime};
|
use time::{Duration, OffsetDateTime,macros::format_description};
|
||||||
|
|
||||||
use log::trace;
|
use log::trace;
|
||||||
|
|
||||||
// STRUCTS
|
// STRUCTS
|
||||||
@ -467,6 +468,10 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result<Subreddit, String> {
|
|||||||
// Metadata regarding the subreddit
|
// Metadata regarding the subreddit
|
||||||
let members: i64 = res["data"]["subscribers"].as_u64().unwrap_or_default() as i64;
|
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;
|
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
|
// 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();
|
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<Subreddit, String> {
|
|||||||
icon: format_url(&icon),
|
icon: format_url(&icon),
|
||||||
members: format_num(members),
|
members: format_num(members),
|
||||||
active: format_num(active),
|
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(),
|
wiki: res["data"]["wiki_enabled"].as_bool().unwrap_or_default(),
|
||||||
nsfw: res["data"]["over18"].as_bool().unwrap_or_default(),
|
nsfw: res["data"]["over18"].as_bool().unwrap_or_default(),
|
||||||
})
|
})
|
||||||
|
@ -587,6 +587,7 @@ pub struct Subreddit {
|
|||||||
pub icon: String,
|
pub icon: String,
|
||||||
pub members: (String, String),
|
pub members: (String, String),
|
||||||
pub active: (String, String),
|
pub active: (String, String),
|
||||||
|
pub created: String,
|
||||||
pub wiki: bool,
|
pub wiki: bool,
|
||||||
pub nsfw: bool,
|
pub nsfw: bool,
|
||||||
}
|
}
|
||||||
|
@ -531,11 +531,14 @@ aside {
|
|||||||
grid-template-columns: auto 4fr 1fr;
|
grid-template-columns: auto 4fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#user_details,
|
#user_details {
|
||||||
#sub_details {
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
}
|
}
|
||||||
|
#sub_details {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
@media screen and (max-width: 279px) {
|
@media screen and (max-width: 279px) {
|
||||||
#sub_actions { display: unset; }
|
#sub_actions { display: unset; }
|
||||||
}
|
}
|
||||||
@ -547,13 +550,9 @@ aside {
|
|||||||
|
|
||||||
/* Subscriptions */
|
/* Subscriptions */
|
||||||
|
|
||||||
#sub_subscription,
|
|
||||||
#user_subscription,
|
#user_subscription,
|
||||||
#sub_filter,
|
|
||||||
#user_filter,
|
#user_filter,
|
||||||
#sub_quicklist,
|
|
||||||
#user_quicklist,
|
#user_quicklist,
|
||||||
#sub_rss,
|
|
||||||
#user_rss {
|
#user_rss {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,12 @@
|
|||||||
<div id="sub_details">
|
<div id="sub_details">
|
||||||
<label>Members</label>
|
<label>Members</label>
|
||||||
<label>Active</label>
|
<label>Active</label>
|
||||||
|
<label>Created</label>
|
||||||
<div title="{{ sub.members.1 }}">{{ sub.members.0 }}</div>
|
<div title="{{ sub.members.1 }}">{{ sub.members.0 }}</div>
|
||||||
<div title="{{ sub.active.1 }}">{{ sub.active.0 }}</div>
|
<div title="{{ sub.active.1 }}">{{ sub.active.0 }}</div>
|
||||||
|
<div>{{ sub.created }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
<div id="sub_actions">
|
<div id="sub_actions">
|
||||||
<div id="sub_subscription">
|
<div id="sub_subscription">
|
||||||
{% if prefs.subscriptions.contains(sub.name) %}
|
{% if prefs.subscriptions.contains(sub.name) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user