chiark / gitweb /
wip wasm deploy
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Oct 2020 19:38:42 +0000 (20:38 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Oct 2020 19:38:42 +0000 (20:38 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/global.rs
templates/loading.tera

index b7c62d1959322e3c0a22db787e9071b03a0e68fe..7e7dc2fd7214924f617f0faaeee066d7dcf499a7 100644 (file)
@@ -1076,6 +1076,7 @@ const DEFAULT_SAVE_DIRECTORY : &str = "save";
 const DEFAULT_COMMAND_SOCKET : &str = "command.socket"; // in save dir
 const DEFAULT_TEMPLATE_DIR : &str = "templates";
 const DEFAULT_LIBRARY_DIR : &str = "library";
+const DEFAULT_WASM_DIR : &str = "target/packed-wasm";
 
 #[derive(Deserialize,Debug,Clone)]
 pub struct ServerConfigSpec {
@@ -1085,6 +1086,7 @@ pub struct ServerConfigSpec {
   pub http_port: Option<u16>,
   pub rocket_workers: Option<u16>,
   pub template_dir: Option<String>,
+  pub wasm_dir: Option<String>,
   pub log: Option<toml::Value>,
   pub bundled_sources: Option<String>,
   pub shapelibs: Option<Vec<shapelib::Config1>>,
@@ -1098,6 +1100,7 @@ pub struct ServerConfig {
   pub http_port: Option<u16>,
   pub rocket_workers: u16,
   pub template_dir: String,
+  pub wasm_dir: String,
   pub log: LogSpecification,
   pub bundled_sources: String,
   pub shapelibs: Vec<shapelib::Config1>,
@@ -1109,8 +1112,8 @@ impl TryFrom<ServerConfigSpec> for ServerConfig {
   fn try_from(spec: ServerConfigSpec) -> ServerConfig {
     let ServerConfigSpec {
       save_directory, command_socket, debug,
-      http_port, rocket_workers, template_dir, log, bundled_sources,
-      shapelibs,
+      http_port, rocket_workers, template_dir, wasm_dir,
+      log, bundled_sources, shapelibs,
     } = spec;
 
     let save_directory = save_directory
@@ -1152,10 +1155,12 @@ impl TryFrom<ServerConfigSpec> for ServerConfig {
         format!("{}/*.toml", DEFAULT_LIBRARY_DIR)
       )]);
 
+    let wasm_dir = wasm_dir.unwrap_or_else(|| DEFAULT_WASM_DIR.to_owned());
+
     ServerConfig {
       save_directory, command_socket, debug,
-      http_port, rocket_workers, template_dir, log, bundled_sources,
-      shapelibs,
+      http_port, rocket_workers, template_dir, wasm_dir,
+      log, bundled_sources, shapelibs,
     }
   }
 }
index e06dc75e64b82074f7a28443a535c1ab74373830..46c6f0e4ceeb80e1fdb506c18f376c53afaf6ce6 100644 (file)
@@ -4,8 +4,9 @@
 <html>
 <head>
 <link rel="license" href="/_/libre.html">
+<script defer>let wasm_input = fetch('/_/wasm');</script>
+<script src="/_/script.js" defer></script>
 </head>
 <body id="loading_body">
 <h1 id="loading_token" data-ptoken="{{ ptoken }}">Loading!</h1>
 <div id="error"></div>
-<script src="/_/script.js"></script>