urls.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. from django.contrib import admin
  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 core.views import HomepageView, SnapshotView, PublicIndexView, AddView, HealthCheckView
  8. # GLOBAL_CONTEXT doesn't work as-is, disabled for now: https://github.com/ArchiveBox/ArchiveBox/discussions/1306
  9. # from config import VERSION, VERSIONS_AVAILABLE, CAN_UPGRADE
  10. # GLOBAL_CONTEXT = {'VERSION': VERSION, 'VERSIONS_AVAILABLE': VERSIONS_AVAILABLE, 'CAN_UPGRADE': CAN_UPGRADE}
  11. # print('DEBUG', settings.DEBUG)
  12. urlpatterns = [
  13. path('public/', PublicIndexView.as_view(), name='public-index'),
  14. path('robots.txt', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'robots.txt'}),
  15. path('favicon.ico', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'favicon.ico'}),
  16. path('docs/', RedirectView.as_view(url='https://github.com/ArchiveBox/ArchiveBox/wiki'), name='Docs'),
  17. path('archive/', RedirectView.as_view(url='/')),
  18. path('archive/<path:path>', SnapshotView.as_view(), name='Snapshot'),
  19. path('admin/core/snapshot/add/', RedirectView.as_view(url='/add/')),
  20. path('add/', AddView.as_view(), name='add'),
  21. path('accounts/login/', RedirectView.as_view(url='/admin/login/')),
  22. path('accounts/logout/', RedirectView.as_view(url='/admin/logout/')),
  23. path('accounts/', include('django.contrib.auth.urls')),
  24. path('admin/', admin.site.urls),
  25. # do not add extra_context like this as not all admin views (e.g. ModelAdmin.autocomplete_view accept extra kwargs)
  26. # path('admin/', admin.site.urls, {'extra_context': GLOBAL_CONTEXT}),
  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.OUTPUT_DIR, 'path': 'index.json'}),
  32. path('', HomepageView.as_view(), name='Home'),
  33. ]
  34. urlpatterns += staticfiles_urlpatterns()
  35. if settings.DEBUG_TOOLBAR:
  36. import debug_toolbar
  37. urlpatterns += [
  38. path('__debug__/', include(debug_toolbar.urls)),
  39. ]
  40. # # Proposed FUTURE URLs spec
  41. # path('', HomepageView)
  42. # path('/add', AddView)
  43. # path('/public', PublicIndexView)
  44. # path('/snapshot/:slug', SnapshotView)
  45. # path('/admin', admin.site.urls)
  46. # path('/accounts', django.contrib.auth.urls)
  47. # # Prposed REST API spec
  48. # # :slugs can be uuid, short_uuid, or any of the unique index_fields
  49. # path('api/v1/'),
  50. # path('api/v1/core/' [GET])
  51. # path('api/v1/core/snapshot/', [GET, POST, PUT]),
  52. # path('api/v1/core/snapshot/:slug', [GET, PATCH, DELETE]),
  53. # path('api/v1/core/archiveresult', [GET, POST, PUT]),
  54. # path('api/v1/core/archiveresult/:slug', [GET, PATCH, DELETE]),
  55. # path('api/v1/core/tag/', [GET, POST, PUT]),
  56. # path('api/v1/core/tag/:slug', [GET, PATCH, DELETE]),
  57. # path('api/v1/cli/', [GET])
  58. # path('api/v1/cli/{add,list,config,...}', [POST]), # pass query as kwargs directly to `run_subcommand` and return stdout, stderr, exitcode
  59. # path('api/v1/extractors/', [GET])
  60. # path('api/v1/extractors/:extractor/', [GET]),
  61. # path('api/v1/extractors/:extractor/:func', [GET, POST]), # pass query as args directly to chosen function
  62. # future, just an idea:
  63. # path('api/v1/scheduler/', [GET])
  64. # path('api/v1/scheduler/task/', [GET, POST, PUT]),
  65. # path('api/v1/scheduler/task/:slug', [GET, PATCH, DELETE]),