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 regex::Regex;
|
||||
use time::{Duration, OffsetDateTime};
|
||||
use time::{Duration, OffsetDateTime,macros::format_description};
|
||||
|
||||
use log::trace;
|
||||
|
||||
// STRUCTS
|
||||
@ -468,6 +469,10 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result<Subreddit, String> {
|
||||
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();
|
||||
let icon = if community_icon.is_empty() { val(&res, "icon_img") } else { community_icon.to_string() };
|
||||
@ -481,6 +486,7 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result<Subreddit, String> {
|
||||
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(),
|
||||
})
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -120,9 +120,12 @@
|
||||
<div id="sub_details">
|
||||
<label>Members</label>
|
||||
<label>Active</label>
|
||||
<label>Created</label>
|
||||
<div title="{{ sub.members.1 }}">{{ sub.members.0 }}</div>
|
||||
<div title="{{ sub.active.1 }}">{{ sub.active.0 }}</div>
|
||||
<div>{{ sub.created }}</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="sub_actions">
|
||||
<div id="sub_subscription">
|
||||
{% if prefs.subscriptions.contains(sub.name) %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user