forked from mozilla/zamboni
-
Notifications
You must be signed in to change notification settings - Fork 8
/
category_landing.html
90 lines (83 loc) · 2.86 KB
/
category_landing.html
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
{% extends "browse/base_listing.html" %}
{% set addon_sets = filter.all() %}
{% set more_links = {
'created': _('View All Recently Added'),
'popular': _('View All Top Downloads'),
'rating': _('View All Top Rated'),
} %}
{% block bodyclass %}category-landing{% endblock %}
{% block content %}
<header>
{{ breadcrumbs([(url('browse.extensions'), _('Extensions')), (None, category.name)]) }}
<h2>{{ category.name }}</h2>
</header>
{% set addons = addon_sets['featured'] %}
{% if addons %}
<div id="featured-addons" class="featured">
<div class="featured-inner">
<h3>
<a href="{{ url('browse.creatured', category.slug) }}">
{{ _('Featured Add-ons') }}</a>
</h3>
<ul>
{% cache addons %}
{# The featured add-ons for a category should be small, so we get them all
with the if. Shuffling here to take advantage of the cached fragment. #}
{% for addon in (addons|list|shuffle)[:3] %}
<li class="addon item">
<h4>
<a href="{{ addon.get_url_path() }}">
{{ addon.name.localized_string|truncate(35) }}</a>
<span>
{% trans users=users_list(addon.listed_authors) %}
by {{ users }}
{% endtrans %}
</span>
</h4>
<p class="preview">
<a href="{{ addon.get_url_path() }}">
<img src="{{ addon.thumbnail_url }}"></a>
</p>
<p class="addon-desc">{{ addon.summary|truncate(100) }}</p>
<p class="addon-rating">{{ addon.average_rating|float|stars }}</p>
{{ install_button(addon, src='creatured') }}
</li>
{% endfor %}
{% endcache %}
</ul>
</div>
</div> {# featured-addons #}
{% endif %}
{% macro meta(key, addon) %}
<span class="meta">
{% if key == 'created' -%}
{{ _('added on {0}')|f(addon.created|datetime) }}
{% elif key == 'popular' %}
{{ _('{0} weekly downloads')|f(addon.weekly_downloads|numberfmt) }}
{% elif key == 'rating' %}
{{ addon.average_rating|float|stars }}
{%- endif %}
</span>
{% endmacro %}
{% for key, title in filter.opts if key != 'featured' %}
{% set addons = addon_sets[key][:10] %}
{% set link = url('browse.extensions', category.slug)|urlparams(sort=key) %}
<div class="addons-column">
<h3><a href="{{ link }}">{{ filter.opts_dict[key] }}</a></h3>
<ul>
{% cache addons %}
{% for addon in addons %}
<li>
<a href="{{ addon.get_url_path() }}">
<img class="icon" width="32" height="32" src="{{ addon.icon_url }}">
<span class="name">{{ addon.name.localized_string|truncate(35) }}</span>
{{ meta(key, addon) }}
</a>
</li>
{% endfor %}
{% endcache %}
</ul>
<p class="view-all"><a href="{{ link }}">{{ more_links[key] }}</a></p>
</div>
{% endfor %}
{% endblock content %}