Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
move div.item out to an inclusion tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jbalogh committed Mar 23, 2010
1 parent 118956c commit 7157592
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 37 deletions.
8 changes: 8 additions & 0 deletions apps/addons/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@ def contribution(addon, text='', src='', show_install=False, show_help=True):
'has_suggested': bool(addon.suggested_amount),
'pledge': pledge,
}))


@register.inclusion_tag('addons/listing_items.html')
@jinja2.contextfunction
def addon_listing_items(context, addons):
c = dict(context.items())
c['addons'] = addons
return c
38 changes: 1 addition & 37 deletions apps/addons/templates/addons/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,43 +62,7 @@ <h2>{{ _('Browse Add-ons') }}</h2>
<div class="addon-listing addon-listing-{{ filter.field }}">
{% for key, addons in addon_sets.items() %}
<div id="list-{{ key }}">
{% for addon in addons %}
{% cache addon %}
<div class="item">
<div class="install">Install button</div>
<h3>
<a href="{{ addon.get_url_path() }}">{{ addon.name }}</a>
<span>
{% trans users=users_list(addon.authors.all()) %}
by {{ users }}
{% endtrans %}
</span>
</h3>
<a href="{{ addon.get_url_path() }}">
<img class="icon" width="32" height="32" src="{{ addon.icon_url }}"
alt="{{ addon.name }}">
</a>
<blockquote>
{{ addon.description|truncate(250) }}
</blockquote>
<div class="meta">
{{ addon|reviews_link }}
<span class="downloads">
{% with num=addon.weekly_downloads %}
{# L10n: {0} is the number of downloads. #}
{{ ngettext("<strong>{0}</strong> weekly download",
"<strong>{0}</strong> weekly downloads",
num)|f(num|numberfmt)|safe }}
{% endwith %}
</span>
<span class="updated">
{{ _('Updated {0}')|f(addon.last_updated|datetime) }}
</span>
{{ support_addon(addon) }}
</div>
</div>
{% endcache %}
{% endfor %}
{{ addon_listing_items(addons) }}
<div class="listing-footer">
{# TODO(jbalogh): browse and rss page urls #}
<a class="subscribe" href="#">
Expand Down
39 changes: 39 additions & 0 deletions apps/addons/templates/addons/listing_items.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% cache addons %}
{% for addon in addons %}
{% cache addon %}
<div class="item">
{{ install_button(addon) }}
<h3>
<a href="{{ addon.get_url_path() }}">{{ addon.name }}</a>
<span>
{% trans users=users_list(addon.authors.all()) %}
by {{ users }}
{% endtrans %}
</span>
</h3>
<a href="{{ addon.get_url_path() }}">
<img class="icon" width="32" height="32" src="{{ addon.icon_url }}"
alt="{{ addon.name }}">
</a>
<blockquote>
{{ addon.description|truncate(250) }}
</blockquote>
<div class="meta">
{{ addon|reviews_link }}
<span class="downloads">
{% with num=addon.weekly_downloads %}
{# L10n: {0} is the number of downloads. #}
{{ ngettext("<strong>{0}</strong> weekly download",
"<strong>{0}</strong> weekly downloads",
num)|f(num|numberfmt)|safe }}
{% endwith %}
</span>
<span class="updated">
{{ _('Updated {0}')|f(addon.last_updated|datetime) }}
</span>
{{ support_addon(addon) }}
</div>
</div>
{% endcache %}
{% endfor %}
{% endcache %}

0 comments on commit 7157592

Please sign in to comment.