From 7edca18f8d76a8f565fa9063ca43e92605c6eaa3 Mon Sep 17 00:00:00 2001 From: robrobinbin <8597693+robrobinbin@users.noreply.github.com> Date: Mon, 8 Feb 2021 01:22:14 +0100 Subject: [PATCH] Inline videos/gifs for card view (#107) * Basic gallery support * Inline videos for card view --- src/post.rs | 1 + src/utils.rs | 3 +++ static/style.css | 7 +++++++ templates/post.html | 2 +- templates/utils.html | 4 ++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/post.rs b/src/post.rs index 3bf810d..1374087 100644 --- a/src/post.rs +++ b/src/post.rs @@ -102,6 +102,7 @@ async fn parse_post(json: &serde_json::Value) -> Post { url: format_url(val(post, "thumbnail").as_str()), width: post["data"]["thumbnail_width"].as_i64().unwrap_or_default(), height: post["data"]["thumbnail_height"].as_i64().unwrap_or_default(), + poster: "".to_string(), }, flair: Flair { flair_parts: parse_rich_flair( diff --git a/src/utils.rs b/src/utils.rs index 512784c..44e042a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -44,6 +44,7 @@ pub struct Media { pub url: String, pub width: i64, pub height: i64, + pub poster: String, } pub struct GalleryMedia { @@ -255,6 +256,7 @@ pub async fn media(data: &Value) -> (String, Media, Vec) { url, width: data["preview"]["images"][0]["source"]["width"].as_i64().unwrap_or_default(), height: data["preview"]["images"][0]["source"]["height"].as_i64().unwrap_or_default(), + poster: format_url(data["preview"]["images"][0]["source"]["url"].as_str().unwrap_or_default()), }, gallery, ) @@ -384,6 +386,7 @@ pub async fn fetch_posts(path: &str, fallback_title: String) -> Result<(Vec {% else if post.post_type == "video" || post.post_type == "gif" %} - + {% else if post.post_type == "gallery" %}