From 25b7399e7fcf803aca08c989fb509f9a1fba53d2 Mon Sep 17 00:00:00 2001 From: Baptiste Gelez Date: Wed, 31 Oct 2018 14:40:31 +0100 Subject: [PATCH] Only list images for possible covers --- plume-models/src/medias.rs | 8 ++++++-- templates/posts/new.html.tera | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index 8b220a0c..6f834867 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -44,28 +44,32 @@ impl Media { pub fn to_json(&self, conn: &Connection) -> serde_json::Value { let mut json = serde_json::to_value(self).expect("Media::to_json: serialization error"); let url = self.url(conn); - let (preview, html, md) = match self.file_path.rsplitn(2, '.').next().expect("Media::to_json: extension error") { + let (cat, preview, html, md) = match self.file_path.rsplitn(2, '.').next().expect("Media::to_json: extension error") { "png" | "jpg" | "jpeg" | "gif" | "svg" => ( + "image", format!("\"{}\"", url, self.alt_text, self.alt_text), format!("\"{}\"", url, self.alt_text, self.alt_text), format!("![{}]({})", self.alt_text, url), ), "mp3" | "wav" | "flac" => ( + "audio", format!("", url, self.alt_text), format!("", url, self.alt_text), format!("", url, self.alt_text), ), "mp4" | "avi" | "webm" | "mov" => ( + "video", format!("", url, self.alt_text), format!("", url, self.alt_text), format!("", url, self.alt_text), ), - _ => (String::new(), String::new(), String::new()) + _ => ("unknown", String::new(), String::new(), String::new()) }; json["html_preview"] = json!(preview); json["html"] = json!(html); json["url"] = json!(url); json["md"] = json!(md); + json["category"] = json!(cat); json } diff --git a/templates/posts/new.html.tera b/templates/posts/new.html.tera index b7f3d6a2..796ab914 100644 --- a/templates/posts/new.html.tera +++ b/templates/posts/new.html.tera @@ -39,9 +39,11 @@