Skip to content
This repository was archived by the owner on Nov 10, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions treestatus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ def index():

@app.route('/help')
def help():
resp = make_response(render_template('help.html'))
if 'REMOTE_USER' in request.environ:
user = status.get_user(request.environ['REMOTE_USER'])
else:
user = None

resp = make_response(render_template('help.html', user=user))
resp.headers['Cache-Control'] = 'max-age=600'
return resp

Expand All @@ -357,7 +362,7 @@ def login():
if not u or not (u.is_admin or u.is_sheriff):
log.info("%s is not allowed", who)
status.delete_token(who)
resp = make_response(render_template('badlogin.html'), 403)
resp = make_response(render_template('badlogin.html', user=None), 403)
# Force the user to logout
if 'repoze.who.api' in request.environ:
repoze_api = request.environ['repoze.who.api']
Expand Down Expand Up @@ -397,8 +402,13 @@ def get_tree(tree):
if is_json():
return wrap_json_headers(t)

if 'REMOTE_USER' in request.environ:
user = status.get_user(request.environ['REMOTE_USER'])
else:
user = None

resp = make_response(render_template('tree.html', tree=t, logs=status.get_logs(tree),
loads=loads, token=get_token()))
loads=loads, token=get_token(), user=user))
resp.headers['Cache-Control'] = 'max-age=30'
resp.headers['Vary'] = 'Cookie'
if '?nc' in request.url:
Expand Down
29 changes: 4 additions & 25 deletions treestatus/templates/badlogin.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tree Status</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<div id="container">
<div id="main">
<span class="atRight">
<a class="loginout" href="/login">Login</a>
</span>
<h1>TreeStatus</h1>
{% extends "template.html" %}
{% block title %}Tree Status{% endblock %}
{% block pageContent %}
<h2 class="error">Sorry!</h2>
<p class="error">
You do not have permission to login to this system.
</p>
</div>
<div id="footer">
<span class="footerWrapper">
<a href="/">All trees</a>
<a href="/help">Help</a>
<a href="https://github.com/catlee/treestatus">Source</a>
<a href="/login">Login</a>
</span>
</div>
</div>
</body>
</html>
{% endblock %}
38 changes: 4 additions & 34 deletions treestatus/templates/help.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Treestatus Docs</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<div id="container">
<div id="main">
<span class="atRight">
{% if 'REMOTE_USER' in request.environ: -%}
{{request.environ['REMOTE_USER']}}
<a class="loginout" href="/logout">Logout</a>
{% else: -%}
<a class="loginout" href="/login">Login</a>
{% endif -%}
</span>
<h1>TreeStatus</h1>
{% extends "template.html" %}
{% block title %}TreeStatus Docs{% endblock %}
{% block pageContent %}
<h2 id="helpHeading">API documentation</h2>
<p>
Treename parameters should be urlencoded if they contain special characters
Expand All @@ -38,19 +23,4 @@ <h2 id="helpHeading">API documentation</h2>
</tbody>
</table>
</div>
</div>
<div id="footer">
<span class="footerWrapper">
<a href="/">All trees</a>
<a href="/help">Help</a>
<a href="https://github.com/catlee/treestatus">Source</a>
{% if 'REMOTE_USER' in request.environ: %}
<a href="/logout">Logout</a>
{% else: %}
<a href="/login">Login</a>
{% endif %}
</span>
</div>
</div>
</body>
</html>
{% endblock %}
54 changes: 12 additions & 42 deletions treestatus/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tree Status</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<div id="container">
<div id="main">
<span class="atRight">
{% if 'REMOTE_USER' in request.environ: -%}
{{request.environ['REMOTE_USER']}}
<a class="loginout" href="/logout">Logout</a>
{% else: -%}
<a class="loginout" href="/login">Login</a>
{% endif -%}
</span>
<h1>TreeStatus</h1>
{% extends "template.html" %}
{% block title %}Tree Status{% endblock %}
{% block pageContent %}
<div id="tableWrapper">
{% if 'REMOTE_USER' in request.environ: -%}
<form method="post" action="">
Expand Down Expand Up @@ -95,27 +80,12 @@ <h2>Previous states</h2>
{%- endfor %}
to {{stack.status.upper()}} {{stack.reason}}
<input type="submit" value="restore" />
</p>
</form>
{% endfor -%}
</div>
{% endif -%}
{% endif -%}
</div>
<div id="footer">
<span class="footerWrapper">
<a href="/">All trees</a>
<a href="/help">Help</a>
<a href="https://github.com/catlee/treestatus">Source</a>
{% if user and user.is_admin -%}
<a href="/users">Manage Users</a>
{% endif -%}
{% if 'REMOTE_USER' in request.environ: -%}
<a href="/logout">Logout</a>
{% else: -%}
<a href="/login">Login</a>
{% endif -%}
</span>
</div>
</body>
</html>
</p>
</form>
{% endfor -%}
</div>
{% endif -%}
{% else: %}
</div>
{% endif -%}
{% endblock %}
39 changes: 39 additions & 0 deletions treestatus/templates/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<div id="container">
<div id="main">
<span class="atRight">
{% if user: -%}
{{user.name}}
<a class="loginout" href="/logout">Logout</a>
{% else: -%}
<a class="loginout" href="/login">Login</a>
{% endif -%}
</span>
<h1>TreeStatus</h1>
{%- block pageContent -%}
{% endblock %}
</div>
<div id="footer">
<span class="footerWrapper">
<a href="/">All trees</a> |
<a href="/help">Help</a> |
<a href="https://github.com/catlee/treestatus">Source</a> |
{% if user and user.is_admin -%}
<a href="/users">Manage Users</a> |
{% endif -%}
{% if user: -%}
<a href="/logout">Logout</a>
{% else: -%}
<a href="/login">Login</a>
{% endif -%}
</span>
</div>
</div>
</body>
</html>
38 changes: 4 additions & 34 deletions treestatus/templates/tree.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{tree.tree}} - {{tree.status}}</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<div id="container">
<div id = "main">
<span class="atRight">
{% if 'REMOTE_USER' in request.environ: -%}
{{request.environ['REMOTE_USER']}}
<a class="loginout" href="/logout">Logout</a>
{% else: -%}
<a class="loginout" href="/login">Login</a>
{% endif -%}
</span>
<h1>TreeStatus</h1>
{% extends "template.html" %}
{% block title %}{{tree.tree}} - {{tree.status}}{% endblock %}
{% block pageContent %}
<h2>{{tree.tree}} is <span class="{{tree.status.lower()}}">{{tree.status.upper()}}</span></h2><br/>
{% if tree.reason: -%}
<h2>Reason: {{tree.reason}}</h2>
Expand Down Expand Up @@ -80,19 +65,4 @@ <h2 id="previous">History</h2>
</tbody>
</table>
</div>
</div>
<div id="footer">
<span class="footerWrapper">
<a href="/">All trees</a>
<a href="/help">Help</a>
<a href="https://github.com/catlee/treestatus">Source</a>
{% if 'REMOTE_USER' in request.environ: -%}
<a href="/logout">Logout</a>
{% else: -%}
<a href="/login">Login</a>
{% endif -%}
</span>
</div>
</div>
</body>
</html>
{% endblock %}
44 changes: 5 additions & 39 deletions treestatus/templates/users.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tree Status</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<div id="container">
<div id="main">
<span class="atRight">
{% if 'REMOTE_USER' in request.environ: -%}
{{request.environ['REMOTE_USER']}}
<a class="loginout" href="/logout">Logout</a>
{% else: -%}
<a class="loginout" href="/login">Login</a>
{% endif -%}
</span>
<h1>TreeStatus</h1>
{% extends "template.html" %}
{% block title %}Tree Status{% endblock %}
{% block pageContent %}
<h2>Manage Users</h2>
<div id="tableWrapper">
<form method="post" action="">
Expand Down Expand Up @@ -57,24 +42,5 @@ <h2>Manage Users</h2>
<span class="atRight"><input type="submit" value="Add" /></span>
</div>
</form>
</div>
</div>

<div id="footer">
<span class="footerWrapper">
<a href="/">All trees</a>
<a href="/help">Help</a>
<a href="https://github.com/catlee/treestatus">Source</a>
{% if user and user.is_admin -%}
<a href="/users">Manage Users</a>
{% endif -%}
{% if 'REMOTE_USER' in request.environ: -%}
<a href="/logout">Logout</a>
{% else: -%}
<a href="/login">Login</a>
{% endif -%}
</span>
</div>
</div>
</body>
</html>
</div>
{% endblock %}