Parent: [589cac] (diff)

Child: [c1be33] (diff)

Download this file

lib.html    90 lines (80 with data), 3.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{% macro gravatar(user, size) -%}
{% set display_name = h.really_unicode(user.display_name) %}
{% set icon_url = '/u/'+user.username.replace('_', '-')+'/user_icon' %}
{% if user.preferences.email_address %}
{% set icon_url = g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon')) %}
{% elif user == user.anonymous() %}
{% set icon_url = g.forge_static('images/user.png') %}
{% endif %}
{% if size %}
<img src="{{icon_url}}"
alt="{{display_name}}"
title="{{display_name}}"
height="{{size}}"
width="{{size}}"/>
{% else %}
<img src="{{icon_url}}" alt="{{display_name}}" title="{{display_name}}"/>
{% 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='') %}
{% if label %}
<label for="{{name}}">{{label}}</label><br/>
{% endif %}
<input type="text" id="{{name}}" name="{{name}}" class="text" value="{{value}}"/><br/>
{% endmacro %}
{% macro radio_button(name, label, option, value=None) %}
{% if label %}
<label for="{{name}}">{{label}}</label><br/>
{% endif %}
<input type="radio" id="{{name}}" name="{{name}}" class="text" value="{{option}}"
{% if option == value %}checked="on"{% endif %}/><br/>
{% endmacro %}
{% macro submit_button(value, name=None) %}
<input type="submit" name="{{name}}" 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 %}