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
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)
use rocket::{get,routes};
use rocket_contrib::serve::StaticFiles;
+use rocket::response::Content;
use otter::imports::*;
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{}
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{})
}
}
#[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)]
resource,
updates,
])
- .mount("/src", StaticFiles::from(bundled_sources))
+ .mount("/_/src", StaticFiles::from(bundled_sources))
;
let r = otter::session::mount(r);
--- /dev/null
+<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>
<!-- 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>
-{# -*- 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.
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 ?";