From fd0033e1c0e1720863cc921b1839ef7542ff0735 Mon Sep 17 00:00:00 2001 From: Krateng Date: Wed, 4 Dec 2019 20:41:53 +0100 Subject: [PATCH] Adjusted structure to be closer to albula --- maloja/__init__.py | 3 +- maloja/server.py | 32 ++++++++++-------- maloja/{web => static/ico}/favicon.ico | Bin .../{web/javascript => static/js}/cookies.js | 0 .../javascript => static/js}/datechange.js | 0 .../javascript => static/js}/neopolitan.js | 0 .../javascript => static/js}/rangeselect.js | 0 .../{web/javascript => static/js}/search.js | 0 .../{web/javascript => static/js}/upload.js | 0 maloja/{web => static}/less/grisons.less | 0 maloja/{web => static}/less/grisonsfont.less | 0 maloja/{web => static}/less/maloja.less | 0 .../media => static/png}/chartpos_bronze.png | Bin .../media => static/png}/chartpos_gold.png | Bin .../media => static/png}/chartpos_normal.png | Bin .../media => static/png}/chartpos_silver.png | Bin maloja/{web => static/png}/favicon.png | Bin .../media => static/png}/record_diamond.png | Bin .../{web/media => static/png}/record_gold.png | Bin .../png}/record_gold_original.png | Bin .../media => static/png}/record_platinum.png | Bin maloja/{web/media => static/png}/star.png | Bin maloja/{web/media => static/png}/star_alt.png | Bin maloja/{web => static/txt}/robots.txt | 0 maloja/web/admin.pyhp | 2 +- maloja/web/artist.html | 4 +-- maloja/web/artist.pyhp | 2 +- maloja/web/charts_artists.html | 2 +- maloja/web/common/header.html | 8 ++--- maloja/web/issues.html | 2 +- maloja/web/manual.html | 2 +- maloja/web/proxy.html | 2 +- maloja/web/setup.html | 2 +- maloja/web/start.html | 4 +-- maloja/web/track.html | 4 +-- maloja/web/track.pyhp | 2 +- 36 files changed, 38 insertions(+), 33 deletions(-) rename maloja/{web => static/ico}/favicon.ico (100%) rename maloja/{web/javascript => static/js}/cookies.js (100%) rename maloja/{web/javascript => static/js}/datechange.js (100%) rename maloja/{web/javascript => static/js}/neopolitan.js (100%) rename maloja/{web/javascript => static/js}/rangeselect.js (100%) rename maloja/{web/javascript => static/js}/search.js (100%) rename maloja/{web/javascript => static/js}/upload.js (100%) rename maloja/{web => static}/less/grisons.less (100%) rename maloja/{web => static}/less/grisonsfont.less (100%) rename maloja/{web => static}/less/maloja.less (100%) rename maloja/{web/media => static/png}/chartpos_bronze.png (100%) rename maloja/{web/media => static/png}/chartpos_gold.png (100%) rename maloja/{web/media => static/png}/chartpos_normal.png (100%) rename maloja/{web/media => static/png}/chartpos_silver.png (100%) rename maloja/{web => static/png}/favicon.png (100%) rename maloja/{web/media => static/png}/record_diamond.png (100%) rename maloja/{web/media => static/png}/record_gold.png (100%) rename maloja/{web/media => static/png}/record_gold_original.png (100%) rename maloja/{web/media => static/png}/record_platinum.png (100%) rename maloja/{web/media => static/png}/star.png (100%) rename maloja/{web/media => static/png}/star_alt.png (100%) rename maloja/{web => static/txt}/robots.txt (100%) diff --git a/maloja/__init__.py b/maloja/__init__.py index 46e9d61..02e1f7a 100644 --- a/maloja/__init__.py +++ b/maloja/__init__.py @@ -7,7 +7,7 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 2,0,3 +version = 2,0,4 versionstr = ".".join(str(n) for n in version) @@ -23,6 +23,7 @@ requires = [ resources = [ "web/*/*", "web/*", + "static/*/*", "data_files/*/*", "data_files/.doreah" ] diff --git a/maloja/server.py b/maloja/server.py index 967628d..5ca6c58 100755 --- a/maloja/server.py +++ b/maloja/server.py @@ -45,8 +45,9 @@ MAIN_PORT = settings.get_settings("WEB_PORT") HOST = settings.get_settings("HOST") THREADS = 12 BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024 -WEBFOLDER = pkg_resources.resource_filename(__name__,"web") +WEBFOLDER = pkg_resources.resource_filename(__name__,"web") +STATICFOLDER = pkg_resources.resource_filename(__name__,"static") webserver = Bottle() @@ -56,8 +57,8 @@ def generate_css(): import lesscpy from io import StringIO less = "" - for f in os.listdir(pthjoin(WEBFOLDER,"less")): - with open(pthjoin(WEBFOLDER,"less",f),"r") as lessf: + for f in os.listdir(pthjoin(STATICFOLDER,"less")): + with open(pthjoin(STATICFOLDER,"less",f),"r") as lessf: less += lessf.read() css = lesscpy.compile(StringIO(less),minify=True) @@ -153,27 +154,30 @@ def static_image(pth): return response -@webserver.route("/css/style.css") +@webserver.route("/style.css") def get_css(): response.content_type = 'text/css' return css -#@webserver.route("/") -@webserver.route("/") -@webserver.route("/") -@webserver.route("/") -@webserver.route("/") -@webserver.route("/") -@webserver.route("/") -def static(name): - response = static_file(name,root=WEBFOLDER) + +@webserver.route("/.") +def static(name,ext): + assert ext in ["txt","ico","jpeg","jpg","png","less","js"] + response = static_file(ext + "/" + name + "." + ext,root=STATICFOLDER) + response.set_header("Cache-Control", "public, max-age=3600") + return response + +@webserver.route("/media/.") +def static(name,ext): + assert ext in ["ico","jpeg","jpg","png"] + response = static_file(ext + "/" + name + "." + ext,root=STATICFOLDER) response.set_header("Cache-Control", "public, max-age=3600") return response @webserver.route("/") def static_html(name): - linkheaders = ["; rel=preload; as=style"] + linkheaders = ["; rel=preload; as=style"] keys = remove_identical(FormsDict.decode(request.query)) pyhp_file = os.path.exists(pthjoin(WEBFOLDER,name + ".pyhp")) diff --git a/maloja/web/favicon.ico b/maloja/static/ico/favicon.ico similarity index 100% rename from maloja/web/favicon.ico rename to maloja/static/ico/favicon.ico diff --git a/maloja/web/javascript/cookies.js b/maloja/static/js/cookies.js similarity index 100% rename from maloja/web/javascript/cookies.js rename to maloja/static/js/cookies.js diff --git a/maloja/web/javascript/datechange.js b/maloja/static/js/datechange.js similarity index 100% rename from maloja/web/javascript/datechange.js rename to maloja/static/js/datechange.js diff --git a/maloja/web/javascript/neopolitan.js b/maloja/static/js/neopolitan.js similarity index 100% rename from maloja/web/javascript/neopolitan.js rename to maloja/static/js/neopolitan.js diff --git a/maloja/web/javascript/rangeselect.js b/maloja/static/js/rangeselect.js similarity index 100% rename from maloja/web/javascript/rangeselect.js rename to maloja/static/js/rangeselect.js diff --git a/maloja/web/javascript/search.js b/maloja/static/js/search.js similarity index 100% rename from maloja/web/javascript/search.js rename to maloja/static/js/search.js diff --git a/maloja/web/javascript/upload.js b/maloja/static/js/upload.js similarity index 100% rename from maloja/web/javascript/upload.js rename to maloja/static/js/upload.js diff --git a/maloja/web/less/grisons.less b/maloja/static/less/grisons.less similarity index 100% rename from maloja/web/less/grisons.less rename to maloja/static/less/grisons.less diff --git a/maloja/web/less/grisonsfont.less b/maloja/static/less/grisonsfont.less similarity index 100% rename from maloja/web/less/grisonsfont.less rename to maloja/static/less/grisonsfont.less diff --git a/maloja/web/less/maloja.less b/maloja/static/less/maloja.less similarity index 100% rename from maloja/web/less/maloja.less rename to maloja/static/less/maloja.less diff --git a/maloja/web/media/chartpos_bronze.png b/maloja/static/png/chartpos_bronze.png similarity index 100% rename from maloja/web/media/chartpos_bronze.png rename to maloja/static/png/chartpos_bronze.png diff --git a/maloja/web/media/chartpos_gold.png b/maloja/static/png/chartpos_gold.png similarity index 100% rename from maloja/web/media/chartpos_gold.png rename to maloja/static/png/chartpos_gold.png diff --git a/maloja/web/media/chartpos_normal.png b/maloja/static/png/chartpos_normal.png similarity index 100% rename from maloja/web/media/chartpos_normal.png rename to maloja/static/png/chartpos_normal.png diff --git a/maloja/web/media/chartpos_silver.png b/maloja/static/png/chartpos_silver.png similarity index 100% rename from maloja/web/media/chartpos_silver.png rename to maloja/static/png/chartpos_silver.png diff --git a/maloja/web/favicon.png b/maloja/static/png/favicon.png similarity index 100% rename from maloja/web/favicon.png rename to maloja/static/png/favicon.png diff --git a/maloja/web/media/record_diamond.png b/maloja/static/png/record_diamond.png similarity index 100% rename from maloja/web/media/record_diamond.png rename to maloja/static/png/record_diamond.png diff --git a/maloja/web/media/record_gold.png b/maloja/static/png/record_gold.png similarity index 100% rename from maloja/web/media/record_gold.png rename to maloja/static/png/record_gold.png diff --git a/maloja/web/media/record_gold_original.png b/maloja/static/png/record_gold_original.png similarity index 100% rename from maloja/web/media/record_gold_original.png rename to maloja/static/png/record_gold_original.png diff --git a/maloja/web/media/record_platinum.png b/maloja/static/png/record_platinum.png similarity index 100% rename from maloja/web/media/record_platinum.png rename to maloja/static/png/record_platinum.png diff --git a/maloja/web/media/star.png b/maloja/static/png/star.png similarity index 100% rename from maloja/web/media/star.png rename to maloja/static/png/star.png diff --git a/maloja/web/media/star_alt.png b/maloja/static/png/star_alt.png similarity index 100% rename from maloja/web/media/star_alt.png rename to maloja/static/png/star_alt.png diff --git a/maloja/web/robots.txt b/maloja/static/txt/robots.txt similarity index 100% rename from maloja/web/robots.txt rename to maloja/static/txt/robots.txt diff --git a/maloja/web/admin.pyhp b/maloja/web/admin.pyhp index 2229e92..0221c61 100644 --- a/maloja/web/admin.pyhp +++ b/maloja/web/admin.pyhp @@ -5,7 +5,7 @@ Maloja - + diff --git a/maloja/web/artist.html b/maloja/web/artist.html index d9f4a03..8a48636 100644 --- a/maloja/web/artist.html +++ b/maloja/web/artist.html @@ -4,8 +4,8 @@ Maloja - KEY_ARTISTNAME - - + + diff --git a/maloja/web/artist.pyhp b/maloja/web/artist.pyhp index 6070112..dfe915d 100644 --- a/maloja/web/artist.pyhp +++ b/maloja/web/artist.pyhp @@ -37,7 +37,7 @@ Maloja - <pyhp echo="artist" /> - + diff --git a/maloja/web/charts_artists.html b/maloja/web/charts_artists.html index 6b070c9..e203049 100644 --- a/maloja/web/charts_artists.html +++ b/maloja/web/charts_artists.html @@ -4,7 +4,7 @@ Maloja - Artist Charts - + diff --git a/maloja/web/common/header.html b/maloja/web/common/header.html index 37d9792..e23b9f3 100644 --- a/maloja/web/common/header.html +++ b/maloja/web/common/header.html @@ -5,7 +5,7 @@ --> - - - - + + + + diff --git a/maloja/web/issues.html b/maloja/web/issues.html index 31e10f0..59eb1bd 100644 --- a/maloja/web/issues.html +++ b/maloja/web/issues.html @@ -4,7 +4,7 @@ Maloja - Issues - + diff --git a/maloja/web/manual.html b/maloja/web/manual.html index b642a8d..e880d5c 100644 --- a/maloja/web/manual.html +++ b/maloja/web/manual.html @@ -4,7 +4,7 @@ Maloja - + + + - - + + diff --git a/maloja/web/track.html b/maloja/web/track.html index c67b824..1fdd265 100644 --- a/maloja/web/track.html +++ b/maloja/web/track.html @@ -4,8 +4,8 @@ Maloja - KEY_TRACKTITLE - - + + diff --git a/maloja/web/track.pyhp b/maloja/web/track.pyhp index b872390..f3c352a 100644 --- a/maloja/web/track.pyhp +++ b/maloja/web/track.pyhp @@ -18,7 +18,7 @@ Maloja - <pyhp echo="track['title']" /> - +