mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-03 06:17:53 +10:00
new public view derived from django
This commit is contained in:
@@ -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())
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user