Skip to content

Commit

Permalink
Deleted Handlebars and renamed tera-templates to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Kixiron authored and Joshua Nelson committed Jul 13, 2020
1 parent f3c27ab commit 080fc6e
Show file tree
Hide file tree
Showing 31 changed files with 5 additions and 465 deletions.
110 changes: 0 additions & 110 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ serde_json = "1.0"
# iron dependencies
iron = "0.5"
router = "0.5"
handlebars-iron = "0.25"
params = "0.8"
staticfile = { version = "0.4", features = [ "cache" ] }
tempfile = "3.1.0"
Expand Down
1 change: 0 additions & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ RUN mkdir -p /opt/docsrs/prefix
COPY --from=build /build/target/release/cratesfyi /usr/local/bin
COPY static /opt/docsrs/prefix/public_html
COPY templates /opt/docsrs/templates
COPY tera-templates /opt/docsrs/tera-templates
COPY dockerfiles/entrypoint.sh /opt/docsrs/

WORKDIR /opt/docsrs
Expand Down
28 changes: 3 additions & 25 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ use crate::{config::Config, db::Pool, impl_webpage, BuildQueue};
use chrono::{DateTime, Utc};
use extensions::InjectExtensions;
use failure::Error;
use handlebars_iron::{DirectorySource, HandlebarsEngine, SourceError};
use iron::{
self,
headers::{CacheControl, CacheDirective, ContentType, Expires, HttpDate},
Expand All @@ -104,17 +103,6 @@ const OPENSEARCH_XML: &[u8] = include_bytes!("opensearch.xml");

const DEFAULT_BIND: &str = "0.0.0.0:3000";

fn handlebars_engine() -> Result<HandlebarsEngine, SourceError> {
// TODO: Use DocBuilderOptions for paths
let mut hbse = HandlebarsEngine::new();
hbse.add(Box::new(DirectorySource::new("./templates", ".hbs")));

// load templates
hbse.reload()?;

Ok(hbse)
}

struct CratesfyiHandler {
shared_resource_handler: Box<dyn Handler>,
router_handler: Box<dyn Handler>,
Expand All @@ -125,11 +113,9 @@ struct CratesfyiHandler {

impl CratesfyiHandler {
fn chain<H: Handler>(inject_extensions: InjectExtensions, base: H) -> Chain {
let hbse = handlebars_engine().expect("Failed to load handlebar templates");

let mut chain = Chain::new(base);
chain.link_before(inject_extensions);
chain.link_after(hbse);

chain
}

Expand Down Expand Up @@ -584,7 +570,7 @@ fn ico_handler(req: &mut Request) -> IronResult<Response> {
}

/// MetaData used in header
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub(crate) struct MetaData {
pub(crate) name: String,
pub(crate) version: String,
Expand Down Expand Up @@ -652,10 +638,7 @@ impl_webpage! {
#[cfg(test)]
mod test {
use super::*;
use crate::{
test::*,
web::{handlebars_engine, match_version},
};
use crate::{test::*, web::match_version};
use kuchiki::traits::TendrilSink;
use serde_json::json;

Expand Down Expand Up @@ -864,11 +847,6 @@ mod test {
});
}

#[test]
fn test_templates_are_valid() {
handlebars_engine().expect("Failed to load handlebar templates");
}

#[test]
fn serialize_metadata() {
let mut metadata = MetaData {
Expand Down
190 changes: 0 additions & 190 deletions src/web/page/handlebars.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/web/page/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mod handlebars;
mod templates;
mod web_page;

pub use handlebars::*;
pub(crate) use templates::TemplateData;
pub(crate) use web_page::WebPage;

Expand Down
4 changes: 2 additions & 2 deletions src/web/page/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{
use tera::{Result as TeraResult, Tera};
use walkdir::WalkDir;

const TEMPLATES_DIRECTORY: &str = "tera-templates";
const TEMPLATES_DIRECTORY: &str = "templates";

/// Holds all data relevant to templating
#[derive(Debug)]
Expand Down Expand Up @@ -45,7 +45,7 @@ impl TemplateData {
let mut watcher = watcher(tx, Duration::from_secs(2)).unwrap();

watcher
.watch("tera-templates", RecursiveMode::Recursive)
.watch(TEMPLATES_DIRECTORY, RecursiveMode::Recursive)
.unwrap();

thread::spawn(move || {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions templates/footer.hbs

This file was deleted.

27 changes: 0 additions & 27 deletions templates/header.hbs

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 080fc6e

Please sign in to comment.