flask-base/templates/base.html
2018-03-31 18:26:40 +02:00

124 lines
4.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{% block head_meta %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
{% endblock %}
<title>{{ config['PROJECT_NAME'] }}{% if page_title %} - {{ page_title }}{% endif %}</title>
{% block head_css %}
<link rel="stylesheet" href="{{ static('css/bootstrap.css') }}" media="screen">
<link rel="stylesheet" href="{{ static('css/base.css') }}" media="screen">
{% endblock -%}
{%- block head %}{% endblock -%}
{%- block head_tail -%}{%- endblock -%}
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a href="/" class="navbar-brand"><i class="glyphicon glyphicon-stats"></i>&nbsp;{{ config['PROJECT_NAME'] }}
{%- if config['DEBUG'] or config.get('BRAND_NOTE') %} <small>{{ config.get('BRAND_NOTE', 'development') }}</small>{% endif -%}
</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="navbar-main">
{% macro navbar_link(href, title=None) %}
<li{% if href == request.endpoint and request.view_args == kwargs %} class="active"{% endif %}>
<a href="{{ url_for(href, **kwargs) }}">{% if not title %}{{ caller() }}{% else %}{{ title }}{% endif %}</a>
</li>
{% endmacro %}
{% block main_menu %}
{# Here add your main menu items, eg: #}
{# navbar_link('friends.index', 'Friends') #}
{% endblock %}
<ul class="nav navbar-nav navbar-right">
{{ navbar_link('flatpages.show', 'FAQ', slug='faq') }}
{% if current_user.is_authenticated() %}
{% if current_user.is_superuser or current_user.roles %}
{{ navbar_link('admin.index', 'Admin') }}
{% endif %}
<p class="navbar-text">{{ current_user }}</p>
{{ navbar_link('security.logout', 'Logout') }}
{% else %}
{{ navbar_link('security.register', 'Sign up') }}
{{ navbar_link('security.login', 'Login') }}
{% endif %}
</ul>
</div>
</div>
</div>
<div class="container">
{% block messages %}
{% with messages = get_flashed_messages(with_categories=True) +
config.get('GLOBAL_FLASHED_MESSAGES', []) %}
{% if messages %}
{% for category, message in messages %}
{% set category = 'info' if category == 'message' else category %}
<div class="alert alert-{{ category }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% endblock %}
{% block page_title %}
{% if page_title %}
<h1 class="page-header">{{ page_title }}
{% block title_actions %}
{% endblock %}
</h1>
{% endif %}
{% endblock %}
{% block content %}{% endblock %}
</div>
</div>
<footer class="container text-right">
{{ config['PROJECT_NAME'] }}
</footer>
{% block tail_js %}
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="{{ static('js/bootstrap.min.js') }}"></script>
<script src="{{ static('js/scripts.js') }}"></script>
{% if config.get('SOCIAL_FACEBOOK') %}
<!-- Facebook SDK START -->
<script>
window.fbAsyncInit = function() {
FB.init({
appId : {{ config['SOCIAL_FACEBOOK']['consumer_key'] }},
cookie : true,
xfbml : true,
version : 'v2.3',
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<!-- Facebook SDK END -->
{% endif %}
{% endblock -%}
{%- block tail %}
{% endblock %}
</body>
</html>