add url to Blog, this seems useful.

This commit is contained in:
Igor Galić
2019-08-14 23:51:16 +02:00
committed by Igor Galić
parent 8e7f789969
commit 9cee38ae6a
2 changed files with 15 additions and 2 deletions
+13
View File
@@ -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())