diff --git a/treestatus/app.py b/treestatus/app.py index 3df5db4..11673ff 100644 --- a/treestatus/app.py +++ b/treestatus/app.py @@ -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 @@ -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'] @@ -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: diff --git a/treestatus/templates/badlogin.html b/treestatus/templates/badlogin.html index 6e9bd47..9223c12 100644 --- a/treestatus/templates/badlogin.html +++ b/treestatus/templates/badlogin.html @@ -1,29 +1,8 @@ - - - - Tree Status - - - -
-
- - Login - -

TreeStatus

+{% extends "template.html" %} +{% block title %}Tree Status{% endblock %} +{% block pageContent %}

Sorry!

You do not have permission to login to this system.

-
- -
- - +{% endblock %} diff --git a/treestatus/templates/help.html b/treestatus/templates/help.html index e177825..918ee17 100644 --- a/treestatus/templates/help.html +++ b/treestatus/templates/help.html @@ -1,21 +1,6 @@ - - - - Treestatus Docs - - - -
-
- - {% if 'REMOTE_USER' in request.environ: -%} - {{request.environ['REMOTE_USER']}} - Logout - {% else: -%} - Login - {% endif -%} - -

TreeStatus

+{% extends "template.html" %} +{% block title %}TreeStatus Docs{% endblock %} +{% block pageContent %}

API documentation

Treename parameters should be urlencoded if they contain special characters @@ -38,19 +23,4 @@

API documentation

-
- - - - +{% endblock %} diff --git a/treestatus/templates/index.html b/treestatus/templates/index.html index 28f5b45..8cf66a7 100644 --- a/treestatus/templates/index.html +++ b/treestatus/templates/index.html @@ -1,21 +1,6 @@ - - - - Tree Status - - - -
-
- - {% if 'REMOTE_USER' in request.environ: -%} - {{request.environ['REMOTE_USER']}} - Logout - {% else: -%} - Login - {% endif -%} - -

TreeStatus

+{% extends "template.html" %} +{% block title %}Tree Status{% endblock %} +{% block pageContent %}
{% if 'REMOTE_USER' in request.environ: -%}
@@ -95,27 +80,12 @@

Previous states

{%- endfor %} to {{stack.status.upper()}} {{stack.reason}} -

-
- {% endfor -%} -
- {% endif -%} - {% endif -%} -
- - - +

+ + {% endfor -%} +
+ {% endif -%} + {% else: %} + + {% endif -%} +{% endblock %} diff --git a/treestatus/templates/template.html b/treestatus/templates/template.html new file mode 100644 index 0000000..38f68de --- /dev/null +++ b/treestatus/templates/template.html @@ -0,0 +1,39 @@ + + + + {% block title %}{% endblock %} + + + +
+
+ + {% if user: -%} + {{user.name}} + Logout + {% else: -%} + Login + {% endif -%} + +

TreeStatus

+ {%- block pageContent -%} + {% endblock %} +
+ +
+ + diff --git a/treestatus/templates/tree.html b/treestatus/templates/tree.html index 1910ae6..4734f72 100644 --- a/treestatus/templates/tree.html +++ b/treestatus/templates/tree.html @@ -1,21 +1,6 @@ - - - - {{tree.tree}} - {{tree.status}} - - - -
-
- - {% if 'REMOTE_USER' in request.environ: -%} - {{request.environ['REMOTE_USER']}} - Logout - {% else: -%} - Login - {% endif -%} - -

TreeStatus

+{% extends "template.html" %} +{% block title %}{{tree.tree}} - {{tree.status}}{% endblock %} +{% block pageContent %}

{{tree.tree}} is {{tree.status.upper()}}


{% if tree.reason: -%}

Reason: {{tree.reason}}

@@ -80,19 +65,4 @@

History

-
- - - - +{% endblock %} diff --git a/treestatus/templates/users.html b/treestatus/templates/users.html index e3a15b8..031c0da 100644 --- a/treestatus/templates/users.html +++ b/treestatus/templates/users.html @@ -1,21 +1,6 @@ - - - - Tree Status - - - -
-
- - {% if 'REMOTE_USER' in request.environ: -%} - {{request.environ['REMOTE_USER']}} - Logout - {% else: -%} - Login - {% endif -%} - -

TreeStatus

+{% extends "template.html" %} +{% block title %}Tree Status{% endblock %} +{% block pageContent %}

Manage Users

@@ -57,24 +42,5 @@

Manage Users

-
-
- - - - - + +{% endblock %}