From dbc082b3ee841d23aefc78db770e4b96655fb9c6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 22 May 2018 19:47:53 +0200 Subject: [PATCH] chore: Remove Tera usage in all modules --- src/errors.rs | 14 +------------- src/main.rs | 14 +------------- src/render.rs | 2 -- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 05642d0a8..3f00a2976 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -32,7 +32,6 @@ use askama; use diesel; use r2d2; use reqwest; -use tera; use tokio_timer; pub type Result = result::Result; @@ -51,9 +50,6 @@ pub enum ConverseError { #[fail(display = "a template rendering error occured: {}", reason)] Template { reason: String }, - #[fail(display = "a template rendering error occured: {}", reason)] - Askama { reason: String }, - #[fail(display = "error occured during request handling: {}", error)] ActixWeb { error: actix_web::Error }, @@ -84,17 +80,9 @@ impl From for ConverseError { } } -impl From for ConverseError { - fn from(error: tera::Error) -> ConverseError { - ConverseError::Template { - reason: format!("{}", error), - } - } -} - impl From for ConverseError { fn from(error: askama::Error) -> ConverseError { - ConverseError::Askama { + ConverseError::Template { reason: format!("{}", error), } } diff --git a/src/main.rs b/src/main.rs index e25c3bef1..47bfb0b36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,6 @@ extern crate rand; extern crate reqwest; extern crate serde; extern crate serde_json; -extern crate tera; extern crate tokio; extern crate tokio_timer; extern crate url; @@ -82,7 +81,6 @@ use oidc::OidcExecutor; use rand::{OsRng, Rng}; use render::Renderer; use std::env; -use tera::Tera; fn config(name: &str) -> String { env::var(name).expect(&format!("{} must be set", name)) @@ -133,16 +131,6 @@ fn start_oidc_executor(base_url: &str) -> Addr { } fn start_renderer() -> Addr { - info!("Compiling templates ..."); - let mut tera: Tera = Default::default(); - - // Include template strings into the binary instead of being - // location-dependent. - // Drawback is that template changes require recompilation ... - tera.add_raw_templates(vec![ - ("search.html", include_str!("../templates/search.html")), - ]).expect("Could not compile templates"); - let comrak = comrak::ComrakOptions{ github_pre_lang: true, ext_strikethrough: true, @@ -154,7 +142,7 @@ fn start_renderer() -> Addr { ..Default::default() }; - Renderer{ tera, comrak }.start() + Renderer{ comrak }.start() } fn gen_session_key() -> [u8; 64] { diff --git a/src/render.rs b/src/render.rs index ea198c31d..223a3bd45 100644 --- a/src/render.rs +++ b/src/render.rs @@ -26,12 +26,10 @@ use errors::*; use std::fmt; use md5; use models::*; -use tera::Tera; use chrono::prelude::{DateTime, Utc}; use comrak::{ComrakOptions, markdown_to_html}; pub struct Renderer { - pub tera: Tera, pub comrak: ComrakOptions, }