mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 03:40:14 +00:00
add initial search endpoint and improve results$
This commit is contained in:
parent
5fb15b79a4
commit
e8eb7077ed
@ -116,6 +116,21 @@ class PlaylistSearchForm(forms.Form):
|
||||
)
|
||||
|
||||
|
||||
class MultiSearchForm(forms.Form):
|
||||
"""multi search form for /search/"""
|
||||
|
||||
searchInput = forms.CharField(
|
||||
label="",
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
"oninput": "searchMulti(this.value)",
|
||||
"autofocus": True,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class AddToQueueForm(forms.Form):
|
||||
"""text area form to add to downloads"""
|
||||
|
||||
|
@ -184,14 +184,23 @@ class SearchForm:
|
||||
"query": {
|
||||
"multi_match": {
|
||||
"query": search_query,
|
||||
"type": "bool_prefix",
|
||||
"operator": "and",
|
||||
"fuzziness": "auto",
|
||||
"fields": [
|
||||
"title",
|
||||
"tags",
|
||||
"category",
|
||||
"channel_name",
|
||||
"channel_description",
|
||||
"playlist_name",
|
||||
"channel_name._2gram",
|
||||
"channel_name._3gram",
|
||||
"channel_name.search_as_you_type",
|
||||
"playlist_description",
|
||||
"playlist_name._2gram",
|
||||
"playlist_name._3gram",
|
||||
"playlist_name.search_as_you_type",
|
||||
"tags",
|
||||
"title._2gram",
|
||||
"title._3gram",
|
||||
"title.search_as_you_type",
|
||||
],
|
||||
}
|
||||
},
|
||||
@ -208,13 +217,14 @@ class SearchForm:
|
||||
video_results = []
|
||||
channel_results = []
|
||||
playlist_results = []
|
||||
for result in search_results:
|
||||
if result["_index"] == "ta_video":
|
||||
video_results.append(result)
|
||||
elif result["_index"] == "ta_channel":
|
||||
channel_results.append(result)
|
||||
elif result["_index"] == "ta_playlist":
|
||||
playlist_results.append(result)
|
||||
if search_results:
|
||||
for result in search_results:
|
||||
if result["_index"] == "ta_video":
|
||||
video_results.append(result)
|
||||
elif result["_index"] == "ta_channel":
|
||||
channel_results.append(result)
|
||||
elif result["_index"] == "ta_playlist":
|
||||
playlist_results.append(result)
|
||||
|
||||
all_results = {
|
||||
"video_results": video_results,
|
||||
|
29
tubearchivist/home/templates/home/search.html
Normal file
29
tubearchivist/home/templates/home/search.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends "home/base.html" %}
|
||||
{% block content %}
|
||||
<div class="boxed-content">
|
||||
<div class="title-bar">
|
||||
<h1>Search</h1>
|
||||
</div>
|
||||
<div class="multi-search-box">
|
||||
{{ search_form }}
|
||||
</div>
|
||||
<div>
|
||||
<h2>Video Results</h2>
|
||||
<div id="video-results" class="video-list grid">
|
||||
<p>No videos found.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Channel Results</h2>
|
||||
<div id="channel-results">
|
||||
<p>No channels found.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Playlist Results</h2>
|
||||
<div id="playlist-results">
|
||||
<p>No playlists found.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -13,6 +13,7 @@ from home.views import (
|
||||
LoginView,
|
||||
PlaylistIdView,
|
||||
PlaylistView,
|
||||
SearchView,
|
||||
SettingsView,
|
||||
VideoView,
|
||||
process,
|
||||
@ -52,4 +53,5 @@ urlpatterns = [
|
||||
login_required(PlaylistIdView.as_view()),
|
||||
name="playlist_id",
|
||||
),
|
||||
path("search/", SearchView.as_view(), name="search"),
|
||||
]
|
||||
|
@ -20,6 +20,7 @@ from home.forms import (
|
||||
ApplicationSettingsForm,
|
||||
ChannelSearchForm,
|
||||
CustomAuthForm,
|
||||
MultiSearchForm,
|
||||
PlaylistSearchForm,
|
||||
SchedulerSettingsForm,
|
||||
SubscribeToChannelForm,
|
||||
@ -669,6 +670,22 @@ class VideoView(View):
|
||||
return stars
|
||||
|
||||
|
||||
class SearchView(ArchivistResultsView):
|
||||
"""resolves to /search/
|
||||
handle cross index search interface
|
||||
"""
|
||||
|
||||
view_origin = "home"
|
||||
es_search = False
|
||||
|
||||
def get(self, request):
|
||||
"""handle get request"""
|
||||
self.initiate_vars(request)
|
||||
self.context.update({"search_form": MultiSearchForm()})
|
||||
|
||||
return render(request, "home/search.html", self.context)
|
||||
|
||||
|
||||
class SettingsView(View):
|
||||
"""resolves to /settings/
|
||||
handle the settings page, display current settings,
|
||||
|
@ -657,6 +657,11 @@ button:hover {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* multi search page */
|
||||
.multi-search-box input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* channel overview page */
|
||||
.channel-list.list {
|
||||
display: block;
|
||||
|
Loading…
Reference in New Issue
Block a user