{#      Description:                                                    -#}
{# This macro renders account link w/ images                            -#}

{# account object                                                       -#}
{#      Accountprofilecontact -#}

{% macro accountLink(account) %}
    {# @var account \ArcaSolutions\WebBundle\Entity\Accountprofilecontact #}

    {% import "::blocks/utility/profile.html.twig" as Profile -%}

    <span class="pull-right">
        {{ 'By'|trans }}

        {% if link is not empty %}
            <a rel="nofollow" href="{{ link }}">{{ account.firstName }} {{ account.lastName }}</a>
        {% else %}
            {{ account.firstName }} {{ account.lastName }}
        {% endif %}
    </span>
{% endmacro %}

{#      Description:                                                    -#}
{# This macro renders author info(a different field of account)         -#}

{# item object                                                          -#}
{#      Module's repository                                             -#}

{% macro authorLink(item, isSample) %}
    {#- it has author -#}

    {# elasticsearch compatibility #}
    {% if item.author.name is defined %}
        {% set name = item.author.name %}
        {% set url = item.author.url %}
    {% else %}
        {% set name = item.author %}
        {% set url = item.authorUrl %}
    {% endif %}

    {% if isSample %}
        {% set url = 'javascript:void(0);' %}
    {% endif %}

    {% if name is not empty %}
        <span class="pull-right">
            {{ 'By'|trans }}
            {% if url %}
                <a href="{{ url }}"> {{ name }} </a>
            {% else %}
                {{ name }}
            {% endif %}
        </span>
    {% endif %}
{% endmacro %}
