comparison 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
comparison
equal deleted inserted replaced
139:584587a000a2 140:3a56d5501ffa
21 # You should have received a copy of the GNU General Public License 21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software 22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 -#} 24 -#}
25 25
26 {% extends "layout.j2" %}
27
26 {% from "macros.j2" import modal, POST_button -%} 28 {% from "macros.j2" import modal, POST_button -%}
27 29
28 <!doctype html> 30 {% block navbar %}
31 {% if has_current %}
32 <li{% if active == 'document' %} class="active"{% endif %}><a href="{{ url_for('document.view') }}">Document</a></li>
33 {% endif %}
34 {% if products %}
35 <li class="dropdown{{ ' active' if active == 'product' }}">
36 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <span class="caret"></span></a>
37 <ul class="dropdown-menu" role="menu">
38 <li role="presentation">
39 <a role="menuitem" tabindex="-1" href="{{ url_for('producttree.view') }}">View Product Tree</a>
40 </li>
41 <li role="presentation" class="divider"></li>
42 {% for name, productid in products | sort %}
43 <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ name }}</a></li>
44 {% endfor %}
45 </ul>
46 </li>
47 {% endif %}
48 {% if vulnerabilities %}
49 <li class="dropdown{{ ' active' if active == 'vulnerability' }}">
50 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Vulnerabilities <span class="caret"></span></a>
51 <ul class="dropdown-menu" role="menu">
52 {% for name, ord in vulnerabilities %}
53 <li><a href="{{ url_for('vulnerability.view', ordinal=ord) }}">{{ name }}</a></li>
54 {% endfor %}
55 </ul>
56 </li>
57 {% endif %}
58 {% if has_current %}
59 <li>
60 {% if error %}
61 <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>&#x2717;</strong></span></p>
62 {% else %}
63 <p class="navbar-text">Document looks valid <span class="badge progress-bar-success"><strong>&#x2713;</strong></span></p>
64 {% endif %}
65 </li>
66 {% endif %}
67 {% endblock %}
29 68
30 <html lang="en"> 69 {% block navbar_right %}
31 <head> 70 {% if has_current %}
32 <meta charset="utf-8"> 71 <li class="dropdown{{ ' active' if active == 'render' }}">
33 <title>Farol - {% block title %}{% endblock %}</title> 72 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <span class="caret"></span></a>
34 <link rel="stylesheet" href="{{ url_for('static', filename='bootstrap.css') }}"> 73 <ul class="dropdown-menu" role="menu">
35 <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> 74 {% for format in ('cvrf', 'nasl', 'oval') %}<li><a href="{{ url_for('render', format_=format)}}">as {{ format | upper }}</a></li>{% endfor %}
36 </head> 75 </ul>
37 <body> 76 </li>
38 <script src="{{ url_for('static', filename='jquery-2.1.1.min.js') }}"></script> 77 {% endif %}
39 <script src="{{ url_for('static', filename='bootstrap.js') }}"></script> 78 {% if caching %}
40 <nav class="navbar navbar-inverse" role="navigation"> 79 <li class="dropdown">
41 <div class="container"> 80 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a>
42 {# Brand and toggle get grouped for better mobile display #} 81 <ul class="dropdown-menu" role="menu">
43 <div class="navbar-header"> 82 <li role="presentation"{{ ' class="disabled"' if not has_current }}>
44 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 83 <a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save {{ current_id }}</a>
45 <span class="sr-only">Toggle navigation</span> 84 </li>
46 <span class="icon-bar"></span> 85 <li role="presentation" class="divider"></li>
47 <span class="icon-bar"></span> 86 {% for element in cache | sort %}
48 <span class="icon-bar"></span> 87 <li role="presentation">
49 </button> 88 {% if has_current %}
50 <a class="navbar-brand" href="{{ url_for('welcome') }}" title="A Security Advisory Management Platform">Farol</a> 89 <a href="#{{element}}_modal" data-toggle="modal">Load {{ element }}</a>
51 </div> 90 {% else %}
91 {% call(selector) POST_button(url_for('cache.load', element=element), out=True) %}
92 <a role="menuitem" href="#" onclick="{{ selector }}.submit();return false;">Load {{ element }}</a>
93 {% endcall %}
94 {% endif %}
95 </li>
96 {% endfor %}
97 </ul>
98 </li>
99 {% endif %}
100 {% endblock %}
52 101
53 {# Collect the nav links, forms, and other content for toggling #} 102 {% block pre_content %}
54 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
55 <ul class="nav navbar-nav">
56 <li{% if active == 'new' %} class="active"{% endif %}><a href="{{ url_for('new') }}">New</a></li>
57 {% if has_current %}
58 <li{% if active == 'document' %} class="active"{% endif %}><a href="{{ url_for('document.view') }}">Document</a></li>
59 {% endif %}
60 {% if products %}
61 <li class="dropdown{{ ' active' if active == 'product' }}">
62 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <span class="caret"></span></a>
63 <ul class="dropdown-menu" role="menu">
64 <li role="presentation">
65 <a role="menuitem" tabindex="-1" href="{{ url_for('producttree.view') }}">View Product Tree</a>
66 </li>
67 <li role="presentation" class="divider"></li>
68 {% for name, productid in products | sort %}
69 <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ name }}</a></li>
70 {% endfor %}
71 </ul>
72 </li>
73 {% endif %}
74 {% if vulnerabilities %}
75 <li class="dropdown{{ ' active' if active == 'vulnerability' }}">
76 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Vulnerabilities <span class="caret"></span></a>
77 <ul class="dropdown-menu" role="menu">
78 {% for name, ord in vulnerabilities %}
79 <li><a href="{{ url_for('vulnerability.view', ordinal=ord) }}">{{ name }}</a></li>
80 {% endfor %}
81 </ul>
82 </li>
83 {% endif %}
84 </ul>
85 {% if has_current %}
86 {% if error %}
87 <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>&#x2717;</strong></span></p>
88 {% else %}
89 <p class="navbar-text">Document looks valid <span class="badge progress-bar-success"><strong>&#x2713;</strong></span></p>
90 {% endif %}
91 {% endif %}
92 <ul class="nav navbar-nav navbar-right">
93 {% if has_current %}
94 <li class="dropdown{{ ' active' if active == 'render' }}">
95 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <span class="caret"></span></a>
96 <ul class="dropdown-menu" role="menu">
97 {% for format in ('cvrf', 'nasl', 'oval') %}<li><a href="{{ url_for('render', format_=format)}}">as {{ format | upper }}</a></li>{% endfor %}
98 </ul>
99 </li>
100 {% endif %}
101 {% if caching %}
102 <li class="dropdown">
103 <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a>
104 <ul class="dropdown-menu" role="menu">
105 <li role="presentation"{{ ' class="disabled"' if not has_current }}>
106 <a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save {{ current_id }}</a>
107 </li>
108 <li role="presentation" class="divider"></li>
109 {% for element in cache | sort %}
110 <li role="presentation">
111 {% if has_current %}
112 <a href="#{{element}}_modal" data-toggle="modal">Load {{ element }}</a>
113 {% else %}
114 {% call(selector) POST_button(url_for('cache.load', element=element), out=True) %}
115 <a role="menuitem" href="#" onclick="{{ selector }}.submit();return false;">Load {{ element }}</a>
116 {% endcall %}
117 {% endif %}
118 </li>
119 {% endfor %}
120 </ul>
121 </li>
122 {% endif %}
123 </ul>
124 </div>{# /.navbar-collapse #}
125 </div>{# /.container-fluid #}
126 </nav>
127 {% if has_current %} 103 {% if has_current %}
128 {% for element in cache %} 104 {% for element in cache %}
129 {# Put the modals for the load action here #} 105 {# Put the modals for the load action here #}
130 {% call modal(element + '_modal', 'Load %s from cache' % element) %} 106 {% call modal(element + '_modal', 'Load %s from cache' % element) %}
131 <p>You asked to load <strong>{{ element }}</strong>, your changes to <strong>{{ current_id }}</strong> will be lost.</p> 107 <p>You asked to load <strong>{{ element }}</strong>, your changes to <strong>{{ current_id }}</strong> will be lost.</p>
135 <a href="{{ url_for('cache.save') }}" class="btn btn-success">Save {{ current_id }}</a> 111 <a href="{{ url_for('cache.save') }}" class="btn btn-success">Save {{ current_id }}</a>
136 {{ POST_button(url_for('cache.load', element=element), text="Load " + element, style="btn-danger") }} 112 {{ POST_button(url_for('cache.load', element=element), text="Load " + element, style="btn-danger") }}
137 {% endcall %} 113 {% endcall %}
138 {% endfor %} 114 {% endfor %}
139 {% endif %} 115 {% endif %}
140 <div class="main container"> 116 {% with messages = get_flashed_messages(with_categories=True) %}
141 {% with messages = get_flashed_messages(with_categories=True) %} 117 {% if messages %}
142 {% if messages %} 118 <div class="flashes">
143 <div class="flashes"> 119 {% for category, message in messages %}
144 {% for category, message in messages %} 120 {% if category == 'message' %}{% set category = "info" %}{% endif %}
145 {% if category == 'message' %}{% set category = "info" %}{% endif %} 121 <div class="alert alert-{{ category }}">{{ message }}</div>
146 <div class="alert alert-{{ category }}">{{ message }}</div> 122 {% endfor %}
147 {% endfor %}
148 </div>
149 {% endif %}
150 {% endwith %}
151 <div>
152 <script>$("#error-popover").popover();</script>
153 {% block content %}{% endblock %}
154 </div> 123 </div>
155 {% if config.DEBUG and not config.DEBUG_SURE %} 124 {% endif %}
125 {% endwith %}
126 {% endblock %}
127
128 {% block post_content %}
129 {% if config.DEBUG and not config.DEBUG_SURE %}
156 <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> 130 <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>
157 {% endif %} 131 {% endif %}
158 </div> 132 {% endblock %}
159 <footer class="footer container-fluid navbar-inverse">
160 <div class="text-center">
161 <span class="text-muted">Copyright &copy; 2014 Greenbone Networks GmbH</span>
162 |
163 <span><a href="{{ url_for('about') }}">About Farol</a></span>
164 </div>
165 <a href="http://greenbone.net/" id="greenbone" class="logo_img text-hide center-block">Greenbone Networks GmbH</a>
166 </footer>
167 </body>
168 </html>

http://farol.wald.intevation.org