Hi. A user on this Otter game server, with account
{{ account }}
has invited you to join the game
- {}
+ {{ game_name }}
-You can play, directly, by visiting this link
+You can play, directly, by visiting this link in a suitable browser.
{{ token_url }}
They have set for you the nickname, within the game, of
{{ game_name }}
on this Otter server.
-You can play, directly, by visiting this link
+You can play, directly, by visiting this link in a suitable browser.
{{ token_url }}
I have set for you the nickname, within the game, of
+++ /dev/null
-// Copyright 2020 Ian Jackson
-// SPDX-License-Identifier: AGPL-3.0-or-later
-// There is NO WARRANTY.
-
-use parking_lot::Mutex;
-
-static TERA : Mutex<Option<State>> = const_mutex(None);
-
-pub fn template_render(name: &str) {
- let guard = TERA.lock();
- let tera =
-}
-
-struct State {
- tera: tera::Tera;
-}
-
-impl Default for State {
- fn default() -> State { State {
- tera: tera::new(
- } }
-}
-
-type TeraWrapper = RwLock<Arc<State>>;
-
-impl State {
-
-}
--- /dev/null
+// Copyright 2020 Ian Jackson
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+use parking_lot::RwLock;
+
+static STATE : RwLock<Option<State>> = const_mutex(None);
+
+#[throws(StartupError)]
+pub fn init() {
+ let guard = STATE.write();
+ assert!(guard.is_none());
+ let glob = format!("{}/*.tera", config().nwtemplates);
+ *guard = State {
+ tera: tera::new(&glob)?,
+ };
+}
+
+#[throws(tera::Error)]
+pub fn template_render<D: Serialize>(template_name: &str, data: &D) {
+ fn get_st() -> MappedRwLockReadGuard<State> {
+ STATE.read().as_ref().unwrap()
+ }
+ get_st().render(template_name, data)
+}
ipl: &IPlayerState,
token: AccessTokenInfo)
-> AccessTokenReport {
- let message = tempfile::tempfile()?;
- let gname = &g.name;
+ let messagefile = tempfile::tempfile()?;
+
+ #[derive(Serialize)]
+ struct CommonData<'r> {
+ player_email: &'r str,
+ game_name: &'r str,
+ token_url: &'r str,
+ nick: &'r str,
+ };
+ let common = CommonData {
+ player_email: &self.addr,
+ game_name: &g.name,
+ token_url: &
+ }
- match &ipl.account {
+ let message = match &ipl.account {
AS::Unix { user } => {
+ struct Data {
+ pub gname:
+ }
+
write!(&mut message, r#"\
"#,