{# Base macros #} {% import "WebPortfolio/macros/meta.html" as meta with context %} {#: SITE_HEADER() ----------------------------------------------------------- #} {%- macro site_header(title="%s", favicon="favicon.ico", charset="utf-8", add_social_graph=true, add_google_analytics=true) -%} {{ title | replace("%s", __g.PAGE_META["title"]) | safe }} {{ meta.meta("description", __g.PAGE_META["description"]) }} {{ set_favicon(favicon) }} {% if add_social_graph == true %} {{ social_graph() }} {% endif %} {{ css_assets('web-portfolio_all.css') }} {{ js_assets('jquery.js') }} {{ js_assets('web-portfolio_all.js') }} {% if add_google_analytics == true %} {{ google_analytics() }} {% endif %} {{ fontawesome() }} {%- endmacro -%} {#: CSS_ASSETS() ------------------------------------------------------------- #} {%- macro css_assets(file) %} {%- assets file %} {% endassets -%} {% endmacro -%} {#: JS_ASSETS()--------------------------------------------------------------- #} {%- macro js_assets(file) %} {%- assets file %} {% endassets -%} {% endmacro -%} {#: FLASHED_MESSAGES()------------------------------------------------------- #} {% macro flashed_messages(dismissible=True) %} {% for category, message in get_flashed_messages(with_categories=True) %} {%endfor%} {% endmacro %} {#: FLASH_MESSAGE ----------------------------------------------------------- #} {% macro flash_message(message, category="info", dismissible=True) %} {% endmacro %} {#: PAGINATION -------------------------------------------------------------- #} {# :paginator: iterator :endpoint: :prev: Text for previous button :next: Text for Next button :class_: A class name for pagination if customed. If you are extending the class best to add the original class and your custom class ie: 'pagination my_custom_pagination' or 'pager my_custom_page' :pager: If true it will show a pager instead of numbered pagination #} {% macro pagination(paginator, endpoint=None, prev="", next="", class_=None, pager=False) %} {% if not endpoint %} {% set endpoint = request.endpoint %} {% endif %} {% if "page" in kwargs %} {% set _ = kwargs.pop("page") %} {% endif %} {% if not class_ %} {% set class_ = "pagination" %} {% if pager %} {% set class_ = "pager" %} {% endif %} {% endif %} {% set _prev_btn = " %s" % prev %} {% set _next_btn = " %s" % next %} {% endmacro %} {#: SOCIAL_GRAPH() ---------------------------------------------------------- #} {%- macro social_graph(use_opengraph=True, use_googleplus=True, use_twitter=True) -%} {% set image = __g.PAGE_META["image"] %} {% if image %} {% set image = static_file(path) %} {% endif %} {%- if __g.PAGE_META["use_opengraph"] and use_opengraph -%} {%- set __meta = ["title", "url", "description", "object_type", "site_name"] -%} {% for _m in __meta -%} {%- if _m == "object_type" -%} {{- meta.opengraph("type", __g.PAGE_META[_m]) -}} {%- else -%} {{- meta.opengraph(_m, __g.PAGE_META[_m]) -}} {%- endif -%} {% endfor %} {% if image %} {{ meta.opengraph("image", image) }} {% endif %} {%- endif -%} {%- if __g.PAGE_META["use_googleplus"] and use_googleplus -%} {%- set __meta = ["title", "url", "description"] -%} {% for _m in __meta -%} {%- if _m == "title" -%} {{- meta.googleplus("name", __g.PAGE_META[_m]) -}} {%- else -%} {{- meta.googleplus(_m, __g.PAGE_META[_m]) -}} {%- endif -%} {% endfor %} {% if image %} {{ meta.googleplus("image", image) }} {% endif %} {%- endif -%} {% if __g.PAGE_META["use_twitter"] and use_twitter -%} {%- set __meta = ["title", "url", "description"] -%} {% for _m in __meta -%} {{- meta.twitter(_m, __g.PAGE_META[_m]) -}} {% endfor %} {% if image %} {{ meta.twitter("image", image) }} {{ meta.twitter("card", "summary_large_image") }} {% else %} {{ meta.twitter("card", "summary") }} {% endif %} {%- endif -%} {%- endmacro -%} {#: GOOGLE_ANALYTICS() ------------------------------------------------------ #} {%- macro google_analytics(code=None) -%} {%- if not code %} {% set code = __g.APPLICATION_GOOGLE_ANALYTICS_ID %} {% endif -%} {%- if code %} {% endif -%} {%- 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 -%} {# To create an image Has the option of making that image easyload params: - file: The image name - lazy: (bool) if True, it will be lazy loaded - static: (bool) it will be treated as static files if true - responsive: (bool) #} {% macro img_src(file, lazy=true, responsive=true, static=false) %} {% set _class = kwargs.pop('class', '') %} {% set _responsive = "responsive" if responsive else "" %} {% set blank_image_1x1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=" %} {% set image_file = static_file(file) if static else file%} {% set lazy_class = "lazy" %} {% if lazy %} {% set img_src = blank_image_1x1 %} {% set data_src = image_file %} {% else %} {% set img_src = image_file %} {% set data_src = "" %} {% set lazy_class = "" %} {% endif %} {% endmacro %} {#: OEMBED ------------------------------------------------------------------ #} {# To #} {% macro oembed(url) %} {% endmacro %} #------------------------------------------------------------------------------- {% macro share_buttons(text=None, url=None, show_count=False, show_label=True, buttons=["facebook", "twitter", "googleplus"]) %}
{% endmacro %} {%- macro fontawesome(version="4.3.0") -%} {%- endmacro -%} {% macro oauth_providers(text="Signin with #provider", size="lg", btn_block=true) %} {% endmacro %} #------------------------------------------------------------------------------- {#: Favicon :#} {% macro set_favicon(path) %} {% endmacro %}