chore: Remove Tera usage in all modules

This commit is contained in:
Vincent Ambo 2018-05-22 19:47:53 +02:00 committed by Vincent Ambo
parent 4747bacfe9
commit dbc082b3ee
3 changed files with 2 additions and 28 deletions

View file

@ -32,7 +32,6 @@ use askama;
use diesel; use diesel;
use r2d2; use r2d2;
use reqwest; use reqwest;
use tera;
use tokio_timer; use tokio_timer;
pub type Result<T> = result::Result<T, ConverseError>; pub type Result<T> = result::Result<T, ConverseError>;
@ -51,9 +50,6 @@ pub enum ConverseError {
#[fail(display = "a template rendering error occured: {}", reason)] #[fail(display = "a template rendering error occured: {}", reason)]
Template { reason: String }, Template { reason: String },
#[fail(display = "a template rendering error occured: {}", reason)]
Askama { reason: String },
#[fail(display = "error occured during request handling: {}", error)] #[fail(display = "error occured during request handling: {}", error)]
ActixWeb { error: actix_web::Error }, ActixWeb { error: actix_web::Error },
@ -84,17 +80,9 @@ impl From<r2d2::Error> for ConverseError {
} }
} }
impl From<tera::Error> for ConverseError {
fn from(error: tera::Error) -> ConverseError {
ConverseError::Template {
reason: format!("{}", error),
}
}
}
impl From<askama::Error> for ConverseError { impl From<askama::Error> for ConverseError {
fn from(error: askama::Error) -> ConverseError { fn from(error: askama::Error) -> ConverseError {
ConverseError::Askama { ConverseError::Template {
reason: format!("{}", error), reason: format!("{}", error),
} }
} }

View file

@ -45,7 +45,6 @@ extern crate rand;
extern crate reqwest; extern crate reqwest;
extern crate serde; extern crate serde;
extern crate serde_json; extern crate serde_json;
extern crate tera;
extern crate tokio; extern crate tokio;
extern crate tokio_timer; extern crate tokio_timer;
extern crate url; extern crate url;
@ -82,7 +81,6 @@ use oidc::OidcExecutor;
use rand::{OsRng, Rng}; use rand::{OsRng, Rng};
use render::Renderer; use render::Renderer;
use std::env; use std::env;
use tera::Tera;
fn config(name: &str) -> String { fn config(name: &str) -> String {
env::var(name).expect(&format!("{} must be set", name)) env::var(name).expect(&format!("{} must be set", name))
@ -133,16 +131,6 @@ fn start_oidc_executor(base_url: &str) -> Addr<Syn, OidcExecutor> {
} }
fn start_renderer() -> Addr<Syn, Renderer> { fn start_renderer() -> Addr<Syn, Renderer> {
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{ let comrak = comrak::ComrakOptions{
github_pre_lang: true, github_pre_lang: true,
ext_strikethrough: true, ext_strikethrough: true,
@ -154,7 +142,7 @@ fn start_renderer() -> Addr<Syn, Renderer> {
..Default::default() ..Default::default()
}; };
Renderer{ tera, comrak }.start() Renderer{ comrak }.start()
} }
fn gen_session_key() -> [u8; 64] { fn gen_session_key() -> [u8; 64] {

View file

@ -26,12 +26,10 @@ use errors::*;
use std::fmt; use std::fmt;
use md5; use md5;
use models::*; use models::*;
use tera::Tera;
use chrono::prelude::{DateTime, Utc}; use chrono::prelude::{DateTime, Utc};
use comrak::{ComrakOptions, markdown_to_html}; use comrak::{ComrakOptions, markdown_to_html};
pub struct Renderer { pub struct Renderer {
pub tera: Tera,
pub comrak: ComrakOptions, pub comrak: ComrakOptions,
} }