views.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import os
  2. import sys
  3. from pathlib import Path
  4. from django.views import View
  5. from django.shortcuts import render
  6. from django.db.models import Q
  7. from core.models import Snapshot
  8. # from archivebox.config import PUBLIC_SNAPSHOTS
  9. PUBLIC_SNAPSHOTS = True
  10. class GalleryDLIconView(View):
  11. template_name = 'plugin_gallerydl__icon.html'
  12. # render static html index from filesystem archive/<timestamp>/index.html
  13. def get_context_data(self, **kwargs):
  14. return {
  15. # **super().get_context_data(**kwargs),
  16. # 'VERSION': VERSION,
  17. # 'COMMIT_HASH': COMMIT_HASH,
  18. # 'FOOTER_INFO': FOOTER_INFO,
  19. }
  20. def get(self, request, path):
  21. if not request.user.is_authenticated and not PUBLIC_SNAPSHOTS:
  22. return redirect(f'/admin/login/?next={request.path}')
  23. # ...
  24. return render(template_name=self.template_name, request=self.request, context=context)
  25. class GalleryDLEmbedView(View):
  26. template_name = 'plugin_gallerydl__embed.html'
  27. # render static html index from filesystem archive/<timestamp>/index.html
  28. def get_context_data(self, **kwargs):
  29. return {
  30. # **super().get_context_data(**kwargs),
  31. # 'VERSION': VERSION,
  32. # 'COMMIT_HASH': COMMIT_HASH,
  33. # 'FOOTER_INFO': FOOTER_INFO,
  34. }
  35. def get(self, request, path):
  36. if not request.user.is_authenticated and not PUBLIC_SNAPSHOTS:
  37. return redirect(f'/admin/login/?next={request.path}')
  38. # ...
  39. return render(template_name=self.template_name, request=self.request, context=context)
  40. class GalleryDLOutputView(View):
  41. template_name = 'plugin_gallerydl__output.html'
  42. # render static html index from filesystem archive/<timestamp>/index.html
  43. def get_context_data(self, **kwargs):
  44. return {
  45. # **super().get_context_data(**kwargs),
  46. # 'VERSION': VERSION,
  47. # 'COMMIT_HASH': COMMIT_HASH,
  48. # 'FOOTER_INFO': FOOTER_INFO,
  49. }
  50. def get(self, request, path):
  51. if not request.user.is_authenticated and not PUBLIC_SNAPSHOTS:
  52. return redirect(f'/admin/login/?next={request.path}')
  53. # ...
  54. return render(template_name=self.template_name, request=self.request, context=context)