From 57938b487b102deed0ed6c356e2fb7fb743f8d08 Mon Sep 17 00:00:00 2001 From: Bruce Martin Date: Thu, 26 Mar 2020 11:45:10 -0600 Subject: [PATCH] remove static route redirects / bump static to top level (#1299) * add another favicon rule * catch only top-level dataset names * add config flag to disable redirects * remove static redirect, point all links to top-level /static * remove extraneous argument * remove httpd redirect --- .../webpack/webpack.config.dev.js | 2 +- .../webpack/webpack.config.prod.js | 2 +- client/index_template.html | 88 +++++++++++-------- server/app/app.py | 10 +-- server/eb/.ebextensions/static_rewrite.config | 11 --- 5 files changed, 56 insertions(+), 57 deletions(-) delete mode 100644 server/eb/.ebextensions/static_rewrite.config diff --git a/client/configuration/webpack/webpack.config.dev.js b/client/configuration/webpack/webpack.config.dev.js index 4498cebd..73d06752 100644 --- a/client/configuration/webpack/webpack.config.dev.js +++ b/client/configuration/webpack/webpack.config.dev.js @@ -90,7 +90,7 @@ module.exports = { __REACT_DEVTOOLS_GLOBAL_HOOK__: "({ isDisabled: true })" }), new webpack.DefinePlugin({ - "process.env.CXG_SERVER_PORT": JSON.stringify(process.env.CXG_SERVER_PORT), + "process.env.CXG_SERVER_PORT": JSON.stringify(process.env.CXG_SERVER_PORT) }) ] }; diff --git a/client/configuration/webpack/webpack.config.prod.js b/client/configuration/webpack/webpack.config.prod.js index 8ee88746..2c4981a4 100644 --- a/client/configuration/webpack/webpack.config.prod.js +++ b/client/configuration/webpack/webpack.config.prod.js @@ -11,7 +11,7 @@ const nodeModules = path.resolve("node_modules"); const babelOptions = require("../babel/babel.prod"); -const publicPath = ""; +const publicPath = "/"; module.exports = { mode: "production", diff --git a/client/index_template.html b/client/index_template.html index 075448a5..ff3eef0b 100644 --- a/client/index_template.html +++ b/client/index_template.html @@ -1,42 +1,58 @@ - - - - cell×gene - - + * { + box-sizing: border-box; + } + + + + + + - - - - - -
-{% for script in SCRIPTS %} - -{% endfor %} - +
+ {% for script in SCRIPTS %} + + {% endfor %} + diff --git a/server/app/app.py b/server/app/app.py index 293da8d2..de88a5b3 100644 --- a/server/app/app.py +++ b/server/app/app.py @@ -44,7 +44,9 @@ def dataset_index(dataset=None): ) +# TODO: remove the top-level /favicon route once the build problem with index.html is resolved @webbp.route("/favicon.png", methods=["GET"]) +@webbp.route("/static/img/favicon.png", methods=["GET"]) def favicon(): return send_from_directory(os.path.join(webbp.root_path, "static/img/"), "favicon.png") @@ -89,11 +91,6 @@ def rest_get_data_adaptor(func): return wrapped_function -def static_redirect(dataset, therest): - """ redirect all static requests to the standard location """ - return redirect(f"/static/{therest}", code=301) - - def dataroot_test_index(): # the following index page is meant for testing/debugging purposes data = '' @@ -229,9 +226,6 @@ class Server: resources = get_api_resources(bp_api) self.app.register_blueprint(resources.blueprint) self.app.add_url_rule("/d//", "dataset_index", dataset_index, methods=["GET"]) - self.app.add_url_rule( - "/d//static/", "static_redirect", static_redirect, methods=["GET"] - ) self.app.matrix_data_cache_manager = matrix_data_cache_manager self.app.annotations = annotations diff --git a/server/eb/.ebextensions/static_rewrite.config b/server/eb/.ebextensions/static_rewrite.config deleted file mode 100644 index 442aa53c..00000000 --- a/server/eb/.ebextensions/static_rewrite.config +++ /dev/null @@ -1,11 +0,0 @@ -# Configure URL rewriting from //static/* to /static/* -files: - "/etc/httpd/conf.d/static_rewrite.conf": - mode: "000644" - owner: root - group: root - content: | - RewriteEngine On - RewriteRule "^(.*)/static/(.*)" "/static/$2" [PT] - RewriteRule "^/favicon.png" "/static/img/favicon.png" [PT] -