urls.py 3.8 KB

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