diff --git a/src/post.rs b/src/post.rs index a06a92b..294be41 100644 --- a/src/post.rs +++ b/src/post.rs @@ -106,6 +106,7 @@ async fn parse_post(json: &serde_json::Value) -> Post { stickied: post["data"]["stickied"].as_bool().unwrap_or(false), }, media, + domain: val(post, "domain"), time: OffsetDateTime::from_unix_timestamp(unix_time).format("%b %d %Y %H:%M UTC"), } } diff --git a/src/utils.rs b/src/utils.rs index 9060dfa..c53fe67 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -37,6 +37,7 @@ pub struct Post { pub flags: Flags, pub thumbnail: String, pub media: String, + pub domain: String, pub time: String, } @@ -169,6 +170,9 @@ pub async fn media(data: &serde_json::Value) -> (String, String) { } else if data["post_hint"].as_str().unwrap_or("") == "image" { post_type = "image"; format_url(data["preview"]["images"][0]["source"]["url"].as_str().unwrap_or_default().to_string()) + } else if data["is_self"].as_bool().unwrap_or_default() { + post_type = "self"; + data["permalink"].as_str().unwrap_or_default().to_string() } else { post_type = "link"; data["url"].as_str().unwrap_or_default().to_string() @@ -240,6 +244,7 @@ pub async fn fetch_posts(path: &str, fallback_title: String) -> Result<(Vec {% for post in posts %} {% if !(post.flags.nsfw && prefs.hide_nsfw == "on") %} -
+

{{ post.score }}

{% if post.flags.nsfw %}
NSFW
{% endif %} @@ -56,8 +56,10 @@ {% if prefs.layout == "card" && post.post_type == "image" %} - {% else if prefs.layout != "card" %} - + {% else if post.post_type == "link" %} + {{ post.domain }} + {% else if post.post_type != "self" %} + {{ post.post_type }} {% endif %}
@@ -104,4 +106,4 @@ {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %}