{% macro gravatar(user, size) -%}
{% set display_name = h.really_unicode(user.display_name) %}
{% if user.preferences.email_address %}
{% if size %}
<img src="{{g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon'))}}"
alt="{{display_name}}"
title="{{display_name}}"
height="{{size}}"
width="{{size}}"/>
{% else %}
<img src="{{g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon'))}}"
alt="{{display_name}}"
title="{{display_name}}"/>
{% endif %}
{% else %}
{% if size %}
<img src="{{'/u/'+user.username.replace('_', '-')+'/user_icon'}}"
alt="{{display_name}}"
title="{{display_name}}"
height="{{size}}"
width="{{size}}"/>
{% else %}
<img src="{{'/u/'+user.username.replace('_', '-')+'/user_icon'}}"
alt="{{display_name}}"
title="{{display_name}}"/>
{% endif %}
{% endif %}
{%- endmacro %}
{% macro email_gravatar(email, title=None, size=None) -%}
{% set title=h.really_unicode(title) %}
{% if email %}
<img src="{{g.gravatar(email, size=size)}}" alt="{{title or email}}" title="{{title or email}}"{% if size %} width="{{size}}" height="{{size}}"{% endif %}/>
{% else %}
<img src="{{g.forge_static('images/user.png')}}" alt="{{title}}" title="{{title}}"{% if size %} width="{{size}}" height="{{size}}"{% endif %}/>
{% endif %}
{%- endmacro %}
{% macro file_field(name, label) %}
{% if label %}
<label for="{{name}}">{{label}}</label>
{% endif %}
<input type="file" id="{{name}}" name="{{name}}" class="text" /><br/>
{% endmacro %}
{% macro text_area(name, label, value=None) %}
{% if label %}
<label for="{{name}}">{{label}}</label><br/>
{% endif %}
<textarea id="{{name}}" name="{{name}}">{{value}}</textarea><br/>
{% endmacro %}
{% macro text_field(name, label, value=None) %}
{% if label %}
<label for="{{name}}">{{label}}</label><br/>
{% endif %}
<input type="text" id="{{name}}" name="{{name}}" class="text" value="{{value}}"/><br/>
{% endmacro %}
{% macro path_links(parts) %}
{% set i=0 %}
{% for part in parts %}
<a href="{{'./' + '../' * (parts.__len__()-i-1)}}">{{part}}</a>
{% set i=i+1 %}
{% endfor %}
{% endmacro %}
{% macro post_summary(post) %}
{% if post %}
<span>
by <a href="{{post.author().url()}}">{{post.author().display_name}}</a>
{{h.ago(post.timestamp)}}
</span>
{% endif %}
{% endmacro %}
{% macro crumbs(trail) %}
{% for (label, url) in trail %}
<li class="{{loop.index0 == 0 and 'first' or ''}}">
{% if url %}
<a href="{{url}}">{{label}}</a>
{% else %}
<span>{{label}}</span>
{% endif %}
</li>
{% endfor %}
{% endmacro %}