{# HTML Macros #} {# META #} {#: The basic meta tag :#} {% macro meta_tag(name, value) %} {% endmacro %} {#: Custom meta tag :#} {% macro meta_custom(namespace, name, value) %} {% endmacro %} {#: opengraph property :#} {% macro meta_property(namespace, name, value) %} {% endmacro %} {#: opengraph tag :#} {%- macro meta_opengraph(name, value) -%} {% if value %} {% endif %} {%- endmacro %} {#: Custom meta tag :#} {%- macro meta_googleplus(name, value) -%} {% if value %} {% endif %} {%- endmacro -%} {#: Custom meta tag :#} {%- macro meta_twitter(name, value) -%} {% if value %} {% endif %} {%- endmacro -%} {#: SOCIAL_GRAPH() ---------------------------------------------------------- #} {%- macro opengraph(use_opengraph=True, use_googleplus=True, use_twitter=True) -%} {% set url = __.__META__["url"] or request.base_url %} {% set image = __.__META__["image"] %} {% if __.__META__["use_opengraph"] and use_opengraph %} {{ meta_opengraph("title", __.__META__["title"]) }} {{ meta_opengraph("description", __.__META__["description"]) }} {{ meta_opengraph("url", url) }} {{ meta_opengraph("site_name", __.__META__["site_name"]) }} {% set object_type = __.__META__["object_type"] %} {{- meta_opengraph("type", __.__META__["object_type"]) -}} {% if image %} {{ meta_opengraph("image", image) }} {% endif %} {% endif %} {% if __.__META__["use_googleplus"] and use_googleplus %} {{ meta_googleplus("description", __.__META__["description"]) }} {{ meta_googleplus("name", __.__META__["title"]) }} {{ meta_googleplus("url", url) }} {% if image %} {{ meta_googleplus("image", image) }} {% endif %} {% endif %} {% if __.__META__["use_twitter"] and use_twitter -%} {{ meta_twitter("title", __.__META__["title"]) }} {{ meta_twitter("description", __.__META__["description"]) }} {{ meta_twitter("url", url ) }} {% if image %} {{ meta_twitter("image", image) }} {{ meta_twitter("card", "summary_large_image") }} {% else %} {{ meta_twitter("card", "summary") }} {% endif %} {% endif %} {% for k, v in __.__META__.properties.items() %} {{ meta_custom("property", k, v) }} {% endfor %} {% endmacro %} {# Create the title, charset tag #} {% macro header(title="%title%", charset="utf-8") %} {{ title | replace("%title%", __.__META__.title) | safe }} {{ meta_tag("description", __.__META__.description) }} {% endmacro %} {#: Favicon :#} {% macro favicon(path) %} {% endmacro %} {% macro global_assets() %} {{ css_asset('global.css') }} {{ js_asset('jquery.js') }} {{ js_asset('global.js') }} {% endmacro %} {% macro bootstrap() %} {{ css_asset('bootstrap.css') }} {{ js_asset('bootstrap.js') }} {% endmacro %} {%- macro fontawesome() -%} {{ css_asset("vendor/font-awesome/font-awesome.min.css") }} {%- endmacro -%} {%- macro fontawesome_cdn(version="4.3.0") -%} {%- endmacro -%} {% macro bootswatch_theme(name) %} {% set file = 'Mambo/bootswatch/%s.css' % name %} {% set output = "gen/bootswatch_%s.css" % name %} {%- assets output=output, file %} {%- endassets %} {% endmacro %} {#: HEADER() ----------------------------------------------------------- #} {%- macro head(title="%s", favicon_="favicon.ico", charset="utf-8", add_social_graph=true, add_google_analytics=true, fontawesome_version="4.4.0") -%} {{ page_header() }} {{ favicon(favicon_) }} {{ global_assets() }} {% if add_social_graph == true %} {{ meta.social_graph() }} {% endif %} {% if add_google_analytics == true %} {{ google_analytics() }} {% endif %} {{ fontawesome(fontawesome_version) }} {%- endmacro -%} {#: CSS ------------------------------------------------------------- #} {%- macro css_asset(file) %} {% if "/" in file %} {% set file = static_file(file) %} {% endif %} {%- assets file %} {% endassets -%} {% endmacro -%} {#: JS--------------------------------------------------------------- #} {%- macro js_asset(file) %} {% if "/" in file %} {% set file = static_file(file) %} {% endif %} {%- assets file %} {% endassets -%} {% endmacro -%} {#:: static_file(url) ::#} {#:: Include static assets ::#} {%- macro static_file(url) -%} {%- if not url.startswith('http') and not url.startswith('//') -%} {%- set url = url_for('static', filename=url) -%} {%- endif -%} {{ url | safe }} {%- endmacro -%} {#: GOOGLE_ANALYTICS() ------------------------------------------------------ #} {% macro google_analytics(code=None) %} {% if not code %} {% set code = __.APPLICATION_GOOGLE_ANALYTICS_ID %} {% endif %} {% if code %} {% endif %} {% endmacro %} {##-------------------------------------------------------------------------------#} {# IN EXPERIMENT #} {% macro oauth_providers(text="Signin with #provider", size="lg", btn_block=true) %} {% endmacro %} {##-------------------------------------------------------------------------------#}