""" Portfolio's macro """ {% import "Portfolio/macros/meta.html" as meta with context %} """ """ {% macro oauth_login_buttons(buttons, size="md", text="Signin with #provider") %} {% for button in buttons %} {% set name = button %} {% if button == "google" %} {% set button = "google-plus" %} {% endif %} {% set text = text.replace("#provider", name) %} {{ oauth_login_button(button, text, size) }} {% endfor %} {% endmacro %} {#:: oauth_login_button Create a social login button ::#} {% macro oauth_login_button(button, text, size="") %} {{ text | title }} {% 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 -%} {#:: css(file) ::#} {#:: include css files ::#} {%- macro css(file) -%} {%- endmacro -%} {#:: js(file) ::#} {#:: include js file ::#} {%- macro js(file) -%} {%- endmacro -%} {#:: img(file, attributes) ::#} {#:: Insert img tag ::#} {% macro img(file, attributes={}) %} {% endmacro %} {#:: google_analytics ::#} {#:: include google analytics tags ::#} #------------------------------------------------------------------------------- """ CSS_ASSETS """ {%- macro css_assets(files) %} {%- assets files %} {% endassets -%} {% endmacro -%} #------------------------------------------------------------------------------- """ JS_ASSETS """ {%- macro js_assets(files) %} {%- assets files %} {% endassets -%} {% endmacro -%} #---- flashed_messages() ------------------------------------------------------- # Render the flashed messages set {% macro flashed_messages(dismissible=True) %} {% for category, message in get_flashed_messages(with_categories=True) %} {%endfor%} {% endmacro %} #------------------------------------------------------------------------------- """ Alert """ {% macro alert(message, category="info", dismissible=True) %} {% endmacro %} #------------------------------------------------------------------------------- """ Pagination """ {% macro pagination(paginator, endpoint=None, class_='pagination') %} {% if not endpoint %} {% set endpoint = request.endpoint %} {% endif %} {% if "page" in kwargs %} {% set _ = kwargs.pop("page") %} {% endif %} {% endmacro %} #------------------------------------------------------------------------------- """ Social_Graph """ {%- macro social_graph(use_opengraph=True, use_googleplus=True, use_twitter=True) -%} {%- if __.META_DATA["use_opengraph"] and use_opengraph -%} {%- set __meta = ["title", "url", "description", "image", "object_type", "site_name"] -%} {% for _m in __meta -%} {%- if _m == "object_type" -%} {{- meta.opengraph("type", __.META_DATA[_m]) -}} {%- else -%} {{- meta.opengraph(_m, __.META_DATA[_m]) -}} {%- endif -%} {% endfor %} {%- endif -%} {%- if __.META_DATA["use_googleplus"] and use_googleplus -%} {%- set __meta = ["title", "url", "description", "image"] -%} {% for _m in __meta -%} {%- if _m == "title" -%} {{- meta.googleplus("name", __.META_DATA[_m]) -}} {%- else -%} {{- meta.googleplus(_m, __.META_DATA[_m]) -}} {%- endif -%} {% endfor %} {%- endif -%} {% if __.META_DATA["use_twitter"] and use_twitter -%} {%- set __meta = ["title", "url", "description", "image"] -%} {% for _m in __meta -%} {{- meta.twitter(_m, __.META_DATA[_m]) -}} {% endfor %} {%- endif -%} {%- endmacro -%} #------------------------------------------------------------------------------- {%- macro jquery() -%} {{- js_assets('portfolio/vendor/jquery/dist/jquery.min.js') -}} {%- endmacro -%} #------------------------------------------------------------------------------- {%- macro fontawesome(version="4.3.0") -%} {%- endmacro -%} #------------------------------------------------------------------------------- {% macro bootstrap() %} {{- css_assets('portfolio/vendor/bootstrap/dist/css/bootstrap.min.css') -}} {{- js_assets('portfolio/vendor/bootstrap/dist/js/bootstrap.min.js') -}} {% endmacro %} #------------------------------------------------------------------------------- {% macro bootswatch(theme) %} {{ css_assets('portfolio/vendor/bootswatch/%s.css' % theme) }} {% endmacro %} #------------------------------------------------------------------------------- """ Google_Analytics """ {%- macro google_analytics(code=None) -%} {%- if not code %} {% set code = __.GOOGLE_ANALYTICS_ID %} {% endif -%} {%- if code %} {% endif -%} {%- endmacro -%} #------------------------------------------------------------------------------- """ Head_Section """ {%- macro head_section(title="%s", favicon="favicon.ico", charset="utf-8") -%} {{ title | replace("%s", __.META_DATA["title"]) | safe }} {{ meta.meta("description", __.META_DATA["description"]) }} {{ meta.favicon(favicon) }} {{ social_graph() }} {{ jquery() }} {{ fontawesome() }} {{ bootstrap() }} {{ google_analytics() }} {%- endmacro -%}