Skip to content

Commit 55b85cf

Browse files
KixironJoshua Nelson
authored and
Joshua Nelson
committed
Deleted Handlebars and renamed tera-templates to templates
1 parent 1a58978 commit 55b85cf

31 files changed

+5
-465
lines changed

Cargo.lock

Lines changed: 0 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ serde_json = "1.0"
5454
# iron dependencies
5555
iron = "0.5"
5656
router = "0.5"
57-
handlebars-iron = "0.25"
5857
params = "0.8"
5958
staticfile = { version = "0.4", features = [ "cache" ] }
6059
tempfile = "3.1.0"

dockerfiles/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ RUN mkdir -p /opt/docsrs/prefix
7474
COPY --from=build /build/target/release/cratesfyi /usr/local/bin
7575
COPY static /opt/docsrs/prefix/public_html
7676
COPY templates /opt/docsrs/templates
77-
COPY tera-templates /opt/docsrs/tera-templates
7877
COPY dockerfiles/entrypoint.sh /opt/docsrs/
7978

8079
WORKDIR /opt/docsrs

src/web/mod.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ use crate::{config::Config, db::Pool, impl_webpage, BuildQueue};
7878
use chrono::{DateTime, Utc};
7979
use extensions::InjectExtensions;
8080
use failure::Error;
81-
use handlebars_iron::{DirectorySource, HandlebarsEngine, SourceError};
8281
use iron::{
8382
self,
8483
headers::{CacheControl, CacheDirective, ContentType, Expires, HttpDate},
@@ -104,17 +103,6 @@ const OPENSEARCH_XML: &[u8] = include_bytes!("opensearch.xml");
104103

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

107-
fn handlebars_engine() -> Result<HandlebarsEngine, SourceError> {
108-
// TODO: Use DocBuilderOptions for paths
109-
let mut hbse = HandlebarsEngine::new();
110-
hbse.add(Box::new(DirectorySource::new("./templates", ".hbs")));
111-
112-
// load templates
113-
hbse.reload()?;
114-
115-
Ok(hbse)
116-
}
117-
118106
struct CratesfyiHandler {
119107
shared_resource_handler: Box<dyn Handler>,
120108
router_handler: Box<dyn Handler>,
@@ -125,11 +113,9 @@ struct CratesfyiHandler {
125113

126114
impl CratesfyiHandler {
127115
fn chain<H: Handler>(inject_extensions: InjectExtensions, base: H) -> Chain {
128-
let hbse = handlebars_engine().expect("Failed to load handlebar templates");
129-
130116
let mut chain = Chain::new(base);
131117
chain.link_before(inject_extensions);
132-
chain.link_after(hbse);
118+
133119
chain
134120
}
135121

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

586572
/// MetaData used in header
587-
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
573+
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
588574
pub(crate) struct MetaData {
589575
pub(crate) name: String,
590576
pub(crate) version: String,
@@ -652,10 +638,7 @@ impl_webpage! {
652638
#[cfg(test)]
653639
mod test {
654640
use super::*;
655-
use crate::{
656-
test::*,
657-
web::{handlebars_engine, match_version},
658-
};
641+
use crate::{test::*, web::match_version};
659642
use kuchiki::traits::TendrilSink;
660643
use serde_json::json;
661644

@@ -864,11 +847,6 @@ mod test {
864847
});
865848
}
866849

867-
#[test]
868-
fn test_templates_are_valid() {
869-
handlebars_engine().expect("Failed to load handlebar templates");
870-
}
871-
872850
#[test]
873851
fn serialize_metadata() {
874852
let mut metadata = MetaData {

src/web/page/handlebars.rs

Lines changed: 0 additions & 190 deletions
This file was deleted.

src/web/page/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
mod handlebars;
21
mod templates;
32
mod web_page;
43

5-
pub use handlebars::*;
64
pub(crate) use templates::TemplateData;
75
pub(crate) use web_page::WebPage;
86

src/web/page/templates.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{
1616
use tera::{Result as TeraResult, Tera};
1717
use walkdir::WalkDir;
1818

19-
const TEMPLATES_DIRECTORY: &str = "tera-templates";
19+
const TEMPLATES_DIRECTORY: &str = "templates";
2020

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

4747
watcher
48-
.watch("tera-templates", RecursiveMode::Recursive)
48+
.watch(TEMPLATES_DIRECTORY, RecursiveMode::Recursive)
4949
.unwrap();
5050

5151
thread::spawn(move || {
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.

templates/footer.hbs

Lines changed: 0 additions & 5 deletions
This file was deleted.

templates/header.hbs

Lines changed: 0 additions & 27 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)