


{#

 META

 Collections of meta tags

#}

{% macro title(suffix) %}
    <title>{{ __.__META__["title"] | safe }} {{ suffix | safe }}</title>
{% endmacro %}

{#: The basic meta tag :#}
{% macro meta(name, value) %}
    <meta name="{{ name }}" content="{{ value | safe }}">
{% endmacro %}

{#: Custom meta tag :#}
{% macro custom(namespace, name, value) %}
    <meta {{ namespace }}="{{ name }}" content="{{ value | safe }}">
{% endmacro %}

{#: Opengraph property :#}
{% macro property(namespace, name, value) %}
    <meta property="{{ namespace }}:{{ name }}" content="{{ value | safe }}">
{% endmacro %}

{#: Custom meta tag :#}
{%- macro opengraph(name, value) -%}
    {% if value %}
    <meta property="og:{{ name }}" content="{{ value | safe }}">
    {% endif %}
{%- endmacro %}

{#: Custom meta tag :#}
{%- macro googleplus(name, value) -%}
    {% if value %}
    <meta itemprop="{{ name }}" content="{{ value | safe }}">
    {% endif %}
{%- endmacro -%}

{#: Custom meta tag :#}
{%- macro twitter(name, value) -%}
    {% if value %}
    <meta name="twitter:{{ name }}" content="{{ value | safe }}">
    {% endif %}
{%- endmacro -%}

{#: SOCIAL_GRAPH() ---------------------------------------------------------- #}
{%- macro social_graph(use_opengraph=True, use_googleplus=True, use_twitter=True) -%}

    {% set url = __.__META__["url"] or request.base_url %}
    {% set image =  __.__META__["image"] %}
    {%  if image %}
        {% set image = static_file(image) %}
    {%  endif %}

    {% if __.__META__["use_opengraph"] and use_opengraph %}
        {{ opengraph("title", __.__META__["title"]) }}
        {{ opengraph("description", __.__META__["description"]) }}
        {{ opengraph("url", url) }}
        {{ opengraph("site_name", __.__META__["site_name"]) }}
        {%  set object_type = __.__META__["object_type"] %}
            {{- opengraph("type", __.__META__["object_type"]) -}}

        {% if image %}
            {{ opengraph("image", image) }}
        {% endif %}

    {% endif %}

    {% if __.__META__["use_googleplus"] and use_googleplus %}
        {{ googleplus("description", __.__META__["description"]) }}
        {{ googleplus("name", __.__META__["title"]) }}
        {{ googleplus("url", url) }}
        {% if image %}
            {{ googleplus("image", image) }}
        {% endif %}
    {% endif %}

    {% if __.__META__["use_twitter"] and use_twitter -%}
        {{ twitter("title", __.__META__["title"]) }}
        {{ twitter("description", __.__META__["description"]) }}
        {{ twitter("url", url ) }}
        {% if image %}
            {{ twitter("image", image) }}
            {{ twitter("card", "summary_large_image") }}
        {% else %}
            {{ twitter("card", "summary") }}
        {% endif %}
    {% endif %}


    {%  for k, v in __.__META__["properties"].items() %}
        {{ custom("property", k, v) }}
    {% endfor %}

{% endmacro %}


