diff --git a/invenio/base/templates/page.html b/invenio/base/templates/_formhelpers.html similarity index 95% copy from invenio/base/templates/page.html copy to invenio/base/templates/_formhelpers.html index c412d74eb..9a4d5a3ad 100644 --- a/invenio/base/templates/page.html +++ b/invenio/base/templates/_formhelpers.html @@ -1,20 +1,19 @@ {# ## This file is part of Invenio. ## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} - -{% extends "page_base.html" %} +{%- extends "_formhelpers_base.html" -%} \ No newline at end of file diff --git a/invenio/base/templates/_formhelpers_base.html b/invenio/base/templates/_formhelpers_base.html index ff1437c1e..9a7572696 100644 --- a/invenio/base/templates/_formhelpers_base.html +++ b/invenio/base/templates/_formhelpers_base.html @@ -1,141 +1,143 @@ {# ## This file is part of Invenio. ## Copyright (C) 2012 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} {# ## See http://flask.pocoo.org/docs/patterns/wtforms/ #} -{% macro render_field(field, show_error_list=True) %} - {% set label_size = kwargs.get('label_size') %} - {% set field_size = kwargs.get('field_size') %} +{% macro render_field(field, show_error_list=True, show_description=False) %}{% set fieldkwargs = kwargs %}{% block render_field scoped %} + {% set label_size = fieldkwargs.get('label_size') %} + {% set field_size = fieldkwargs.get('field_size') %} {%- if field.name == "csrf_token" or field.type == 'HiddenField' -%} - {{ field(**kwargs)|safe }} + {{ field(**fieldkwargs)|safe }} {%- else -%} - <div class="form-group {% if show_error_list and field.errors %} error{% endif %}"> + <div class="form-group {% if show_error_list and field.errors %} has-error{% endif %}"> {% set label_classes = "control-label" %} {% if label_size %} {% set label_classes = label_classes + ' col-md-' + label_size|string %} {% endif %} {{ field.label(class_=label_classes) }} - {% set classes = kwargs.get('class_', '') + ' form-control' %} - {% do kwargs.update({'class_': classes }) %} + {% set classes = fieldkwargs.get('class_', '') + ' form-control' %} + {% do fieldkwargs.update({'class_': classes }) %} {% if field_size %} <div class="col-md-{{field_size|string}}"> {% endif %} - {{ field(**kwargs)|safe }} + {{ field(**fieldkwargs)|safe }} {% if show_error_list and field.errors %} {% for error in field.errors %} - <span class="help-inline">{{ error }}</span> + <span class="help-block">{{ error }}</span> {% endfor %} {% endif %} + {% if show_description and field.description %} + <div class="help-block"><small>{{ field.description }}</small></div> + {% endif %} {% if field_size %} </div> {% endif %} </div> {%- endif -%} -{% endmacro %} +{% endblock %}{% endmacro %} {# ## See https://github.com/sublee/flask-autoindex/blob/master/flaskext/autoindex/templates/__autoindex__/macros.html #} -{% macro th(key, label, args='', colspan=1) %} +{% macro th(key, label, args='', colspan=1) %}{% block th scoped %} <th class="{{ key }}" colspan="{{ colspan }}"> {% set sort_by = request.args.get('sort_by') %} {% set order = request.args.get('order', 'asc') %} {%- if sort_by == key and order == 'asc' -%} <a href="?sort_by={{ key }}&order=desc{{ args }}">{{ label }}</a> {%- else -%} <a href="?sort_by={{ key }}{{ args }}">{{ label }}</a> {%- endif -%} {%- if sort_by == key -%} {%- if order == 'asc' -%} <span> <small>v</small></span> {%- elif order == 'desc' -%} <span> ^</span> {%- endif -%} {%- endif -%} </th> -{% endmacro %} +{% endblock %}{% endmacro %} {# ## Field input wrapper. #} -{% macro _filter_element(field) %} +{% macro _filter_element(field) %}{% block _filter_element scoped %} <div class="input-group filter_element"> {{ field }}<span class="input-group-addon remove-field" onclick="$(this).parent().remove()"> <i class="glyphicon glyphicon-minus"></i> </span> </div> -{% endmacro %} +{% endblock %}{% endmacro %} {# ## Renders multiple input fields and clickable (jQuery) ## elements for dynamic field manipulation. #} -{% macro filter_field(field) %} +{% macro filter_field(field) %}{% block filter_field scoped %} <div class="form-group"> {{ field.label(class="control-label") }} <div class="controls"> <div class="col-md-6 paste"> {% if field.raw_data %} {% for i in range(field.raw_data|count) %} {{ _filter_element(field) }} {% endfor %} {% else %} {{ _filter_element(field) }} {% endif %} </div> <span class="pull-right btn btn-primary add-field" onclick="$('#field_copy_{{ field.id }}').children().clone().appendTo($(this).siblings('.paste'));"> <i class="glyphicon glyphicon-plus"></i> </span> </div> </div> -{% endmacro %} +{% endblock %}{% endmacro %} -{% macro filter_copy_element(field) %} +{% macro filter_copy_element(field) %}{% block filter_copy_element scoped %} <div id="field_copy_{{ field.id }}" class="copy" style="display:none;"> {{ _filter_element(field) }} </div> -{% endmacro %} +{% endblock %}{% endmacro %} -{% macro render_filter_form(form) %} +{% macro render_filter_form(form) %}{% block render_filter_form scoped %} <form {{ kwargs|xmlattr }}> {{ form.csrf_token }} {{ form.sort_by }} {{ form.order }} <fieldset> <legend>{{ _("Filter") }}</legend> {% for field in form %} {% if not field.name in ['csrf_token', 'sort_by', 'order'] %} {{ filter_field(field) }} {% endif %} {% endfor %} <hr/> <div class="pull-right"> <input type="submit" class="btn btn-primary" value="{{ _("Filter") }}" /> <input type="reset" class="btn" value="{{ _("Reset") }}" /> </div> </fieldset> </form> {% for field in form %} {% if not field.name in ['csrf', 'sort_by', 'order'] %} {{ filter_copy_element(field) }} {% endif %} {% endfor %} -{% endmacro %} - +{% endblock %}{% endmacro %} diff --git a/invenio/base/templates/_macros.html b/invenio/base/templates/_macros.html index 0a5e7d401..91d77d43a 100644 --- a/invenio/base/templates/_macros.html +++ b/invenio/base/templates/_macros.html @@ -1,45 +1,46 @@ {# ## This file is part of Invenio. ## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} {%- macro flashed_messages() -%} {% block messages %} - {% for category, msg in get_flashed_messages(with_categories=True, category_filter=['', 'info', 'error', 'warning', 'success']) %} + {% for category, msg in get_flashed_messages(with_categories=True, category_filter=['', 'info', 'danger', 'error', 'warning', 'success']) %} + {% set category = 'danger' if category == 'error' else category %} <div class="alert alert-{{ category }}"> <a class="close" data-dismiss="alert" href="#">×</a> {{ msg|safe }} </div> {% endfor %} {% endblock messages %} {% endmacro %} {%- macro js_bundle() -%} {%- for bundle in get_js_bundle(iterate=True) -%} {%- assets bundle -%} <script type="text/javascript" src="{{ ASSET_URL }}"></script> {%- endassets -%} {%- endfor -%} {%- endmacro -%} {%- macro css_bundle() -%} {%- for bundle in get_css_bundle(iterate=True) -%} {%- assets bundle -%} <link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}"></link> {%- endassets -%} {%- endfor -%} {%- endmacro -%} \ No newline at end of file diff --git a/invenio/base/templates/breadcrumbs.html b/invenio/base/templates/breadcrumbs.html index bf8069b3d..5f740f0e1 100644 --- a/invenio/base/templates/breadcrumbs.html +++ b/invenio/base/templates/breadcrumbs.html @@ -1,38 +1,38 @@ {# ## This file is part of Invenio. ## Copyright (C) 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} {% if breadcrumbs|length > 1 %} <div class="container"> - <ul class="breadcrumb"> + <ul class="breadcrumb" itemprop="breadcrumb"> {% for breadcrumb in breadcrumbs %} {% if loop.last %} <li class="active"> {{ breadcrumb.text|safe }} </li> {% else %} <li> <a href="{{ breadcrumb.url }}" class="navtrail"> {{ breadcrumb.text|safe }} </a> </li> {% endif %} {% endfor %} </ul> </div> {% endif %} diff --git a/invenio/base/templates/page.html b/invenio/base/templates/page.html index c412d74eb..ba3fb83b3 100644 --- a/invenio/base/templates/page.html +++ b/invenio/base/templates/page.html @@ -1,20 +1,19 @@ {# ## This file is part of Invenio. ## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} - -{% extends "page_base.html" %} +{%- extends "page_base.html" -%} \ No newline at end of file diff --git a/invenio/base/templates/page_base.html b/invenio/base/templates/page_base.html index 1ef95455b..29ad6c888 100644 --- a/invenio/base/templates/page_base.html +++ b/invenio/base/templates/page_base.html @@ -1,195 +1,158 @@ {# ## This file is part of Invenio. ## Copyright (C) 2012, 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% from "_macros.html" import flashed_messages, js_bundle, css_bundle with context %} +{%- from "_macros.html" import flashed_messages, js_bundle, css_bundle with context -%} {# Global CSS #} -{% block global_css %} +{%- block global_css %} {%- css 'css/bootstrap.css', '00-invenio' -%} {%- css 'css/typeahead.js-bootstrap.css', '00-invenio' -%} {%- css 'css/token-input.css', '00-invenio' -%} {%- css 'css/token-input-facebook.css', '00-invenio' -%} {%- css url_for('static', filename='css/base.css'), '00-invenio' -%} {%- css url_for('webtag.static', filename='css/tags/popover.css'), '00-invenio' -%} {%- if config.CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' %} {%- css 'css/'+config.CFG_WEBSTYLE_TEMPLATE_SKIN, '00-invenio' -%} {%- endif %} -{% endblock global_css %} - +{%- endblock global_css -%} {# Global Javascript files #} -{% block global_javascript %} +{%- block global_javascript -%} {%- js 'js/jquery.min.js', '00-invenio' -%} {%- js 'js/bootstrap.js', '00-invenio' -%} {%- js 'js/jquery.tokeninput.js', '00-invenio' -%} {%- js 'js/hogan.js', '00-invenio' -%} {%- js 'js/jquery.jeditable.mini.js', '00-invenio' -%} {%- js 'js/invenio.js', '00-invenio' -%} {%- js 'js/translate.js', '00-invenio' -%} {%- js 'js/typeahead.js', '00-invenio' -%} -{% endblock global_javascript %} - +{%- endblock global_javascript %} +{%- block page -%} {%- if not no_pageheader -%} +{%- block page_top -%} <!DOCTYPE html> -<html lang="{{ ln|safe }}" {% if is_language_rtl(g.ln) %}dir="rtl"{% endif %}> +<html{% if g.ln %} lang="{{ g.ln|safe }}"{% if is_language_rtl(g.ln) %} dir="rtl"{% endif %}{% endif %}> <head> + {%- block head %} + {%- block head_meta %} <meta charset="utf-8"> <title>{{ title+' - ' if title }}{{ config.CFG_SITE_NAME_INTL[g.ln] }}</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <meta name="description" content=""> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="{{ g.ln|safe }}" /> - <meta name="description" content="{{ description }}" /> - <meta name="keywords" content="{{ keywords }}" /> - <meta name="author" content=""> + {%- if description %}<meta name="description" content="{{ description }}" />{% endif %} + {%- if keywords %}<meta name="keywords" content="{{ keywords }}" />{% endif %} + {%- if config.get('CFG_GOOGLE_SITE_VERIFICATION', None) -%} + {%- for google_id in config.CFG_GOOGLE_SITE_VERIFICATION %} + <meta name="google-site-verification" content="{{google_id}}" /> + {%- endfor -%} + {%- endif -%} + {%- endblock head_meta -%} + + {%- block head_links %} <link rev="made" href="mailto:{{ config.CFG_SITE_SUPPORT_EMAIL }}" /> <link rel="canonical" href="{{ canonical_url }}" /> - {% for alt_ln, alternate_url in alternate_urls.iteritems() %} + {%- block head_links_langs %}{%- for alt_ln, alternate_url in alternate_urls.iteritems() %} <link rel="alternate" hreflang="{{ alt_ln }}" href="{{ alternate_url }}" /> - {% endfor %} + {%- endfor %}{%- endblock %} <link rel="alternate" type="application/rss+xml" title="{{ config.CFG_SITE_NAME }} RSS" href="{{ url_for('rss') }}" /> <link rel="search" type="application/opensearchdescription+xml" href="{{ url_for('opensearchdescription') }}" title="{{ config.CFG_SITE_NAME }}" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="{{ url_for('unapi') }}" /> - {{ linkbackTrackbackLink }} + {%- if linkbackTrackbackLink %}{{ linkbackTrackbackLink }}{%- endif %} <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> - - <!-- Le fav and touch icons --> <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> - {% for size in [144, 114, 72, 57] %} - {% set icon_name = 'apple-touch-icon-%d-precomposed.png'|format(size) %} + {%- block head_apple_icons -%} + {%- for size in [144, 114, 72, 57] -%} + {%- set icon_name = 'apple-touch-icon-%d-precomposed.png'|format(size) %} <link rel="apple-touch-icon-precomposed" sizes="{{ size }}x{{ size }}" href="{{ url_for('static', filename=icon_name) }}"> - {% endfor %} + {%- endfor -%} + {%- endblock head_apple_icons -%} + {%- endblock head_links %} - {% block header %} - {{ metaheaderadd|safe }} - {% block metaheader %} - {% endblock metaheader %} - {% endblock header %} + {%- block header %}{{ metaheaderadd|safe }}{%- block metaheader %}{%- endblock metaheader -%}{%- endblock header -%} {{ css_bundle() }} - {% block _top_assets %}{% endblock _top_assets %} - {% block css %}{% endblock css %} - <style> - - legend [class*="icon-"] { vertical-align: baseline; } - a.label, a.label:hover, .label a, .label a:hover { color: white;} - .htmlbrief .media-heading { font-weight: 200; } - .icon.muted { opacity: 0.6; } - - /* - ----------------------- Stick footer ----------------------- */ - html, - body { - height: 100%; - } - - {% set footer_height = '150px' -%} - /* Wrapper for page content to push down footer */ - #wrap { - min-height: 100%; - height: auto !important; - height: 100%; - /* Negative indent footer by it's height */ - margin: 0 auto -{{ footer_height }}; - } - - /* Set the fixed height of the footer here */ - #push, - footer { - min-height: {{ footer_height }}; - } - - #push { - margin-top: 60px; - } - - footer a, footer a:hover { - color: #666; - } - footer, footer p { - font-size: 11px; - color: #333; - } - - /* Lastly, apply responsive CSS fixes as necessary */ - @media (max-width: 767px) { - footer { - margin-left: -20px; - margin-right: -20px; - padding-left: 20px; - padding-right: 20px; - } - } - - /* --------------- */ - </style> + {%- block _top_assets %}{% endblock _top_assets %} + {%- block css %}{% endblock css %} + {%- endblock head %} </head> -<body class="{{ body_css_classes|join(' ') if body_css_classes }}" - lang="{{ g.ln.split('_', 1)[0]|safe }}" {{ rtl_direction|safe }}> +<body{% if body_css_classes %} class="{{ body_css_classes|join(' ') }}"{% endif %}{% if g.ln %} lang="{{ g.ln.split('_', 1)[0]|safe }}"{% if rtl_direction %} {{ rtl_direction|safe }}{% endif %}{% endif %} itemscope itemtype="http://schema.org/WebPage"> +{%- block body_start %}{% endblock body_start %} +{%- block page_header -%} <div id="wrap"> <header> <!-- replaced page header --> {% block headerbox %} {% include 'header.html' %} {% endblock headerbox %} <!-- end replaced page header --> {% block breadcrumb %} {%- include 'breadcrumbs.html' -%} {% endblock breadcrumb %} {% block pageheaderadd %}{{ pageheaderadd|safe }}{% endblock pageheaderadd %} </header> +{%- endblock page_header -%} +{%- endblock page_top -%} {%- endif -%} + {%- if not no_pagebody -%} {%- block page_body -%} <div class="container"> {% block title %} {% if title %} <div class="page-header"> <h1>{{ title }}</h1> </div> {% endif %} {% endblock title %} {{ flashed_messages() }} {% block body %} {{ body }} {% endblock body %} </div> {%- endblock page_body -%} {%- endif -%} + {%- if not no_pagefooter -%} +{%- block page_bottom -%} +{%- block page_footer %} <div id="push"></div> </div>{# end wrap #} <footer> <div class="container"> {% block pagefooteradd %}{{ pagefooteradd|safe }}{% endblock pagefooteradd %} </div> <!-- replaced page footer --> {%- include 'footer.html' -%} </footer> -{% block _bottom_assets %} +{%- endblock page_footer %} +{%- block _bottom_assets %} {{ js_bundle() }} -{% endblock _bottom_assets %} -{% block javascript %}{% endblock javascript %} +{%- endblock _bottom_assets %} +{%- block javascript %}{% endblock javascript %} +{%- block body_end %}{% endblock body_end %} </body> </html> +{%- endblock page_bottom -%} {%- endif -%} +{%- endblock page -%}