urls.py 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. __package__ = 'archivebox.core'
  2. from django.urls import path, include
  3. from django.views import static
  4. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  5. from django.conf import settings
  6. from django.views.generic.base import RedirectView
  7. from .admin import archivebox_admin
  8. from .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 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. path('public/', PublicIndexView.as_view(), name='public-index'),
  15. path('robots.txt', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'robots.txt'}),
  16. path('favicon.ico', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'favicon.ico'}),
  17. path('docs/', RedirectView.as_view(url='https://github.com/ArchiveBox/ArchiveBox/wiki'), name='Docs'),
  18. path('archive/', RedirectView.as_view(url='/')),
  19. path('archive/<path:path>', SnapshotView.as_view(), name='Snapshot'),
  20. path('admin/core/snapshot/add/', RedirectView.as_view(url='/add/')),
  21. path('add/', AddView.as_view(), name='add'),
  22. path('accounts/login/', RedirectView.as_view(url='/admin/login/')),
  23. path('accounts/logout/', RedirectView.as_view(url='/admin/logout/')),
  24. path('accounts/', include('django.contrib.auth.urls')),
  25. path('admin/', archivebox_admin.urls),
  26. path("api/", include('api.urls'), name='api'),
  27. path('health/', HealthCheckView.as_view(), name='healthcheck'),
  28. path('error/', lambda *_: 1/0),
  29. # path('jet_api/', include('jet_django.urls')), Enable to use https://www.jetadmin.io/integrations/django
  30. path('index.html', RedirectView.as_view(url='/')),
  31. path('index.json', static.serve, {'document_root': settings.CONFIG.OUTPUT_DIR, 'path': 'index.json'}),
  32. path('', HomepageView.as_view(), name='Home'),
  33. ]
  34. urlpatterns += staticfiles_urlpatterns()
  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]),