mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
from django.contrib import admin
|
|
from django.urls import path, include
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.views.static import serve
|
|
from links.views import LinkDetailView, LinkUpdateView, CustomLinkView
|
|
from links.file_views import PublicFileView
|
|
from django.urls import path, include, re_path
|
|
from django.conf.urls.i18n import i18n_patterns
|
|
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
# Add API URLs before locale URLs
|
|
path('api/', include('links.api_urls')), # New line for API routes
|
|
# Media files
|
|
path('media/<path:path>', serve, {
|
|
'document_root': settings.MEDIA_ROOT,
|
|
}),
|
|
# Music files
|
|
path('music/<path:path>', serve, {
|
|
'document_root': settings.MUSIC_ROOT,
|
|
}),
|
|
path('i18n/', include('django.conf.urls.i18n')),
|
|
path('search/', include('links.search_urls')),
|
|
path('link/<int:pk>/', LinkDetailView.as_view(), name='link_detail'),
|
|
path('link/<int:pk>/edit/', LinkUpdateView.as_view(), name='link_update'),
|
|
path('custom/<slug:alias>/', CustomLinkView.as_view(), name='custom_link'),
|
|
path('custom/<slug:alias>/edit/', LinkUpdateView.as_view(), name='custom_link_update'),
|
|
|
|
# Include netscan and files BEFORE links.urls to prevent the alias catch-all from intercepting them
|
|
path('ui/netscan/', include('netscan.urls')),
|
|
path('ui/files/', include('links.file_urls')),
|
|
|
|
# Public file access — /public/files/{uuid}-{filename}
|
|
re_path(
|
|
r'^public/files/(?P<pk>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})-(?P<filename>.+)$',
|
|
PublicFileView.as_view(),
|
|
name='public-file',
|
|
),
|
|
|
|
# Include main app URLs with locale
|
|
path('', include('links.urls')),
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|