chiark / gitweb /
wip copyright stuff
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Oct 2020 21:53:33 +0000 (22:53 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Oct 2020 21:53:33 +0000 (22:53 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
Makefile
src/bin/daemon-otter.rs
templates/libre [new file with mode: 0644]
templates/loading.tera
templates/session.tera
usvg-processor

index 2a32136ab3f38f9fae9c4aefb8110914e8bee119..5156c5dd952f652096ed6d8dcafb82cc7c09bcc3 100644 (file)
@@ -1,4 +1,7 @@
 templates/script.js
-templates/LICENCE.txt
+templates/LICENCE
+templates/AGPLv3
+templates/CC-BY-SA-3.0
+templates/CC-BY-SA-4.0
 save/lock
 /library/*/*.usvg
index 0d27f653c9d99a2532d013c1b7476431e02bda37..095a78055fee0cf4e2e33743c6897a00b63df465 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -41,9 +41,17 @@ USVG_PROCESSOR = usvg-processor
 LIBRARY_PROCESS_SVG = ./$(USVG_PROCESSOR) $@ $(wordlist 1,2,$^) '$(USVG) $(USVG_OPTIONS)'
 $(LIBRARY_FILES): $(USVG_PROCESSOR) Makefile
 
-assets: templates/script.js templates/LICENCE.txt libraries
+LITFILES= LICENCE AGPLv3
+TXTFILES= CC-BY-SA-3.0 CC-BY-SA-4.0
 
-templates/LICENCE.txt: templates/%.txt: %
+FILEASSETS = $(addprefix templates/,$(LITFILES) $(TXTFILES))
+
+assets: templates/script.js libraries $(FILEASSETS)
+
+$(addprefix templates/,$(LITFILES)): templates/%: %;
+       cp $< $@.new && mv -f $@.new $@
+
+$(addprefix templates/,$(TXTFILES)): templates/%: %.txt
        cp $< $@.new && mv -f $@.new $@
 
 libraries: $(LIBRARY_FILES)
index 420d35f7f59986d52e2aea82983d8cec0344f196..1458c220cdb8b6a8338b6b4ac4b4eecb2b2da2aa 100644 (file)
@@ -11,6 +11,7 @@
 
 use rocket::{get,routes};
 use rocket_contrib::serve::StaticFiles;
+use rocket::response::Content;
 
 use otter::imports::*;
 
@@ -24,10 +25,22 @@ fn index() -> Template {
   Template::render("test",&c)
 }
 
-const RESOURCES : &[&str] = &["script.js", "style.css", "LICENCE.txt"];
+const RESOURCES : &[(&'static str, ContentType)] = &[
+  ("script.js",    ContentType::JavaScript),
+  ("style.css",    ContentType::JavaScript),
+  ("LICENCE",      ContentType::Plain),
+  ("libre",        ContentType::HTML),
+  ("AGPLv3",       ContentType::Plain),
+  ("CC-BY-SA-3.0", ContentType::Plain),
+  ("CC-BY-SA-4.0", ContentType::Plain),
+];
 
 #[derive(Debug)]
-struct CheckedResourceLeaf { pub safe : &'static str }
+struct CheckedResourceLeaf {
+  safe_leaf: &'static str,
+  ctype: ContentType,
+}
+
 #[derive(Error,Debug)]
 #[error("not a valid resource path")]
 struct UnknownResource{}
@@ -35,8 +48,10 @@ struct UnknownResource{}
 impl<'r> FromParam<'r> for CheckedResourceLeaf {
   type Error = UnknownResource;
   fn from_param(param: &'r RawStr) -> Result<Self, Self::Error> {
-    for &safe in RESOURCES {
-      if safe == param.as_str() { return Ok(CheckedResourceLeaf{ safe }) }
+    for &(safe_leaf, ref ctype) in RESOURCES {
+      if safe_leaf == param.as_str() {
+        return Ok(CheckedResourceLeaf { safe_leaf, ctype: ctype.clone() })
+      }
     }
     Err(UnknownResource{})
   }
@@ -71,8 +86,10 @@ fn updates<'r>(ctoken : InstanceAccess<ClientId>, gen: u64,
 }  
 
 #[get("/_/<leaf>")]
-fn resource(leaf : CheckedResourceLeaf) -> io::Result<NamedFile> {
-  NamedFile::open(format!("{}/{}", config().template_dir, leaf.safe))
+#[throws(io::Error)]
+fn resource<'r>(leaf : CheckedResourceLeaf) -> impl Responder<'r> {
+  let path = format!("{}/{}", config().template_dir, leaf.safe_leaf);
+  Content(leaf.ctype, NamedFile::open(path)?)
 }  
 
 #[throws(StartupError)]
@@ -145,7 +162,7 @@ fn main() {
       resource,
       updates,
     ])
-    .mount("/src", StaticFiles::from(bundled_sources))
+    .mount("/_/src", StaticFiles::from(bundled_sources))
     ;
 
   let r = otter::session::mount(r);
diff --git a/templates/libre b/templates/libre
new file mode 100644 (file)
index 0000000..a3441f6
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+  <head>
+    <title>otter - Free Software, source code, legal</title>
+  </head>
+<body>
+
+<h1>otter - Online TableTop Environment Renderer</h1>
+<p>
+  This server is running otter, the Online TableTop Environment
+  Renderer.
+<p>
+  otter is Free Software, according to the <a href="AGPLv3">GNU Affero General
+  Public License, version 3</a> or (at your option) any later version.
+  There is NO WARRANTY.
+<p>
+  You can download <a href="/_/src/">source code for this running server
+  version</a>.  That includes the source code for all the included
+  game piece pictures (shape libraries).
+<p>
+  The shape libraries have a variety of licences.
+  All those included with otter are available under at least
+  <a href="CC-BY-SA-3.0">CC-BY-SA 3.0</a> or
+  <a href="CC-BY-SA-4.0">CC-BY-SA 4.0</a>.
+  Check the source in "view source" in your browser, or the browser
+  Developer Tools (in Firefox, use Inspector);
+  that will also tell you the library piece filename.
+  If you want to edit them you will probably
+  want to start with the actual source code,
+  because the SVG pieces as sent by the server have generally
+  been fed though an SVG distiller.
+<p>
+  <a href="/_/LICENCE">Further information about licensing</a>
+  etc. is available here, and of course also in the source code.
+</body>
+</html>
index ec7188dc2914d98aebe6005232ac3cf4f0cc4570..e06dc75e64b82074f7a28443a535c1ab74373830 100644 (file)
@@ -1,10 +1,9 @@
 <!-- Copyright 2020 Ian Jackson
      SPDX-License-Identifier: AGPL-3.0-or-later
-     There is NO WARRANTY.
-     Source code for this running version is at /src -->
+     There is NO WARRANTY. -->
 <html>
 <head>
-<link rel="license" href="/_/LICENCE.txt">
+<link rel="license" href="/_/libre.html">
 </head>
 <body id="loading_body">
 <h1 id="loading_token" data-ptoken="{{ ptoken }}">Loading!</h1>
index daccf8d61d9947356d83e0a4fcade4d5d5854591..fceae1ba558cde2a9280c55aad02bbfa4041cb5d 100644 (file)
@@ -1,4 +1,4 @@
-{# -*- HTML -*- -#}<body id="main-body" 
+<body id="main-body" {# -*- HTML -*- -#}
       data-ctoken="{{ctoken}}"
       data-us="{{player}}"
       data-gen="{{gen}}"
 
 <hr>
 <address>
-  This server is running otter, the Online TableTop Environment
-  Renderer.
-<p>
-  otter is Free Software, according to the GNU Affero General
-  Public License, version 3 or (at your option) any later version.
-  There is NO WARRANTY.
-  You can download <a href="/src/">source code for this running server
-  version</a>.  That includes the source code for all the included
-  game piece pictures (shape libraries).
-<p>
-  The shape libraries have a variety of licences.  All those included
-  with otter are available under at least CC-BY-SA 3.0 or CC-BY-SA
-  4.0.  Check the source in "view source" in your browser, or the
-  browser Developer Tools (in Firefox, use Inspector); that will also
-  tell you the library piece filename.  If you want to edit them you
-  will probably want to start with the actual source code, because the
-  SVG pieces as sent by the server have generally been fed though an
-  SVG distiller.
-<p>
-  <a href="/_/LICENCE.txt">Further information about licensing</a>
-  etc. is available here, and of course also in the source code.
-</body>
-</html>
+This server is running otter, the Online TableTop Environment
+Renderer.  otter and its shape (piece picture) libraries
+are <a href="/_/libre">Free Software</a> and come with NO
+WARRANTY.
index 4e7b1af275bfc346aeb2382fc106347457f48b27..9985a274d607684e6103e281fcba43d08b2ef0e9 100755 (executable)
@@ -12,7 +12,7 @@ open STDIN, "<", $in or die $!;
 sub add_lic () {
   while (<L>) {
     next unless m{^\s*SPDX-License-Identifier:\s+(\S.*?)\s*$};
-    print "<!-- $out $1, see $lic -->\n" or die $!;
+    print "<!-- otter $out $1, see $lic -->\n" or die $!;
     return;
   }
   die "no spdx in $lic ?";