urls.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. __package__ = 'archivebox.core'
  2. from django.urls import path, re_path, include
  3. from django.views import static
  4. from django.conf import settings
  5. from django.views.generic.base import RedirectView
  6. from archivebox.misc.serve_static import serve_static
  7. from core.admin_site import archivebox_admin
  8. from core.views import HomepageView, SnapshotView, PublicIndexView, AddView, HealthCheckView
  9. from workers.views import JobsDashboardView
  10. # GLOBAL_CONTEXT doesn't work as-is, disabled for now: https://github.com/ArchiveBox/ArchiveBox/discussions/1306
  11. # from archivebox.config import VERSION, VERSIONS_AVAILABLE, CAN_UPGRADE
  12. # GLOBAL_CONTEXT = {'VERSION': VERSION, 'VERSIONS_AVAILABLE': VERSIONS_AVAILABLE, 'CAN_UPGRADE': CAN_UPGRADE}
  13. # print('DEBUG', settings.DEBUG)
  14. urlpatterns = [
  15. re_path(r"^static/(?P<path>.*)$", serve_static),
  16. # re_path(r"^media/(?P<path>.*)$", static.serve, {"document_root": settings.MEDIA_ROOT}),
  17. path('robots.txt', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'robots.txt'}),
  18. path('favicon.ico', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'favicon.ico'}),
  19. path('docs/', RedirectView.as_view(url='https://github.com/ArchiveBox/ArchiveBox/wiki'), name='Docs'),
  20. path('public/', PublicIndexView.as_view(), name='public-index'),
  21. path('archive/', RedirectView.as_view(url='/')),
  22. path('archive/<path:path>', SnapshotView.as_view(), name='Snapshot'),
  23. path('admin/core/snapshot/add/', RedirectView.as_view(url='/add/')),
  24. path('add/', AddView.as_view(), name='add'),
  25. path("jobs/", JobsDashboardView.as_view(), name='jobs_dashboard'),
  26. path('accounts/login/', RedirectView.as_view(url='/admin/login/')),
  27. path('accounts/logout/', RedirectView.as_view(url='/admin/logout/')),
  28. path('accounts/', include('django.contrib.auth.urls')),
  29. path('admin/', archivebox_admin.urls),
  30. path("api/", include('api.urls'), name='api'),
  31. path('health/', HealthCheckView.as_view(), name='healthcheck'),
  32. path('error/', lambda *_: 1/0), # type: ignore
  33. # path('jet_api/', include('jet_django.urls')), Enable to use https://www.jetadmin.io/integrations/django
  34. path('index.html', RedirectView.as_view(url='/')),
  35. path('', HomepageView.as_view(), name='Home'),
  36. ]
  37. if settings.DEBUG_TOOLBAR:
  38. urlpatterns += [path('__debug__/', include("debug_toolbar.urls"))]
  39. if settings.DEBUG_REQUESTS_TRACKER:
  40. urlpatterns += [path("__requests_tracker__/", include("requests_tracker.urls"))]
  41. # # Proposed FUTURE URLs spec
  42. # path('', HomepageView)
  43. # path('/add', AddView)
  44. # path('/public', PublicIndexView)
  45. # path('/snapshot/:slug', SnapshotView)
  46. # path('/admin', admin.site.urls)
  47. # path('/accounts', django.contrib.auth.urls)
  48. # # Prposed REST API spec
  49. # # :slugs can be uuid, short_uuid, or any of the unique index_fields
  50. # path('api/v1/'),
  51. # path('api/v1/core/' [GET])
  52. # path('api/v1/core/snapshot/', [GET, POST, PUT]),
  53. # path('api/v1/core/snapshot/:slug', [GET, PATCH, DELETE]),
  54. # path('api/v1/core/archiveresult', [GET, POST, PUT]),
  55. # path('api/v1/core/archiveresult/:slug', [GET, PATCH, DELETE]),
  56. # path('api/v1/core/tag/', [GET, POST, PUT]),
  57. # path('api/v1/core/tag/:slug', [GET, PATCH, DELETE]),
  58. # path('api/v1/cli/', [GET])
  59. # path('api/v1/cli/{add,list,config,...}', [POST]), # pass query as kwargs directly to `run_subcommand` and return stdout, stderr, exitcode
  60. # path('api/v1/extractors/', [GET])
  61. # path('api/v1/extractors/:extractor/', [GET]),
  62. # path('api/v1/extractors/:extractor/:func', [GET, POST]), # pass query as args directly to chosen function
  63. # future, just an idea:
  64. # path('api/v1/scheduler/', [GET])
  65. # path('api/v1/scheduler/task/', [GET, POST, PUT]),
  66. # path('api/v1/scheduler/task/:slug', [GET, PATCH, DELETE]),