clean up search pages
This commit is contained in:
Родитель
a592ceae08
Коммит
7260a51c24
|
@ -247,7 +247,8 @@ class PersonasFilter(BaseFilter):
|
|||
.with_index(personas='personas_movers_idx'))
|
||||
|
||||
|
||||
def personas(request, category=None):
|
||||
def personas_listing(request, category=None):
|
||||
# Common pieces using by browse and search.
|
||||
TYPE = amo.ADDON_PERSONA
|
||||
q = Category.objects.filter(application=request.APP.id,
|
||||
type=TYPE)
|
||||
|
@ -255,15 +256,17 @@ def personas(request, category=None):
|
|||
|
||||
base = (Addon.objects.public().filter(type=TYPE)
|
||||
.extra(select={'_app': request.APP.id}))
|
||||
featured = base & Addon.objects.featured(request.APP)
|
||||
is_homepage = category is None and 'sort' not in request.GET
|
||||
|
||||
if category is not None:
|
||||
category = get_object_or_404(q, slug=category)
|
||||
base = base.filter(categories__id=category.id)
|
||||
|
||||
filter = PersonasFilter(request, base, key='sort', default='up-and-coming')
|
||||
return categories, filter
|
||||
|
||||
|
||||
def personas(request, category=None):
|
||||
categories, filter = personas_listing(request, category)
|
||||
if 'sort' in request.GET:
|
||||
template = 'grid.html'
|
||||
else:
|
||||
|
@ -277,13 +280,13 @@ def personas(request, category=None):
|
|||
count = base.with_index(addons='type_status_inactive_idx').count()
|
||||
addons = amo.utils.paginate(request, filter.qs, 30, count=count)
|
||||
|
||||
search_cat = 'personas'
|
||||
|
||||
featured = base & Addon.objects.featured(request.APP)
|
||||
is_homepage = category is None and 'sort' not in request.GET
|
||||
return jingo.render(request, 'browse/personas/' + template,
|
||||
{'categories': categories, 'category': category,
|
||||
'filter': filter, 'addons': addons,
|
||||
'featured': featured, 'is_homepage': is_homepage,
|
||||
'search_cat': search_cat})
|
||||
'search_cat': 'personas'})
|
||||
|
||||
|
||||
@cache_page(60 * 60 * 24 * 365)
|
||||
|
|
|
@ -1,34 +1,28 @@
|
|||
{% extends "base.html" %}
|
||||
{% from "browse/macros.html" import secondary_categories %}
|
||||
|
||||
{% block title %}
|
||||
{% if query %}
|
||||
{{ page_title(_('Personas Search Results for {0}')|f(query)) }}
|
||||
{{ page_title(_('Personas Search Results for {0}')|f(query)) }}
|
||||
{% else %}
|
||||
{{ page_title(_('Personas Search Results')) }}
|
||||
{{ page_title(_('Personas Search Results')) }}
|
||||
{% endif %}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="primary" role="main">
|
||||
<h2>{{ _('Browse Personas') }}</h2>
|
||||
<header class="results-head">
|
||||
{{ breadcrumbs([(None, _('Search'))]) }}
|
||||
<hgroup>
|
||||
<h2>{{ _('Browse Personas') }}</h2>
|
||||
<h3 class="results-count">{{ showing(query, tag, pager) }}</h3>
|
||||
</hgroup>
|
||||
</header>
|
||||
|
||||
<h3>
|
||||
{% trans plural=pager.paginator.count, count=pager.paginator.count|numberfmt %}
|
||||
{{ count }} Persona {% pluralize %} {{ count }} Personas
|
||||
{% endtrans %}
|
||||
</h3>
|
||||
<div class="featured">
|
||||
{% if pager.object_list %}
|
||||
<div class="featured-inner">
|
||||
<ul class="thumbnails">
|
||||
{% for a in pager.object_list %}
|
||||
<li>
|
||||
{{ persona_preview(a.persona) }}
|
||||
<h4>{{ a.name }}</h4>
|
||||
<em>{{ _('{0} active daily users')|f(a.average_daily_users|numberfmt) }}</em>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{{ persona_grid(pager.object_list) }}
|
||||
</div>
|
||||
<div class="listing-footer">{{ pager|paginator }}</div>
|
||||
{% else %}
|
||||
|
@ -36,19 +30,5 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="secondary" role="complementary">
|
||||
<div class="categories persona-categories">
|
||||
<h3>{{ _('Personas') }}</h3>
|
||||
<ul>
|
||||
{% cache categories %}
|
||||
{% for cat in categories %}
|
||||
<li>
|
||||
<a href="{{ url('browse.personas', cat.slug) }}">{{ cat.name }}</a>
|
||||
<span class="items">{{ cat.count }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endcache %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{ secondary_categories(_('Personas'), 'browse.personas', categories, filter) }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ page_title(title) }}{% endblock %}
|
||||
{% block title %}
|
||||
{% if query %}
|
||||
{{ page_title(_('Add-on Search Results for {0}')|f(query)) }}
|
||||
{% else %}
|
||||
{{ page_title(_('Add-on Search Results')) }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="primary" role="main">
|
||||
<header class="results-head">
|
||||
{{ breadcrumbs([(None, _('Search'))]) }}
|
||||
<h2>{{ _('Search Results') }}</h2>
|
||||
<h3 class="results-count">{{ showing(query, tag, pager) }}</h3>
|
||||
{% if sort == 'name' %}
|
||||
|
|
|
@ -10,6 +10,7 @@ from tower import ugettext as _
|
|||
|
||||
import amo
|
||||
import bandwagon.views
|
||||
import browse.views
|
||||
from amo.decorators import json_view
|
||||
from amo.helpers import urlparams
|
||||
from amo import urlresolvers
|
||||
|
@ -172,20 +173,15 @@ def _personas(request):
|
|||
page = form.cleaned_data.get('page') or 1
|
||||
search_opts['offset'] = (page - 1) * search_opts['limit']
|
||||
|
||||
client = PersonasClient()
|
||||
|
||||
q = Category.objects.filter(application=request.APP.id,
|
||||
type=amo.ADDON_PERSONA)
|
||||
categories = order_by_translation(q, 'name')
|
||||
|
||||
try:
|
||||
results = client.query(query, **search_opts)
|
||||
results = PersonasClient().query(query, **search_opts)
|
||||
except SearchError:
|
||||
return jingo.render(request, 'search/down.html', {}, status=503)
|
||||
|
||||
pager = amo.utils.paginate(request, results, search_opts['limit'])
|
||||
|
||||
c = dict(pager=pager, form=form, categories=categories)
|
||||
categories, filter = browse.views.personas_listing(request)
|
||||
c = dict(pager=pager, form=form, categories=categories, query=query,
|
||||
filter=filter)
|
||||
return jingo.render(request, 'search/personas.html', c)
|
||||
|
||||
|
||||
|
@ -238,8 +234,6 @@ def ajax_search(request):
|
|||
|
||||
|
||||
def search(request, tag_name=None):
|
||||
title = _('Search Add-ons')
|
||||
|
||||
# If the form is invalid we still want to have a query.
|
||||
query = request.REQUEST.get('q', '')
|
||||
|
||||
|
@ -273,9 +267,6 @@ def search(request, tag_name=None):
|
|||
# Remora dies in a fire.
|
||||
query = form.cleaned_data['q']
|
||||
|
||||
if query:
|
||||
title = _('Search for %s' % query)
|
||||
|
||||
addon_type = form.cleaned_data.get('atype', 0)
|
||||
tag = tag_name if tag_name is not None else form.cleaned_data.get('tag')
|
||||
page = form.cleaned_data['page']
|
||||
|
@ -337,6 +328,6 @@ def search(request, tag_name=None):
|
|||
pager = amo.utils.paginate(request, results, search_opts['limit'])
|
||||
|
||||
return jingo.render(request, 'search/results.html', {
|
||||
'pager': pager, 'title': title, 'query': query, 'tag': tag,
|
||||
'pager': pager, 'query': query, 'tag': tag,
|
||||
'versions': versions, 'categories': categories, 'tags': tags,
|
||||
'sort_tabs': sort_tabs, 'sort': sort})
|
||||
|
|
|
@ -2564,7 +2564,7 @@ html[xmlns] .clearfix {
|
|||
}
|
||||
|
||||
.results-head {width: 100%;}
|
||||
.results-head h2 { margin-bottom: 0;}
|
||||
.results-head h2 { margin-bottom: 0; margin-top: 0;}
|
||||
.results-head h3 {margin-top: 0; font-family: "helvetica neue", arial, helvetica, sans-serif; font-weight: normal; color: #444;}
|
||||
|
||||
.results .item .item-info .downloads {display: block; margin-left: 0px;}
|
||||
|
|
Загрузка…
Ссылка в новой задаче