From: Ian Jackson Date: Fri, 2 Oct 2020 21:53:33 +0000 (+0100) Subject: wip copyright stuff X-Git-Tag: otter-0.2.0~804 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e6e15e7d11b6ee9a5e7fff8454bbf2419dab6bb3;p=otter.git wip copyright stuff Signed-off-by: Ian Jackson --- diff --git a/.gitignore b/.gitignore index 2a32136a..5156c5dd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index 0d27f653..095a7805 100644 --- 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) diff --git a/src/bin/daemon-otter.rs b/src/bin/daemon-otter.rs index 420d35f7..1458c220 100644 --- a/src/bin/daemon-otter.rs +++ b/src/bin/daemon-otter.rs @@ -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 { - 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, gen: u64, } #[get("/_/")] -fn resource(leaf : CheckedResourceLeaf) -> io::Result { - 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 index 00000000..a3441f69 --- /dev/null +++ b/templates/libre @@ -0,0 +1,35 @@ + + + otter - Free Software, source code, legal + + + +

otter - Online TableTop Environment Renderer

+

+ This server is running otter, the Online TableTop Environment + Renderer. +

+ 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 source code for this running server + version. That includes the source code for all the included + game piece pictures (shape libraries). +

+ 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. +

+ Further information about licensing + etc. is available here, and of course also in the source code. + + diff --git a/templates/loading.tera b/templates/loading.tera index ec7188dc..e06dc75e 100644 --- a/templates/loading.tera +++ b/templates/loading.tera @@ -1,10 +1,9 @@ + There is NO WARRANTY. --> - +

Loading!

diff --git a/templates/session.tera b/templates/session.tera index daccf8d6..fceae1ba 100644 --- a/templates/session.tera +++ b/templates/session.tera @@ -1,4 +1,4 @@ -{# -*- HTML -*- -#}
- This server is running otter, the Online TableTop Environment - Renderer. -

- 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 source code for this running server - version. That includes the source code for all the included - game piece pictures (shape libraries). -

- 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. -

- Further information about licensing - etc. is available here, and of course also in the source code. - - +This server is running otter, the Online TableTop Environment +Renderer. otter and its shape (piece picture) libraries +are Free Software and come with NO +WARRANTY. diff --git a/usvg-processor b/usvg-processor index 4e7b1af2..9985a274 100755 --- a/usvg-processor +++ b/usvg-processor @@ -12,7 +12,7 @@ open STDIN, "<", $in or die $!; sub add_lic () { while () { next unless m{^\s*SPDX-License-Identifier:\s+(\S.*?)\s*$}; - print "\n" or die $!; + print "\n" or die $!; return; } die "no spdx in $lic ?";