From 20e99909a542535e0284e5d50241476154666501 Mon Sep 17 00:00:00 2001 From: Deimos Date: Tue, 30 Jul 2019 18:06:17 -0600 Subject: [PATCH] Add basic group-specific search If you search while inside a group, it will now search only inside that group. A note at the top of the results page will explain this, and includes a link to search across all groups instead. --- tildes/tildes/__init__.py | 2 ++ tildes/tildes/routes.py | 2 ++ tildes/tildes/templates/macros/forms.jinja2 | 12 ++++++++++-- tildes/tildes/templates/search.jinja2 | 12 +++++++++++- tildes/tildes/templates/topic_listing.jinja2 | 6 +++--- tildes/tildes/views/topic.py | 10 ++++++++++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/tildes/tildes/__init__.py b/tildes/tildes/__init__.py index 98284dd..8528847 100644 --- a/tildes/tildes/__init__.py +++ b/tildes/tildes/__init__.py @@ -137,6 +137,7 @@ def current_listing_base_url( base_vars_by_route: Dict[str, Tuple[str, ...]] = { "bookmarks": ("per_page", "type"), "group": ("order", "period", "per_page", "tag", "unfiltered"), + "group_search": ("order", "period", "per_page", "q"), "home": ("order", "period", "per_page", "tag", "unfiltered"), "search": ("order", "period", "per_page", "q"), "user": ("order", "per_page", "type"), @@ -169,6 +170,7 @@ def current_listing_normal_url( normal_vars_by_route: Dict[str, Tuple[str, ...]] = { "bookmarks": ("order", "period", "per_page"), "group": ("order", "period", "per_page"), + "group_search": ("order", "period", "per_page", "q"), "home": ("order", "period", "per_page"), "notifications": ("per_page",), "search": ("order", "period", "per_page", "q"), diff --git a/tildes/tildes/routes.py b/tildes/tildes/routes.py index 4f7aa5b..ab5947e 100644 --- a/tildes/tildes/routes.py +++ b/tildes/tildes/routes.py @@ -36,6 +36,8 @@ def includeme(config: Configurator) -> None: config.add_route("group_topics", "/topics", factory=group_by_path) + config.add_route("group_search", "/search", factory=group_by_path) + config.add_route("group_wiki", "/wiki", factory=group_by_path) # if you change this from "new_page" make sure to also edit diff --git a/tildes/tildes/templates/macros/forms.jinja2 b/tildes/tildes/templates/macros/forms.jinja2 index a675476..84fa77f 100644 --- a/tildes/tildes/templates/macros/forms.jinja2 +++ b/tildes/tildes/templates/macros/forms.jinja2 @@ -61,8 +61,16 @@ {% endmacro %} -{% macro search_form(existing_query=None) %} -