Fix title on deleting query
This commit is contained in:
parent
ae39eb98e9
commit
6263e65bb9
6 changed files with 44 additions and 48 deletions
|
@ -1,5 +1,28 @@
|
||||||
{% extends 'base.html' %}
|
{% load result_filters %}
|
||||||
|
{% include "title.html" %}
|
||||||
{% block content %}
|
{% if results %}
|
||||||
<h2>Welcome, {{ user.username }}!</h2>
|
{% for result in results %}
|
||||||
{% endblock %}
|
<li class="result" is="mwmbl-result">
|
||||||
|
<div class="result-container">
|
||||||
|
<div class="curation-buttons">
|
||||||
|
<button class="curation-button curate-delete" is="mwmbl-delete-button">✕</button>
|
||||||
|
<button class="curation-button curate-approve" is="mwmbl-validate-button">✓</button>
|
||||||
|
<button class="curation-button curate-add" is="mwmbl-add-button">+</button>
|
||||||
|
</div>
|
||||||
|
<div class="result-link">
|
||||||
|
<a href="{{result.url}}">
|
||||||
|
<p class='link'>{{result.url}}</p>
|
||||||
|
<p class='title'>{{result.title|strengthen}}</p>
|
||||||
|
<p class='extract'>{{result.extract|strengthen}}</p>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<li class="home">
|
||||||
|
<h1>
|
||||||
|
Welcome to Mwmbl, the free, open-source and non-profit search engine.
|
||||||
|
</h1>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
|
@ -8,12 +8,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
<!-- Page title -->
|
{% include "title.html" %}
|
||||||
{% if query %}
|
|
||||||
<title>Mwmbl - {{ query }}</title>
|
|
||||||
{% else %}
|
|
||||||
<title>Mwmbl - Search</title>
|
|
||||||
{% endif %}
|
|
||||||
<meta name="description" content="The free, open-source and non-profit search engine.">
|
<meta name="description" content="The free, open-source and non-profit search engine.">
|
||||||
|
|
||||||
<!-- Favicons -->
|
<!-- Favicons -->
|
||||||
|
@ -69,7 +64,7 @@
|
||||||
placeholder='Search on Mwmbl...'
|
placeholder='Search on Mwmbl...'
|
||||||
title='Use "CTRL+K" or "/" to focus.'
|
title='Use "CTRL+K" or "/" to focus.'
|
||||||
autocomplete='off'
|
autocomplete='off'
|
||||||
hx-get="/app/search/"
|
hx-get="/app/home/"
|
||||||
hx-trigger="keyup changed delay:100ms"
|
hx-trigger="keyup changed delay:100ms"
|
||||||
hx-target=".results"
|
hx-target=".results"
|
||||||
>
|
>
|
||||||
|
@ -86,7 +81,7 @@
|
||||||
<main>
|
<main>
|
||||||
<mwmbl-results>
|
<mwmbl-results>
|
||||||
<ul class='results'>
|
<ul class='results'>
|
||||||
{% include "results.html" %}
|
{% include "home.html" %}
|
||||||
</ul>
|
</ul>
|
||||||
</mwmbl-results>
|
</mwmbl-results>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
{% load result_filters %}
|
|
||||||
<title>Mwmbl - {{ query }}</title>
|
|
||||||
{% if results %}
|
|
||||||
{% for result in results %}
|
|
||||||
<li class="result" is="mwmbl-result">
|
|
||||||
<div class="result-container">
|
|
||||||
<div class="curation-buttons">
|
|
||||||
<button class="curation-button curate-delete" is="mwmbl-delete-button">✕</button>
|
|
||||||
<button class="curation-button curate-approve" is="mwmbl-validate-button">✓</button>
|
|
||||||
<button class="curation-button curate-add" is="mwmbl-add-button">+</button>
|
|
||||||
</div>
|
|
||||||
<div class="result-link">
|
|
||||||
<a href="{{result.url}}">
|
|
||||||
<p class='link'>{{result.url}}</p>
|
|
||||||
<p class='title'>{{result.title|strengthen}}</p>
|
|
||||||
<p class='extract'>{{result.extract|strengthen}}</p>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
<li class="home">
|
|
||||||
<h1>
|
|
||||||
Welcome to Mwmbl, the free, open-source and non-profit search engine.
|
|
||||||
</h1>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
6
mwmbl/templates/title.html
Normal file
6
mwmbl/templates/title.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<!-- Page title -->
|
||||||
|
{% if query %}
|
||||||
|
<title>Mwmbl - {{ query }}</title>
|
||||||
|
{% else %}
|
||||||
|
<title>Mwmbl - Search</title>
|
||||||
|
{% endif %}
|
|
@ -18,14 +18,14 @@ from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from mwmbl.api import api_v1
|
from mwmbl.api import api_v1
|
||||||
from mwmbl.views import search_results, fetch_url, home
|
from mwmbl.views import home_fragment, fetch_url, index
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('api/v1/', api_v1.urls),
|
path('api/v1/', api_v1.urls),
|
||||||
path('accounts/', include('allauth.urls')),
|
path('accounts/', include('allauth.urls')),
|
||||||
|
|
||||||
path('', home, name="home"),
|
path('', index, name="home"),
|
||||||
path('app/search/', search_results, name="search_results"),
|
path('app/home/', home_fragment, name="home"),
|
||||||
path('app/fetch/', fetch_url, name="fetch_url")
|
path('app/fetch/', fetch_url, name="fetch_url")
|
||||||
]
|
]
|
||||||
|
|
|
@ -41,7 +41,7 @@ def justext_with_dom(html_text, stoplist, length_low=LENGTH_LOW_DEFAULT,
|
||||||
return paragraphs, title
|
return paragraphs, title
|
||||||
|
|
||||||
|
|
||||||
def home(request):
|
def index(request):
|
||||||
query = request.GET.get("q")
|
query = request.GET.get("q")
|
||||||
results = ranker.search(query) if query else None
|
results = ranker.search(query) if query else None
|
||||||
return render(request, "index.html", {
|
return render(request, "index.html", {
|
||||||
|
@ -51,10 +51,10 @@ def home(request):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def search_results(request):
|
def home_fragment(request):
|
||||||
query = request.GET["q"]
|
query = request.GET["q"]
|
||||||
results = ranker.search(query)
|
results = ranker.search(query)
|
||||||
response = render(request, "results.html", {"results": results, "query": query})
|
response = render(request, "home.html", {"results": results, "query": query})
|
||||||
current_url = request.htmx.current_url
|
current_url = request.htmx.current_url
|
||||||
# Replace query string with new query
|
# Replace query string with new query
|
||||||
stripped_url = current_url[:current_url.index("?")] if "?" in current_url else current_url
|
stripped_url = current_url[:current_url.index("?")] if "?" in current_url else current_url
|
||||||
|
@ -77,7 +77,7 @@ def fetch_url(request):
|
||||||
extract = extract[:NUM_EXTRACT_CHARS - 1] + '…'
|
extract = extract[:NUM_EXTRACT_CHARS - 1] + '…'
|
||||||
|
|
||||||
result = Document(title=title, url=url, extract=extract, score=0.0)
|
result = Document(title=title, url=url, extract=extract, score=0.0)
|
||||||
return render(request, "results.html", {
|
return render(request, "home.html", {
|
||||||
"results": [format_result(result, query)],
|
"results": [format_result(result, query)],
|
||||||
"query": query,
|
"query": query,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue