Skip to content

Commit

Permalink
vital stats are configurable in hovercard grids (bug 671154)
Browse files Browse the repository at this point in the history
  • Loading branch information
potch committed Jul 25, 2011
1 parent c41b808 commit dbd78b5
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 18 deletions.
3 changes: 2 additions & 1 deletion apps/addons/helpers.py
Expand Up @@ -207,7 +207,8 @@ def addon_hovercard(context, addon):
@register.filter
@jinja2.contextfilter
@register.inclusion_tag('addons/impala/addon_grid.html')
def addon_grid(context, addons, src=None, dl_src=None, pagesize=6, cols=2):
def addon_grid(context, addons, src=None, dl_src=None, pagesize=6, cols=2,
vital_summary='rating', vital_more='adu'):
if not src:
src = context.get('src')
# dl_src is an optional src paramater just for the download links
Expand Down
7 changes: 3 additions & 4 deletions apps/addons/templates/addons/impala/addon_grid.html
@@ -1,3 +1,4 @@
{% from "addons/macros.html" import vital %}
{% cache addons %}
<ul class="listing-grid c {{ columns }}">
{% for page in pages %}
Expand All @@ -22,7 +23,7 @@ <h3>{{ addon.name }}</h3>
<div class="category" class="more-info">{{ cat }}</div>
{% endif %}
{% endwith %}
{{ impala_reviews_link(addon) }}
{{ vital(addon, vital_summary) }}
</div>
</a>
<div class="more">
Expand All @@ -33,9 +34,7 @@ <h3>{{ addon.name }}</h3>
by {{ users }}
{% endtrans %}
</div>
<div class="adu">
{{ _('{0} users')|f(addon.average_daily_users|numberfmt) }}
</div>
{{ vital(addon, vital_more) }}
</div>
</div>
</li>
Expand Down
5 changes: 2 additions & 3 deletions apps/addons/templates/addons/impala/featured_grid.html
@@ -1,3 +1,4 @@
{% from "addons/macros.html" import vital %}
{% cache addons %}
<ul class="listing-grid c featured {{ columns }}">
{% for page in pages %}
Expand Down Expand Up @@ -27,9 +28,7 @@ <h3>{{ addon.name }}</h3>
by {{ users }}
{% endtrans %}
</div>
<div class="adu">
{{ _('{0} users')|f(addon.average_daily_users|numberfmt) }}
</div>
{{ vital(addon, 'adu') }}
</div>
</div>
</li>
Expand Down
2 changes: 1 addition & 1 deletion apps/addons/templates/addons/impala/persona_grid.html
@@ -1,5 +1,5 @@
{% cache personas %}
<ul class="listing-grid personas three-col c">
<ul class="listing-grid personas cols-3 c">
{% for page in pages %}
{% set first_page = loop.first %}
<section>
Expand Down
17 changes: 17 additions & 0 deletions apps/addons/templates/addons/macros.html
@@ -0,0 +1,17 @@
{% macro vital(addon, type) %}
<div class="vital">
{% if type == 'rating' %}
{{ impala_reviews_link(addon) }}
{% endif %}
{% if type == 'adu' %}
<span class="adu">
{% trans cnt=addon.average_daily_users,
num=addon.average_daily_users|numberfmt %}
{{ num }} user
{% pluralize %}
{{ num }} users
{% endtrans %}
</span>
{% endif %}
</div>
{% endmacro %}
2 changes: 1 addition & 1 deletion apps/bandwagon/helpers.py
Expand Up @@ -133,7 +133,7 @@ def collection_add_widget(context, addon, condensed=False):
@register.inclusion_tag('bandwagon/collection_grid.html')
def collection_grid(context, collections, src=None, pagesize=4, cols=2):
pages = chunked(collections, pagesize)
columns = '' if cols != 3 else 'three-col'
columns = 'cols-%d' % cols
return new_context(**locals())


Expand Down
4 changes: 3 additions & 1 deletion apps/browse/templates/browse/impala/category_landing.html
Expand Up @@ -26,12 +26,14 @@ <h2>{{ category.name }}</h2>
category.slug)|urlparams(sort=key) %}
{% set hc_src = 'cb-hc-' + src_dict[key] %}
{% set dl_src = 'cb-dl-' + src_dict[key] %}
{% set vital = ('adu', 'rating') if key == 'users' else ('rating', 'adu') %}
<div class="island c">
<h2>
{{ filter.opts_dict[key] }}
<a class="seeall" href="{{ link }}">{{ _('See all »') }}</a>
</h2>
{{ addons|addon_grid(cols=3, src=hc_src, dl_src=dl_src) }}
{{ addons|addon_grid(cols=3, src=hc_src, dl_src=dl_src,
vital_summary=vital[0], vital_more=vital[1]) }}
</div>
{% endfor %}
</section>
Expand Down
8 changes: 4 additions & 4 deletions media/css/impala/hovercards.less
Expand Up @@ -48,6 +48,7 @@
}
.adu {
color: #390;
font-size: 11px;
}
.byline {
margin: 8px 0;
Expand Down Expand Up @@ -140,8 +141,7 @@
padding: 0;
}
}
.adu {
font-size: 11px;
.more .vital {
border-top: 1px dotted #CCCCCC;
padding: 8px 0 0;
margin: 8px 0 4px;
Expand Down Expand Up @@ -197,13 +197,13 @@
}
}
}
.category, .rating {
.category, .vital {
color: #666;
font-size: 11px;
line-height: 10px;
white-space: nowrap;
}
.rating {
.summary .vital {
margin-top: 4px;
font-size: 10px;
line-height: 12px;
Expand Down
2 changes: 1 addition & 1 deletion media/css/impala/prose.less
@@ -1,7 +1,7 @@
.prose {
line-height: 1.2em;
ul, ol {
 margin: 0 0 0 20px;
margin: 0 0 0 20px;
}
ul {
list-style: disc;
Expand Down
4 changes: 2 additions & 2 deletions templates/impala/base.html
Expand Up @@ -76,8 +76,8 @@
{% endif %}
{% block aux_nav %}
<li>
<a href="#" class="controller" title="{{ _('Find add-ons for other applications') }}">{{ _('Other Applications') }}</a>
<ul>
<a href="#" title="{{ _('Find add-ons for other applications') }}">{{ _('Other Applications') }}</a>
<ul class="other-apps">
{% for app in amo.APP_USAGE %}
{% if app != request.APP %}
<li id="app-{{ app.short }}" class="{{ app.short }}">
Expand Down

0 comments on commit dbd78b5

Please sign in to comment.