Use Ructe (#327)
All the template are now compiled at compile-time with the `ructe` crate.
I preferred to use it instead of askama because it allows more complex Rust expressions, where askama only supports a small subset of expressions and doesn't allow them everywhere (for instance, `{{ macro!() | filter }}` would result in a parsing error).
The diff is quite huge, but there is normally no changes in functionality.
Fixes #161 and unblocks #110 and #273
This commit is contained in:
@@ -763,17 +763,9 @@ impl Post {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_json(&self, conn: &Connection) -> serde_json::Value {
|
||||
pub fn url(&self, conn: &Connection) -> String {
|
||||
let blog = self.get_blog(conn);
|
||||
json!({
|
||||
"post": self,
|
||||
"author": self.get_authors(conn)[0].to_json(conn),
|
||||
"url": format!("/~/{}/{}/", blog.get_fqn(conn), self.slug),
|
||||
"date": self.creation_date.timestamp(),
|
||||
"blog": blog.to_json(conn),
|
||||
"tags": Tag::for_post(&*conn, self.id),
|
||||
"cover": self.cover_id.and_then(|i| Media::get(conn, i).map(|m| m.to_json(conn))),
|
||||
})
|
||||
format!("/~/{}/{}", blog.get_fqn(conn), self.slug)
|
||||
}
|
||||
|
||||
pub fn compute_id(&self, conn: &Connection) -> String {
|
||||
@@ -784,6 +776,10 @@ impl Post {
|
||||
self.slug
|
||||
))
|
||||
}
|
||||
|
||||
pub fn cover_url(&self, conn: &Connection) -> Option<String> {
|
||||
self.cover_id.and_then(|i| Media::get(conn, i)).map(|c| c.url(conn))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromActivity<Article, (&'a Connection, &'a Searcher)> for Post {
|
||||
|
||||
Reference in New Issue
Block a user