2024-03-25 17:46:01 -07:00
|
|
|
from .admin import archivebox_admin
|
2019-04-02 16:36:41 -04:00
|
|
|
|
2019-04-22 19:07:39 -04:00
|
|
|
from django.urls import path, include
|
2019-04-30 23:13:21 -04:00
|
|
|
from django.views import static
|
2021-02-16 04:16:24 -05:00
|
|
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
2019-04-22 19:07:39 -04:00
|
|
|
from django.conf import settings
|
2019-04-30 23:13:21 -04:00
|
|
|
from django.views.generic.base import RedirectView
|
2019-04-17 05:42:21 -04:00
|
|
|
|
2021-10-03 19:12:03 +02:00
|
|
|
from core.views import HomepageView, SnapshotView, PublicIndexView, AddView, HealthCheckView
|
2019-04-22 19:07:39 -04:00
|
|
|
|
2024-04-10 01:29:24 +02:00
|
|
|
from ninja import NinjaAPI
|
|
|
|
from api.auth import GlobalAuth
|
|
|
|
|
|
|
|
api = NinjaAPI(auth=GlobalAuth())
|
|
|
|
api.add_router("/auth/", "api.auth.router")
|
|
|
|
api.add_router("/archive/", "api.archive.router")
|
|
|
|
|
2024-01-03 16:11:27 -08:00
|
|
|
# GLOBAL_CONTEXT doesn't work as-is, disabled for now: https://github.com/ArchiveBox/ArchiveBox/discussions/1306
|
|
|
|
# from config import VERSION, VERSIONS_AVAILABLE, CAN_UPGRADE
|
|
|
|
# GLOBAL_CONTEXT = {'VERSION': VERSION, 'VERSIONS_AVAILABLE': VERSIONS_AVAILABLE, 'CAN_UPGRADE': CAN_UPGRADE}
|
2020-06-30 05:56:17 -04:00
|
|
|
|
2019-04-17 05:42:21 -04:00
|
|
|
|
2024-01-03 16:11:27 -08:00
|
|
|
# print('DEBUG', settings.DEBUG)
|
2023-12-19 09:58:15 -08:00
|
|
|
|
2019-04-02 16:36:41 -04:00
|
|
|
urlpatterns = [
|
2021-01-30 05:35:07 -05:00
|
|
|
path('public/', PublicIndexView.as_view(), name='public-index'),
|
|
|
|
|
2021-02-17 18:25:47 -05:00
|
|
|
path('robots.txt', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'robots.txt'}),
|
|
|
|
path('favicon.ico', static.serve, {'document_root': settings.STATICFILES_DIRS[0], 'path': 'favicon.ico'}),
|
2019-04-30 23:13:21 -04:00
|
|
|
|
2020-11-23 02:04:39 -05:00
|
|
|
path('docs/', RedirectView.as_view(url='https://github.com/ArchiveBox/ArchiveBox/wiki'), name='Docs'),
|
2020-07-27 23:56:35 -04:00
|
|
|
|
2019-04-30 23:13:21 -04:00
|
|
|
path('archive/', RedirectView.as_view(url='/')),
|
2021-02-18 02:38:30 -05:00
|
|
|
path('archive/<path:path>', SnapshotView.as_view(), name='Snapshot'),
|
2020-09-17 09:08:20 -05:00
|
|
|
|
|
|
|
path('admin/core/snapshot/add/', RedirectView.as_view(url='/add/')),
|
2021-01-30 05:35:07 -05:00
|
|
|
path('add/', AddView.as_view(), name='add'),
|
2021-10-03 19:12:03 +02:00
|
|
|
|
2019-05-02 19:15:16 -04:00
|
|
|
path('accounts/login/', RedirectView.as_view(url='/admin/login/')),
|
|
|
|
path('accounts/logout/', RedirectView.as_view(url='/admin/logout/')),
|
|
|
|
|
2020-06-30 05:56:17 -04:00
|
|
|
|
2019-04-22 19:07:39 -04:00
|
|
|
path('accounts/', include('django.contrib.auth.urls')),
|
2024-03-25 17:46:01 -07:00
|
|
|
path('admin/', archivebox_admin.urls),
|
2024-01-03 16:11:27 -08:00
|
|
|
|
2024-04-10 01:29:24 +02:00
|
|
|
path("api/", api.urls),
|
|
|
|
|
2021-10-03 19:12:03 +02:00
|
|
|
path('health/', HealthCheckView.as_view(), name='healthcheck'),
|
2023-09-14 02:41:27 -07:00
|
|
|
path('error/', lambda _: 1/0),
|
|
|
|
|
|
|
|
# path('jet_api/', include('jet_django.urls')), Enable to use https://www.jetadmin.io/integrations/django
|
2021-10-03 19:12:03 +02:00
|
|
|
|
2020-06-30 05:56:17 -04:00
|
|
|
path('index.html', RedirectView.as_view(url='/')),
|
|
|
|
path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}),
|
2021-01-30 05:35:17 -05:00
|
|
|
path('', HomepageView.as_view(), name='Home'),
|
2019-04-02 16:36:41 -04:00
|
|
|
]
|
2021-02-16 04:16:24 -05:00
|
|
|
urlpatterns += staticfiles_urlpatterns()
|
2021-01-30 05:35:17 -05:00
|
|
|
|
2021-02-16 02:50:05 -05:00
|
|
|
if settings.DEBUG_TOOLBAR:
|
|
|
|
import debug_toolbar
|
|
|
|
urlpatterns += [
|
|
|
|
path('__debug__/', include(debug_toolbar.urls)),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# # Proposed FUTURE URLs spec
|
|
|
|
# path('', HomepageView)
|
|
|
|
# path('/add', AddView)
|
|
|
|
# path('/public', PublicIndexView)
|
|
|
|
# path('/snapshot/:slug', SnapshotView)
|
|
|
|
|
|
|
|
# path('/admin', admin.site.urls)
|
|
|
|
# path('/accounts', django.contrib.auth.urls)
|
|
|
|
|
|
|
|
# # Prposed REST API spec
|
|
|
|
# # :slugs can be uuid, short_uuid, or any of the unique index_fields
|
|
|
|
# path('api/v1/'),
|
|
|
|
# path('api/v1/core/' [GET])
|
|
|
|
# path('api/v1/core/snapshot/', [GET, POST, PUT]),
|
|
|
|
# path('api/v1/core/snapshot/:slug', [GET, PATCH, DELETE]),
|
|
|
|
# path('api/v1/core/archiveresult', [GET, POST, PUT]),
|
|
|
|
# path('api/v1/core/archiveresult/:slug', [GET, PATCH, DELETE]),
|
|
|
|
# path('api/v1/core/tag/', [GET, POST, PUT]),
|
|
|
|
# path('api/v1/core/tag/:slug', [GET, PATCH, DELETE]),
|
|
|
|
|
|
|
|
# path('api/v1/cli/', [GET])
|
|
|
|
# path('api/v1/cli/{add,list,config,...}', [POST]), # pass query as kwargs directly to `run_subcommand` and return stdout, stderr, exitcode
|
|
|
|
|
|
|
|
# path('api/v1/extractors/', [GET])
|
|
|
|
# path('api/v1/extractors/:extractor/', [GET]),
|
|
|
|
# path('api/v1/extractors/:extractor/:func', [GET, POST]), # pass query as args directly to chosen function
|
|
|
|
|
|
|
|
# future, just an idea:
|
|
|
|
# path('api/v1/scheduler/', [GET])
|
|
|
|
# path('api/v1/scheduler/task/', [GET, POST, PUT]),
|
|
|
|
# path('api/v1/scheduler/task/:slug', [GET, PATCH, DELETE]),
|