From 0933a22a34d26dbe64e20e84e4700807ba7be3a9 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 18 Dec 2020 23:14:40 -0300 Subject: Initial commit --- .gitignore | 16 +++++++++++++ README | 14 +++++++++++ comp.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ raw/ATTRIBUTION.md | 50 +++++++++++++++++++++++++++++++++++++++ raw/bg/battle2.jpg | Bin 0 -> 458612 bytes raw/bg/castle.jpg | Bin 0 -> 574349 bytes raw/bg/tavern.jpg | Bin 0 -> 655315 bytes 7 files changed, 148 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100755 comp.py create mode 100644 raw/ATTRIBUTION.md create mode 100644 raw/bg/battle2.jpg create mode 100644 raw/bg/castle.jpg create mode 100644 raw/bg/tavern.jpg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..455e12e --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Patterns to ignore. + +# Binaries +*.pyc +resources.json + +#Back up +*.bak +*~ + +# Development files +live +*.dev.* +*.dev** +tba/* +x* diff --git a/README b/README new file mode 100644 index 0000000..adbca68 --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +This is the update server. By default, it will output files to: +/var/www/html/assets + +Simply use comp.py and it will convert assets and pretty much handle everything +for you. Make sure that raw/ folder is consistent with the same rules which builtin +assets follow regarding paths. + +This is a development tool for optimization and not required for your server. +It **only** works in Debian Buster and other systems similar to this one, like +Ubuntu 18.04. +You can use, eg. GitLab Pages to serve the files and make a 301 on main server, or +simply not use the tool at all. + +The choice is yours. diff --git a/comp.py b/comp.py new file mode 100755 index 0000000..97ec03a --- /dev/null +++ b/comp.py @@ -0,0 +1,68 @@ +#!/usr/bin/python2.7 +######################################################################################## +# This file is part of Spheres. +# Copyright (C) 2019 Jesusalva + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +######################################################################################## +# This builds live/ folder for Update Server +import subprocess, json, sys, os, traceback +PATH="/var/www/html/assets" + +# Delete previous deployment +subprocess.call("rm --recursive %s/*" % PATH, shell=True) +f=open("resources.json", "w") + +rc=[] + +# Go through every file in raw and give them a hash +for path, subdir, files in os.walk("raw/"): + for n in files: + fn=os.path.join(path, n) + + # Ignored files + if fn.endswith("~"): + continue + + # Copy and update resource table + print(fn) + try: + NAME=fn.replace("raw/", "").replace("/", "_") + EXT=NAME.split(".")[-1:][0] + NAME=NAME.split(".")[:-1][0] + ## TODO code + if EXT in ["png", "jpg", "jpeg"]: + subprocess.call("convert %s %s/%s" % (fn, PATH, NAME), shell=True) + EXT="webp" + else: + subprocess.call("cp %s %s/%s.%s" % (fn, PATH, NAME, EXT), shell=True) + rc.append([NAME, EXT]) + except: + traceback.print_exc() + pass + +# Save new summary +json.dump(rc, f) +f.close() + +# Create blank index page to disable dir listing +subprocess.call("touch %s/index.html" % PATH, shell=True) + +# Correct permissions +subprocess.call("chown -R www-data:www-data %s/*" % PATH, shell=True) +subprocess.call("chmod --recursive o-rwx %s/*" % PATH, shell=True) + +# TODO: zip everything and provide an all-in-one download? + diff --git a/raw/ATTRIBUTION.md b/raw/ATTRIBUTION.md new file mode 100644 index 0000000..1cd4b72 --- /dev/null +++ b/raw/ATTRIBUTION.md @@ -0,0 +1,50 @@ +For DMCA complaints please email dmca@tmw2.org and we will try to correct it +within 30 (thirty) days. + +This special license file covers assets only, for code, you must refer to their +headers and to the COPYING file. + +Notes: Works submitted by Jesusalva and under CC0, may also be used as if they +were under the Apache license without the need of prior consent. + +---- + +GPLv2: Licensed under GNU General Public License version2 or later. +http://www.gnu.org/licenses/gpl-2.0.html +See also the GPL file. + +GPLv3: Licensed under GNU General Public License version3 or later. +http://www.gnu.org/licenses/gpl-3.0.html +See also the COPYING + +CC BY-SA 4.0: Licensed under Creative Commons Attribution-ShareAlike 4.0 Unported. +http://creativecommons.org/licenses/by-sa/4.0/ +See also the CC BY-SA 4.0 file. + +CC0 : Licensed under Creative Commons Zero +http://creativecommons.org/licenses/cc0 +Also known as “Public Domain Dedication” + +MIT : Licensed under the MIT License. +https://opensource.org/licenses/MIT +See also MIT file. + +This copyright notice must be kept intact for use, according to CC BY-SA +compatibility terms. +Where relevant, you must also include a link to https://tmw2.org in your credit. + +--------------------------------------------------------------------------------- +# Folder + path/to/the/licensed/work.something (Author) (License) (Notes/Contributors/Authors/Co-Authors/Sources/etc.) + +# BG + bg/battle2.jpg (Écrivain) (CC0) (OpenGameArt) + bg/castle.jpg (yd) (CC0) (OpenGameArt) + bg/tavern.jpg (?) (CC0) (Bridge to Hrad Valdštejn - edit by Jesusalva) + + + + + + + diff --git a/raw/bg/battle2.jpg b/raw/bg/battle2.jpg new file mode 100644 index 0000000..9c6cb8d Binary files /dev/null and b/raw/bg/battle2.jpg differ diff --git a/raw/bg/castle.jpg b/raw/bg/castle.jpg new file mode 100644 index 0000000..5298e38 Binary files /dev/null and b/raw/bg/castle.jpg differ diff --git a/raw/bg/tavern.jpg b/raw/bg/tavern.jpg new file mode 100644 index 0000000..a520eb5 Binary files /dev/null and b/raw/bg/tavern.jpg differ -- cgit v1.2.3-70-g09d2