mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
SubredditSearch: Separate facets from SearchBar.
Conflicts: r2/r2/lib/pages/pages.py Conflicts: r2/r2/lib/pages/pages.py
This commit is contained in:
@@ -1439,8 +1439,7 @@ class SearchPage(BoringPage):
|
||||
search_params=search_params,
|
||||
site=site,
|
||||
simple=simple, restrict_sr=restrict_sr,
|
||||
syntax=syntax, converted_data=converted_data,
|
||||
facets=facets, sort=sort, recent=recent)
|
||||
syntax=syntax, converted_data=converted_data)
|
||||
self.subreddits = subreddits
|
||||
|
||||
# generate the over18 redirect url for the current search if needed
|
||||
@@ -1456,11 +1455,14 @@ class SearchPage(BoringPage):
|
||||
kw['nav_menus'].append(MenuLink(title=_('enable NSFW results'),
|
||||
url=over18_url))
|
||||
|
||||
self.sr_facets = SubredditFacets(prev_search=prev_search, facets=facets,
|
||||
sort=sort, recent=recent)
|
||||
BoringPage.__init__(self, pagename, robots='noindex', *a, **kw)
|
||||
|
||||
def content(self):
|
||||
return self.content_stack((self.searchbar, self.infobar,
|
||||
self.nav_menu, self.subreddits, self._content))
|
||||
self.nav_menu, self.subreddits, self._content,
|
||||
self.sr_facets))
|
||||
|
||||
|
||||
class MenuLink(Templated):
|
||||
@@ -3138,8 +3140,8 @@ class SearchBar(Templated):
|
||||
"""
|
||||
def __init__(self, header=None, prev_search='', search_params={},
|
||||
simple=False, restrict_sr=False, site=None, syntax=None,
|
||||
subreddit_search=False, converted_data=None, facets={},
|
||||
sort=None, recent=None, **kw):
|
||||
subreddit_search=False, converted_data=None,
|
||||
**kw):
|
||||
if header is None:
|
||||
header = _("search")
|
||||
self.header = header
|
||||
@@ -3150,8 +3152,15 @@ class SearchBar(Templated):
|
||||
simple=simple, restrict_sr=restrict_sr,
|
||||
site=site, syntax=syntax,
|
||||
converted_data=converted_data,
|
||||
subreddit_search=subreddit_search, facets=facets,
|
||||
sort=sort, recent=recent)
|
||||
subreddit_search=subreddit_search)
|
||||
|
||||
|
||||
class SubredditFacets(Templated):
|
||||
def __init__(self, prev_search='', facets={}, sort=None, recent=None):
|
||||
self.prev_search = prev_search
|
||||
|
||||
Templated.__init__(self, facets=facets, sort=sort, recent=recent)
|
||||
|
||||
|
||||
class Frame(Wrapped):
|
||||
"""Frameset for the FrameToolbar used when a user hits /tb/. The
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<%!
|
||||
from r2.lib.strings import strings
|
||||
from r2.lib.pages import SearchForm
|
||||
from r2.lib.template_helpers import static, search_url
|
||||
from r2.lib.template_helpers import static
|
||||
%>
|
||||
|
||||
<% isize = 60 %>
|
||||
@@ -52,17 +52,3 @@
|
||||
syntax=thing.syntax)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
%if thing.facets and len(thing.facets) > 1:
|
||||
<div class="searchfacets">
|
||||
<h4 class="title">${_("too many results? narrow it down to a subreddit!")}</h4>
|
||||
<ol class="list">
|
||||
%for subreddit, count in thing.facets:
|
||||
<li class="searchfacet reddit">
|
||||
<a class="facet title word" href="${search_url(thing.prev_search, subreddit.name, restrict_sr='on', sort=thing.sort, recent=thing.recent)}">/r/${subreddit.name}</a>
|
||||
<span class="facet count number">(${count})</span>
|
||||
</li>
|
||||
%endfor
|
||||
</ol>
|
||||
</div>
|
||||
%endif
|
||||
|
||||
39
r2/r2/templates/subredditfacets.html
Normal file
39
r2/r2/templates/subredditfacets.html
Normal file
@@ -0,0 +1,39 @@
|
||||
## The contents of this file are subject to the Common Public Attribution
|
||||
## License Version 1.0. (the "License"); you may not use this file except in
|
||||
## compliance with the License. You may obtain a copy of the License at
|
||||
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
|
||||
## License Version 1.1, but Sections 14 and 15 have been added to cover use of
|
||||
## software over a computer network and provide for limited attribution for the
|
||||
## Original Developer. In addition, Exhibit A has been modified to be
|
||||
## consistent with Exhibit B.
|
||||
##
|
||||
## Software distributed under the License is distributed on an "AS IS" basis,
|
||||
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
## the specific language governing rights and limitations under the License.
|
||||
##
|
||||
## The Original Code is reddit.
|
||||
##
|
||||
## The Original Developer is the Initial Developer. The Initial Developer of
|
||||
## the Original Code is reddit Inc.
|
||||
##
|
||||
## All portions of the code written by reddit are Copyright (c) 2006-2015
|
||||
## reddit Inc. All Rights Reserved.
|
||||
###############################################################################
|
||||
|
||||
<%!
|
||||
from r2.lib.template_helpers import search_url
|
||||
%>
|
||||
|
||||
%if thing.facets and len(thing.facets) > 1:
|
||||
<div class="searchfacets">
|
||||
<h4 class="title">${_("too many results? narrow it down to a subreddit!")}</h4>
|
||||
<ol class="list">
|
||||
%for subreddit, count in thing.facets:
|
||||
<li class="searchfacet reddit">
|
||||
<a class="facet title word" href="${search_url(thing.prev_search, subreddit.name, restrict_sr='on', sort=thing.sort, recent=thing.recent)}">/r/${subreddit.name}</a>
|
||||
<span class="facet count number">(${count})</span>
|
||||
</li>
|
||||
%endfor
|
||||
</ol>
|
||||
</div>
|
||||
%endif
|
||||
Reference in New Issue
Block a user