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
This commit is contained in:
Bruce Martin
2020-03-26 11:45:10 -06:00
committed by GitHub
parent 40c2e4c164
commit 57938b487b
5 changed files with 56 additions and 57 deletions

View File

@@ -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)
})
]
};

View File

@@ -11,7 +11,7 @@ const nodeModules = path.resolve("node_modules");
const babelOptions = require("../babel/babel.prod");
const publicPath = "";
const publicPath = "/";
module.exports = {
mode: "production",

View File

@@ -1,42 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>cell&times;gene</title>
<style>
html, body, p, h1, h2, h3, h4, h5, h6, span, button, input, label, text, div {
font-family: 'Roboto Condensed', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
font-size: 14px;
}
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>cell&times;gene</title>
<style>
html,
body,
p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
button,
input,
label,
text,
div {
font-family: "Roboto Condensed", "Helvetica Neue", "Helvetica",
"Arial", sans-serif;
font-size: 14px;
}
body {
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
</style>
<link rel="shortcut icon" href="static/img/favicon.png">
* {
box-sizing: border-box;
}
</style>
<link rel="shortcut icon" href="/static/img/favicon.png" />
</head>
<body>
<script type="text/javascript">
window.CELLXGENE = {};
window.CELLXGENE.API = {
prefix: window.location.href + "api/",
version: "v0.2/"
};
</script>
<noscript
>If you're seeing this message, that means
<strong>JavaScript has been disabled on your browser</strong>,
please <strong>enable JS</strong> to make this app work.
</noscript>
</head>
<body>
<script type="text/javascript">
window.CELLXGENE = {};
window.CELLXGENE.API = {
prefix: window.location.href + "api/",
version: "v0.2/"
};
</script>
<noscript>If you're seeing this message, that means <strong>JavaScript has been disabled on your browser</strong>,
please <strong>enable JS</strong> to make this app work.
</noscript>
<div id="root"></div>
{% for script in SCRIPTS %}
<script type="text/javascript" src="{{script | safe}}"></script>
{% endfor %}
</body>
<div id="root"></div>
{% for script in SCRIPTS %}
<script type="text/javascript" src="{{script | safe}}"></script>
{% endfor %}
</body>
</html>

View File

@@ -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 = '<!doctype html><html lang="en">'
@@ -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>/", "dataset_index", dataset_index, methods=["GET"])
self.app.add_url_rule(
"/d/<dataset>/static/<path:therest>", "static_redirect", static_redirect, methods=["GET"]
)
self.app.matrix_data_cache_manager = matrix_data_cache_manager
self.app.annotations = annotations

View File

@@ -1,11 +0,0 @@
# Configure URL rewriting from /<dataset>/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]