From 9cee38ae6a75f5aa3728c0ee531207e7fa163aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Fri, 31 May 2019 23:18:29 +0200 Subject: [PATCH] add url to Blog, this seems useful. --- plume-models/src/blogs.rs | 13 +++++++++++++ templates/blogs/details.rs.html | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index ad6e40a2..a81b88f9 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -327,6 +327,19 @@ impl Blog { }) } + pub fn url(&self) -> String { + format!( + "https://{}", + self.custom_domain + .clone() + .unwrap_or_else(|| Host::new(format!( + "{}/~/{}", + Instance::get_local().unwrap().public_domain, + self.title + ))) + ) + } + pub fn icon_url(&self, conn: &Connection) -> String { self.icon_id .and_then(|id| Media::get(conn, id).and_then(|m| m.url()).ok()) diff --git a/templates/blogs/details.rs.html b/templates/blogs/details.rs.html index 71c87a71..571b1139 100644 --- a/templates/blogs/details.rs.html +++ b/templates/blogs/details.rs.html @@ -13,8 +13,8 @@ - - + +