chiark / gitweb /
Rocket cleanup: Call our tera tera
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Mar 2022 22:54:10 +0000 (23:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Mar 2022 23:50:50 +0000 (00:50 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.toml
TODO
daemon/api.rs
daemon/main.rs
jstest/jstest.rs
src/bundles.rs
src/error.rs
src/imports.rs
src/nwtemplates.rs
src/prelude.rs

index b64d723447b701b8fb4a628d5991d83f3d2752b5..ee340adaa547099386c9f8eba14e01ca0360f419 100644 (file)
@@ -73,6 +73,7 @@ structopt="0.3"
 sha2="0.10"
 subtle="2.4"
 tempfile="3"
+tera="1.10"
 toml="0.5"
 typetag="0.1.6"
 uds="0.2"
@@ -92,8 +93,6 @@ mio          = { version="0.8",   features=["os-ext", "os-poll" ] }
 serde        = { version="1"    , features=["derive", "rc"] }
 strum        = { version="0.24" , features=["derive"      ] }
 
-tera_standalone = { version="1.10", package="tera" }
-
 slotmap = { package="slotmap-fork-otter", version="1", git="https://github.com/ijackson/slotmap", branch="slotmap-fork-otter", features=["serde"] }
 
 #fin.
diff --git a/TODO b/TODO
index 2a3dce9114cccca160612ad55d41bfe2f9b689e9..d41d9bec12a8477aaba2a02569b69a8322e5bb6f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,4 +4,3 @@ content-type for download bundles
 http2 HEAD requests
 fix listen
 fix that /_/updates vs /_/<leaf> involves ordering
-one tera version
index 4ec910f645a1aa16674d236076f2df898ca4b18e..dc6c3858fb59fc0cd718a6afa5efb394e58cb56e 100644 (file)
@@ -2,8 +2,6 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-use crate::imports::*;
-
 pub use super::*;
 
 #[derive(Clone,Debug)]
index 4812fdb540f8eb6a30911cea4ecf0a14a8515fe9..63e9340263fbd8434da8dff23662f3f0a8cab7fd 100644 (file)
@@ -5,7 +5,7 @@
 #![feature(lint_reasons)]
 #![feature(proc_macro_hygiene, decl_macro)]
 
-use otter::imports::thiserror;
+use otter::imports::*;
 
 pub mod imports;
 
@@ -37,8 +37,6 @@ use actix_files::NamedFile;
 use actix_cors::Cors;
 
 use otter::prelude::*;
-use otter::imports::tera_standalone as tera;
-use tera::Tera;
 
 const CT_JAVASCRIPT: mime::Mime = mime::APPLICATION_JAVASCRIPT_UTF_8;
 const CT_TEXT:      mime::Mime = mime::TEXT_PLAIN_UTF_8;
@@ -65,7 +63,7 @@ struct FrontPageRenderContext {
 pub type Template = HttpResponse;
 
 pub struct Templates {
-  tera: tera::Tera,
+  tera: Tera,
 }
 
 impl Templates {
index 1e17353c6b49584dee6a9ad7cc4298d3d0dbb2c2..fdc46010899b9173143aeb0f61a411908bfec524 100644 (file)
@@ -6,7 +6,6 @@ pub use otter::imports::*;
 pub use otter::prelude::*;
 
 pub use otter_api_tests::Explode;
-pub use otter::imports::tera_standalone as tera;
 
 pub use indexmap::IndexMap;
 pub use indexmap::IndexSet;
index 2dc4b715aa1ff1ff8d728bfa5bdfd8902a8847be..7b412dd6fc7ebc16b2685296e83342e7711d1be2 100644 (file)
@@ -922,7 +922,7 @@ pub fn spec_macroexpand(
 
   for (nomfile, data) in &templates { report(nomfile, data)?; }
 
-  let mut tera = tera_standalone::Tera::default();
+  let mut tera = Tera::default();
   tera.add_raw_templates(templates).context("load")?;
   let mut out: Vec<u8> = vec![];
   tera.render_to("spec", &default(), &mut out).context("render")?;
index 7b4a79aceea8ea2af47e73e64556d66835a812de..7204983478e2f28275c84410f05555aad4ccc280 100644 (file)
@@ -3,7 +3,6 @@
 // There is NO WARRANTY.
 
 use crate::prelude::*;
-use tera_standalone as tera;
 
 #[derive(Error,Debug)]
 pub enum Fatal { // Includes _bogus_ client updates, see PROTOCOL.md
index 88937c970270ba0df81f447d98790827611378f6..28580f2b67ab844105096d4de24fe81e51aaa0e8 100644 (file)
@@ -35,7 +35,7 @@ pub use regex;
 pub use rmp_serde;
 pub use sha2;
 pub use slotmap;
-pub use tera_standalone;
+pub use tera;
 pub use toml;
 pub use uds;
 pub use unicode_width;
index 42cf490bce2da2a102ab1b31d3a6e217fa6f04d4..b49062e48c824abf6fa49f753fb1e3a040b5b24f 100644 (file)
@@ -10,7 +10,7 @@ use parking_lot::{const_rwlock, RwLock, RwLockReadGuard};
 static STATE: RwLock<Option<State>> = const_rwlock(None);
 
 struct State {
-  tera: tera_standalone::Tera,
+  tera: Tera,
 }
 
 #[throws(StartupError)]
@@ -20,7 +20,7 @@ pub fn init() {
   let config = config();
   let nwtemplate_dir = &config.nwtemplate_dir;
   let glob = format!("{}/*.tera", nwtemplate_dir);
-  let tera = tera_standalone::Tera::new(&glob)
+  let tera = Tera::new(&glob)
     .map_err(|e| anyhow!("{}", e))
     .context("load tamplates")
     .with_context(|| nwtemplate_dir.to_string())?;
@@ -34,11 +34,11 @@ pub fn init() {
 pub fn render<D>(template_name: &str, data: &D) -> String
 where D: Serialize + Debug
 {
-  fn get_tera() -> MappedRwLockReadGuard<'static, tera_standalone::Tera> {
+  fn get_tera() -> MappedRwLockReadGuard<'static, Tera> {
     let g = STATE.read();
     RwLockReadGuard::map(g, |g| &g.as_ref().unwrap().tera)
   }
-  let context = tera_standalone::Context::from_serialize(data)
+  let context = tera::Context::from_serialize(data)
     .with_context(
       || format!("failed make context from serializable {:?}", data)
     )
index 06b91eea5a7cb30540ec9d746a912180e348307e..0a8db3615c350d3bd49167328f981e36b0332ddb 100644 (file)
@@ -101,6 +101,7 @@ pub use strum::{EnumString, EnumIter, EnumMessage, EnumProperty};
 pub use strum::{IntoEnumIterator, IntoStaticStr};
 pub use subtle::ConstantTimeEq;
 pub use tempfile::{self, NamedTempFile};
+pub use tera::Tera;
 pub use thiserror::Error;
 pub use unicase::UniCase;
 pub use url::Url;