From 5c4ac3cf3dcff7cb0cd8792cc4ba745b1c2f69ae Mon Sep 17 00:00:00 2001 From: apkallum Date: Thu, 20 Aug 2020 10:04:34 -0400 Subject: [PATCH] new public view derived from django --- archivebox/core/urls.py | 3 +- archivebox/core/views.py | 11 + .../themes/default/core/snapshot_list.html | 281 ++++++++++++++++++ 3 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 archivebox/themes/default/core/snapshot_list.html diff --git a/archivebox/core/urls.py b/archivebox/core/urls.py index b830de68..bf5708d5 100644 --- a/archivebox/core/urls.py +++ b/archivebox/core/urls.py @@ -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 +from core.views import MainIndex, OldIndex, LinkDetails, PublicArchiveView # print('DEBUG', settings.DEBUG) @@ -31,4 +31,5 @@ urlpatterns = [ path('index.html', RedirectView.as_view(url='/')), path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}), path('', MainIndex.as_view(), name='Home'), + path('public/', PublicArchiveView.as_view()) ] diff --git a/archivebox/core/views.py b/archivebox/core/views.py index 399f368e..a4e67a42 100644 --- a/archivebox/core/views.py +++ b/archivebox/core/views.py @@ -4,6 +4,7 @@ from django.shortcuts import render, redirect from django.http import HttpResponse from django.views import View, static +from django.views.generic.list import ListView from core.models import Snapshot @@ -102,3 +103,13 @@ class LinkDetails(View): content_type="text/plain", status=404, ) + +class PublicArchiveView(ListView): + template = 'snapshot_list.html' + model = Snapshot + context_object_name = 'links' + paginate_by = 2 + def get_context_data(self, *args, **kwargs): + context = super(PublicArchiveView, self).get_context_data(*args, **kwargs) + context['links'] = [snapshot.as_link for snapshot in Snapshot.objects.all()] + return context diff --git a/archivebox/themes/default/core/snapshot_list.html b/archivebox/themes/default/core/snapshot_list.html new file mode 100644 index 00000000..07dbe675 --- /dev/null +++ b/archivebox/themes/default/core/snapshot_list.html @@ -0,0 +1,281 @@ +{% load static %} + + + + + Archived Sites + + + + + + + + + + +
+
+ +
+
+ + + + + + + + + + + {% for link in links %} + + + + + + + {% endfor %} + +
BookmarkedSaved Link ({{num_links}})FilesOriginal URL
{{link.bookmarked_date}} + {% if link.is_archived %} + + {% else %} + + {% endif %} + + {{link.title|default:'Loading...'}} + {{link.tags|default:''}} + + + 📄 + {{link.num_outputs}} + + {{link.url}}
+ + + +