Commit 49310fcf authored by Romain Loth's avatar Romain Loth

nicer topbar navigation + debug redirects with next

parent e045ac6a
......@@ -61,6 +61,9 @@ app = Flask("services",
static_folder=path.join(config['HOME'],"static"),
template_folder=path.join(config['HOME'],"templates"))
if not app.config['SERVER_NAME']:
app.config['SERVER_NAME'] = "localhost"
app.config['DEBUG'] = (config['LOG_LEVEL'] == "DEBUG")
app.config['SECRET_KEY'] = 'TODO fill secret key for sessions for login'
......@@ -153,7 +156,7 @@ def rootstub():
"""
pass
# /services/index/
# /services/demo/
@app.route(config['PREFIX']+'/demo/')
def demo():
"""
......@@ -165,7 +168,6 @@ def demo():
# current_user=current_user
)
# /services/
@app.route(config['PREFIX']+'/')
def services():
......@@ -174,7 +176,17 @@ def services():
# /services/test
@app.route(config['PREFIX'] + '/test', methods=['GET'])
def test_stuff():
return render_template("message.html", message=url_for('rootstub', _external=True))
return render_template("message.html",
message = "<br/>".join([
"dir(req)" + str(dir(request)),
"requrl:" + request.url,
"req.host:" + request.host,
"req.url_root:" + request.url_root,
"req.base_url:" + request.base_url,
"req.full_path:" + request.full_path,
"req.access_route:" + str(request.access_route)
])
)
# /services/api/aggs
@app.route(config['PREFIX'] + config['API_ROUTE'] + '/aggs')
......@@ -268,6 +280,8 @@ def login():
next_url = request.args.get('next', None)
if next_url:
print("next_url", next_url)
print("app.config.servername", app.config['SERVER_NAME'])
safe_flag = is_safe_url(next_url, request.host_url)
if safe_flag:
# normal next_url
......@@ -275,7 +289,7 @@ def login():
else:
# server name is different than ours
# in next_url so we won't go there
return(redirect(url_for('rootstub', _external=True)))
return(redirect('/'))
else:
# no specified next_url => profile
return redirect(url_for('profile', _external=True))
......@@ -306,7 +320,7 @@ def login():
@app.route(config['PREFIX'] + config['USR_ROUTE'] + '/logout/')
def logout():
logout_user()
return redirect(url_for('rootstub', _external=True))
return redirect(url_for('demo', _external=True))
# /services/user/profile/
......
......@@ -73,7 +73,14 @@ input.readonly {
color: #554 ;
}
#mainpagelink:hover {
.navlink {
font-size: 1.2em;
font-weight: bold;
margin: .2em 0 0 .4em;
}
.navlink:hover {
background-color: transparent !important;
}
......
......@@ -45,15 +45,43 @@
<body>
<div class="topbar" style="opacity: 0.93;">
<div class="topbar" style="opacity: 0.9;">
<div class="topbar-inner">
<div class="container-fluid">
<a class="brand" href="http://www.iscpif.fr">
<span class="glyphicon glyphicon-home white"></i></a>
<ul class="white nav navbar-nav">
<ul class="white nav navbar-nav navbar-left">
<li>
<a id="mainpagelink" href="/"> <strong>Complex systems community explorer</strong></a>
<a class="brand" href="https://iscpif.fr/">
<img height="25px" src="{{ url_for('static', filename='img/logo_m_bleu-header.png') }}"</a>
</li>
<li>
<a class="brand" href="/">
<span class="glyphicon glyphicon-home white"></span>&nbsp;&nbsp;
Community Explorer
</a>
</li>
</ul>
<ul class="white nav navbar-nav navbar-right">
{% if current_user and current_user.info %}
<li>
<a class="navlink" href="/services/user/profile"> Your Profile </a>
</li>
<li>
<a class="navlink" href='/explorerjs.html?type="uid"&nodeidparam="{{ current_user.uid }}"'> Your Map </a>
</li>
<li>
<a class="navlink" href='/print_scholar_directory.php?query={{ current_user.uid }}'> Your Neighboor Stats </a>
</li>
<li>
<a class="navlink" href='/services/user/logout/'> Logout </a>
</li>
{% else %}
<li>
<a class="navlink" href="/services/user/register"> Register </a>
</li>
<li>
<a class="navlink" href="/services/user/login"> Login </a>
</li>
{% endif %}
</ul>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment