mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50: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):
|
class AddToQueueForm(forms.Form):
|
||||||
"""text area form to add to downloads"""
|
"""text area form to add to downloads"""
|
||||||
|
|
||||||
|
@ -184,14 +184,23 @@ class SearchForm:
|
|||||||
"query": {
|
"query": {
|
||||||
"multi_match": {
|
"multi_match": {
|
||||||
"query": search_query,
|
"query": search_query,
|
||||||
|
"type": "bool_prefix",
|
||||||
|
"operator": "and",
|
||||||
|
"fuzziness": "auto",
|
||||||
"fields": [
|
"fields": [
|
||||||
"title",
|
|
||||||
"tags",
|
|
||||||
"category",
|
"category",
|
||||||
"channel_name",
|
|
||||||
"channel_description",
|
"channel_description",
|
||||||
"playlist_name",
|
"channel_name._2gram",
|
||||||
|
"channel_name._3gram",
|
||||||
|
"channel_name.search_as_you_type",
|
||||||
"playlist_description",
|
"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 = []
|
video_results = []
|
||||||
channel_results = []
|
channel_results = []
|
||||||
playlist_results = []
|
playlist_results = []
|
||||||
for result in search_results:
|
if search_results:
|
||||||
if result["_index"] == "ta_video":
|
for result in search_results:
|
||||||
video_results.append(result)
|
if result["_index"] == "ta_video":
|
||||||
elif result["_index"] == "ta_channel":
|
video_results.append(result)
|
||||||
channel_results.append(result)
|
elif result["_index"] == "ta_channel":
|
||||||
elif result["_index"] == "ta_playlist":
|
channel_results.append(result)
|
||||||
playlist_results.append(result)
|
elif result["_index"] == "ta_playlist":
|
||||||
|
playlist_results.append(result)
|
||||||
|
|
||||||
all_results = {
|
all_results = {
|
||||||
"video_results": video_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,
|
LoginView,
|
||||||
PlaylistIdView,
|
PlaylistIdView,
|
||||||
PlaylistView,
|
PlaylistView,
|
||||||
|
SearchView,
|
||||||
SettingsView,
|
SettingsView,
|
||||||
VideoView,
|
VideoView,
|
||||||
process,
|
process,
|
||||||
@ -52,4 +53,5 @@ urlpatterns = [
|
|||||||
login_required(PlaylistIdView.as_view()),
|
login_required(PlaylistIdView.as_view()),
|
||||||
name="playlist_id",
|
name="playlist_id",
|
||||||
),
|
),
|
||||||
|
path("search/", SearchView.as_view(), name="search"),
|
||||||
]
|
]
|
||||||
|
@ -20,6 +20,7 @@ from home.forms import (
|
|||||||
ApplicationSettingsForm,
|
ApplicationSettingsForm,
|
||||||
ChannelSearchForm,
|
ChannelSearchForm,
|
||||||
CustomAuthForm,
|
CustomAuthForm,
|
||||||
|
MultiSearchForm,
|
||||||
PlaylistSearchForm,
|
PlaylistSearchForm,
|
||||||
SchedulerSettingsForm,
|
SchedulerSettingsForm,
|
||||||
SubscribeToChannelForm,
|
SubscribeToChannelForm,
|
||||||
@ -669,6 +670,22 @@ class VideoView(View):
|
|||||||
return stars
|
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):
|
class SettingsView(View):
|
||||||
"""resolves to /settings/
|
"""resolves to /settings/
|
||||||
handle the settings page, display current settings,
|
handle the settings page, display current settings,
|
||||||
|
@ -657,6 +657,11 @@ button:hover {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* multi search page */
|
||||||
|
.multi-search-box input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* channel overview page */
|
/* channel overview page */
|
||||||
.channel-list.list {
|
.channel-list.list {
|
||||||
display: block;
|
display: block;
|
||||||
|
Loading…
Reference in New Issue
Block a user