From be30c6a42b0f839d3aa4a99d84e6844c6ca6c2c1 Mon Sep 17 00:00:00 2001 From: michael-lewis Date: Sun, 3 Dec 2023 20:50:24 +0000 Subject: [PATCH] New chat page, for #96 Chat with your website functionality --- .../dynamic/searchmysite/search/search.py | 28 +-- .../templates/layoutwithchatbox.html | 50 ----- .../searchmysite/templates/search/chat.html | 192 ++++++++++++++---- 3 files changed, 172 insertions(+), 98 deletions(-) delete mode 100644 src/web/content/dynamic/searchmysite/templates/layoutwithchatbox.html diff --git a/src/web/content/dynamic/searchmysite/search/search.py b/src/web/content/dynamic/searchmysite/search/search.py index 8242fe7..303fb0b 100644 --- a/src/web/content/dynamic/searchmysite/search/search.py +++ b/src/web/content/dynamic/searchmysite/search/search.py @@ -9,6 +9,7 @@ import config import searchmysite.solr from searchmysite.searchutils import get_search_params, get_query_vector_string, get_start, get_filter_queries, do_search, do_vector_search, get_no_of_results, get_page_range, get_links, get_display_pagination, get_display_facets, get_display_results +from searchmysite.adminutils import select_indexed_domains import os bp = Blueprint('search', __name__) @@ -64,24 +65,25 @@ def browse(search_type='browse'): def chat(search_type='chat'): # Get params and data required to perform search - params = get_search_params(request, search_type) - groupbydomain = False # Browse only returns home pages, so will only have one result per domain - query = params['q'] - if query != '*': - query_vector_string = get_query_vector_string(query) + #params = get_search_params(request, search_type) + #groupbydomain = False # Browse only returns home pages, so will only have one result per domain + #query = params['q'] + #if query != '*': + # query_vector_string = get_query_vector_string(query) # Perform the actual search - search_results = do_vector_search(query_vector_string) + # search_results = do_vector_search(query_vector_string) #current_app.logger.debug('search_results: {}'.format(search_results)) # Get data required to display the results - (total_results, total_domains) = get_no_of_results(search_results, groupbydomain) # groupbydomain False so both values will be the same - links = get_links(request, params, search_type) - display_results = get_display_results(search_results, groupbydomain, params, links['query_string']) - else: - display_results = None - - return render_template('search/chat.html', params=params, subtitle='Chat', results=display_results) + # (total_results, total_domains) = get_no_of_results(search_results, groupbydomain) # groupbydomain False so both values will be the same + # links = get_links(request, params, search_type) + # display_results = get_display_results(search_results, groupbydomain, params, links['query_string']) + #else: + # display_results = None + #return render_template('search/chat.html', params=params, subtitle='Chat', results=display_results) + all_indexed_domains = select_indexed_domains() + return render_template('search/chat.html', subtitle='Chat', domains=all_indexed_domains) @bp.route('/new/', methods=['GET', 'POST']) diff --git a/src/web/content/dynamic/searchmysite/templates/layoutwithchatbox.html b/src/web/content/dynamic/searchmysite/templates/layoutwithchatbox.html deleted file mode 100644 index afef311..0000000 --- a/src/web/content/dynamic/searchmysite/templates/layoutwithchatbox.html +++ /dev/null @@ -1,50 +0,0 @@ -{% extends "layout.html" %} - -{% block searchbox %} -
-
-
-
- - -
-
-
-
- -
-
- -
-
- -
- -{% endblock %} - diff --git a/src/web/content/dynamic/searchmysite/templates/search/chat.html b/src/web/content/dynamic/searchmysite/templates/search/chat.html index 6e7c427..d93eec9 100644 --- a/src/web/content/dynamic/searchmysite/templates/search/chat.html +++ b/src/web/content/dynamic/searchmysite/templates/search/chat.html @@ -1,47 +1,169 @@ -{% extends "layoutwithchatbox.html" %} +{% extends "layout.html" %} {% block title %}Search My Site - {{ subtitle }}{% endblock %} {% block content %} - {% if results %} - -
-
- {% for result in results %} -
-

- {% if result['contains_adverts'] %}Page contains adverts{% endif %} - {% if result['published_date'] %}{{ result['published_date'] }}:{% endif %} - {{ result['url'] }} -

- {% if result['content_chunk_text'] %} -

- {{ result['content_chunk_text'] }} - + +

+ Please note: +

    +
  • + This service is experimental, is running on a relatively low powered machine so is very slow, and may sometimes generate incoherent results. +
  • +
  • + If you don't see a result you expect it might be because the content falls outside the + page and embedding limits shown on Add Site. +
  • +
+

+ +
+
-
+ +
{% endblock %}