Mercurial > farol > farol
diff farol/templates/base.j2 @ 140:3a56d5501ffa
Add HTTP error handling
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Mon, 27 Oct 2014 16:46:18 +0100 |
parents | 67c4b299736e |
children | 3500cb0c54d1 |
line wrap: on
line diff
--- a/farol/templates/base.j2 Mon Oct 27 15:08:29 2014 +0100 +++ b/farol/templates/base.j2 Mon Oct 27 16:46:18 2014 +0100 @@ -23,107 +23,83 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -#} +{% extends "layout.j2" %} + {% from "macros.j2" import modal, POST_button -%} -<!doctype html> +{% block navbar %} + {% if has_current %} + <li{% if active == 'document' %} class="active"{% endif %}><a href="{{ url_for('document.view') }}">Document</a></li> + {% endif %} + {% if products %} + <li class="dropdown{{ ' active' if active == 'product' }}"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <span class="caret"></span></a> + <ul class="dropdown-menu" role="menu"> + <li role="presentation"> + <a role="menuitem" tabindex="-1" href="{{ url_for('producttree.view') }}">View Product Tree</a> + </li> + <li role="presentation" class="divider"></li> + {% for name, productid in products | sort %} + <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ name }}</a></li> + {% endfor %} + </ul> + </li> + {% endif %} + {% if vulnerabilities %} + <li class="dropdown{{ ' active' if active == 'vulnerability' }}"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Vulnerabilities <span class="caret"></span></a> + <ul class="dropdown-menu" role="menu"> + {% for name, ord in vulnerabilities %} + <li><a href="{{ url_for('vulnerability.view', ordinal=ord) }}">{{ name }}</a></li> + {% endfor %} + </ul> + </li> + {% endif %} + {% if has_current %} + <li> + {% if error %} + <p class="navbar-text">Document is <a id="error-popover" href="#" tabindex="0" class="navbar-link" data-toggle="popover" data-trigger="focus" data-placement="bottom" title="First Error:" data-content="{{ error }}"><strong>invalid</strong></a> <span class="badge progress-bar-danger"><strong>✗</strong></span></p> + {% else %} + <p class="navbar-text">Document looks valid <span class="badge progress-bar-success"><strong>✓</strong></span></p> + {% endif %} + </li> + {% endif %} +{% endblock %} -<html lang="en"> -<head> - <meta charset="utf-8"> - <title>Farol - {% block title %}{% endblock %}</title> - <link rel="stylesheet" href="{{ url_for('static', filename='bootstrap.css') }}"> - <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> -</head> -<body> - <script src="{{ url_for('static', filename='jquery-2.1.1.min.js') }}"></script> - <script src="{{ url_for('static', filename='bootstrap.js') }}"></script> - <nav class="navbar navbar-inverse" role="navigation"> - <div class="container"> - {# Brand and toggle get grouped for better mobile display #} - <div class="navbar-header"> - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> - <span class="sr-only">Toggle navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <a class="navbar-brand" href="{{ url_for('welcome') }}" title="A Security Advisory Management Platform">Farol</a> - </div> - - {# Collect the nav links, forms, and other content for toggling #} - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <ul class="nav navbar-nav"> - <li{% if active == 'new' %} class="active"{% endif %}><a href="{{ url_for('new') }}">New</a></li> - {% if has_current %} - <li{% if active == 'document' %} class="active"{% endif %}><a href="{{ url_for('document.view') }}">Document</a></li> - {% endif %} - {% if products %} - <li class="dropdown{{ ' active' if active == 'product' }}"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li role="presentation"> - <a role="menuitem" tabindex="-1" href="{{ url_for('producttree.view') }}">View Product Tree</a> - </li> - <li role="presentation" class="divider"></li> - {% for name, productid in products | sort %} - <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ name }}</a></li> - {% endfor %} - </ul> +{% block navbar_right %} + {% if has_current %} + <li class="dropdown{{ ' active' if active == 'render' }}"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <span class="caret"></span></a> + <ul class="dropdown-menu" role="menu"> + {% for format in ('cvrf', 'nasl', 'oval') %}<li><a href="{{ url_for('render', format_=format)}}">as {{ format | upper }}</a></li>{% endfor %} + </ul> + </li> + {% endif %} + {% if caching %} + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a> + <ul class="dropdown-menu" role="menu"> + <li role="presentation"{{ ' class="disabled"' if not has_current }}> + <a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save {{ current_id }}</a> + </li> + <li role="presentation" class="divider"></li> + {% for element in cache | sort %} + <li role="presentation"> + {% if has_current %} + <a href="#{{element}}_modal" data-toggle="modal">Load {{ element }}</a> + {% else %} + {% call(selector) POST_button(url_for('cache.load', element=element), out=True) %} + <a role="menuitem" href="#" onclick="{{ selector }}.submit();return false;">Load {{ element }}</a> + {% endcall %} + {% endif %} </li> - {% endif %} - {% if vulnerabilities %} - <li class="dropdown{{ ' active' if active == 'vulnerability' }}"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown">Vulnerabilities <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - {% for name, ord in vulnerabilities %} - <li><a href="{{ url_for('vulnerability.view', ordinal=ord) }}">{{ name }}</a></li> - {% endfor %} - </ul> - </li> - {% endif %} - </ul> - {% if has_current %} - {% if error %} - <p class="navbar-text">Document is <a id="error-popover" href="#" tabindex="0" class="navbar-link" data-toggle="popover" data-trigger="focus" data-placement="bottom" title="First Error:" data-content="{{ error }}"><strong>invalid</strong></a> <span class="badge progress-bar-danger"><strong>✗</strong></span></p> - {% else %} - <p class="navbar-text">Document looks valid <span class="badge progress-bar-success"><strong>✓</strong></span></p> - {% endif %} - {% endif %} - <ul class="nav navbar-nav navbar-right"> - {% if has_current %} - <li class="dropdown{{ ' active' if active == 'render' }}"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - {% for format in ('cvrf', 'nasl', 'oval') %}<li><a href="{{ url_for('render', format_=format)}}">as {{ format | upper }}</a></li>{% endfor %} - </ul> - </li> - {% endif %} - {% if caching %} - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li role="presentation"{{ ' class="disabled"' if not has_current }}> - <a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save {{ current_id }}</a> - </li> - <li role="presentation" class="divider"></li> - {% for element in cache | sort %} - <li role="presentation"> - {% if has_current %} - <a href="#{{element}}_modal" data-toggle="modal">Load {{ element }}</a> - {% else %} - {% call(selector) POST_button(url_for('cache.load', element=element), out=True) %} - <a role="menuitem" href="#" onclick="{{ selector }}.submit();return false;">Load {{ element }}</a> - {% endcall %} - {% endif %} - </li> - {% endfor %} - </ul> - </li> - {% endif %} - </ul> - </div>{# /.navbar-collapse #} - </div>{# /.container-fluid #} - </nav> + {% endfor %} + </ul> + </li> + {% endif %} +{% endblock %} + +{% block pre_content %} {% if has_current %} {% for element in cache %} {# Put the modals for the load action here #} @@ -137,32 +113,20 @@ {% endcall %} {% endfor %} {% endif %} - <div class="main container"> - {% with messages = get_flashed_messages(with_categories=True) %} - {% if messages %} - <div class="flashes"> - {% for category, message in messages %} - {% if category == 'message' %}{% set category = "info" %}{% endif %} - <div class="alert alert-{{ category }}">{{ message }}</div> - {% endfor %} - </div> - {% endif %} - {% endwith %} - <div> - <script>$("#error-popover").popover();</script> - {% block content %}{% endblock %} + {% with messages = get_flashed_messages(with_categories=True) %} + {% if messages %} + <div class="flashes"> + {% for category, message in messages %} + {% if category == 'message' %}{% set category = "info" %}{% endif %} + <div class="alert alert-{{ category }}">{{ message }}</div> + {% endfor %} </div> - {% if config.DEBUG and not config.DEBUG_SURE %} - <div class="alert alert-danger"><strong>DEBUG:</strong> This application is running in debug mode. See the <a href="{{ url_for('about') }}#debug">about page</a> for more Details</div> {% endif %} - </div> - <footer class="footer container-fluid navbar-inverse"> - <div class="text-center"> - <span class="text-muted">Copyright © 2014 Greenbone Networks GmbH</span> - | - <span><a href="{{ url_for('about') }}">About Farol</a></span> - </div> - <a href="http://greenbone.net/" id="greenbone" class="logo_img text-hide center-block">Greenbone Networks GmbH</a> - </footer> -</body> -</html> + {% endwith %} +{% endblock %} + +{% block post_content %} + {% if config.DEBUG and not config.DEBUG_SURE %} + <div class="alert alert-danger"><strong>DEBUG:</strong> This application is running in debug mode. See the <a href="{{ url_for('about') }}#debug">about page</a> for more Details</div> + {% endif %} +{% endblock %}