mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
unify public archive view
This commit is contained in:
parent
3288f8579b
commit
5e8c115f3f
3 changed files with 36 additions and 41 deletions
|
@ -5,7 +5,7 @@ from django.views import static
|
|||
from django.conf import settings
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
from core.views import MainIndex, OldIndex, LinkDetails, PublicArchiveView, SearchResultsView, add_view
|
||||
from core.views import MainIndex, OldIndex, LinkDetails, PublicArchiveView, add_view
|
||||
|
||||
|
||||
# print('DEBUG', settings.DEBUG)
|
||||
|
@ -32,5 +32,4 @@ urlpatterns = [
|
|||
path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}),
|
||||
path('', MainIndex.as_view(), name='Home'),
|
||||
path('public/', PublicArchiveView.as_view(), name='public-index'),
|
||||
path('search_results/', SearchResultsView.as_view(), name='search-results'),
|
||||
]
|
||||
|
|
|
@ -123,6 +123,9 @@ class PublicArchiveView(ListView):
|
|||
|
||||
def get_queryset(self, **kwargs):
|
||||
qs = super().get_queryset(**kwargs)
|
||||
query = self.request.GET.get('q')
|
||||
if query:
|
||||
qs = Snapshot.objects.filter(title__icontains=query)
|
||||
for snapshot in qs:
|
||||
snapshot.icons = get_icons(snapshot)
|
||||
return qs
|
||||
|
@ -134,13 +137,6 @@ class PublicArchiveView(ListView):
|
|||
else:
|
||||
return redirect(f'/admin/login/?next={self.request.path}')
|
||||
|
||||
class SearchResultsView(PublicArchiveView):
|
||||
def get_queryset(self):
|
||||
query = self.request.GET.get('q')
|
||||
results = Snapshot.objects.filter(title__icontains=query)
|
||||
for snapshot in results:
|
||||
snapshot.icons = get_icons(snapshot)
|
||||
return results
|
||||
|
||||
def add_view(request):
|
||||
if PUBLIC_ADD_VIEW or request.user.is_authenticated:
|
||||
|
|
|
@ -232,7 +232,7 @@
|
|||
</div>
|
||||
</header>
|
||||
<br>
|
||||
<form action="{% url 'search-results' %}" method="get">
|
||||
<form action="{% url 'public-index' %}" method="get">
|
||||
<input name="q" type="text" placeholder="Search...">
|
||||
<button type="submit">Search</button>
|
||||
<button onclick="location.href='{% url 'public-index' %}'" type="button">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue