summaryrefslogtreecommitdiff
path: root/app/jrnl/urls.py
blob: 2b1703361558f14b10d43ef682aef4798c427abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from django.conf.urls import url
from django.views.generic.base import RedirectView

from . import views

urlpatterns = [
    url(
        regex=r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+).txt$',
        view=views.EntryDetailViewTXT.as_view(),
        name="detail-txt"
    ),
    url(
        regex=r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+).amp$',
        view=views.EntryDetailViewAMP.as_view(),
        name="detail-amp"
    ),
    url(
        regex=r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)$',
        view=views.EntryDetailView.as_view(),
        name="detail"
    ),
    url(
        regex=r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$',
        view=views.EntryMonthArchiveView.as_view(month_format='%m'),
        name="list_month"
    ),
    url(
        regex=r'(?P<year>\d{4})/$',
        view=views.EntryYearArchiveView.as_view(),
        name="list_year"
    ),
    url(
        regex=r'(?P<slug>[-\w]+)/(?P<page>\d+)/$',
        view=views.EntryCountryList.as_view(),
        name="list_country"
    ),
    url(
        regex=r'(?P<page>\d+)/$',
        view=views.EntryList.as_view(),
        name="list"
    ),
    # redirect /slug/ to /slug/1/ for live server
    url(
        regex=r'(?P<slug>[-\w]+)/$',
        view=RedirectView.as_view(url="/jrnl/%(slug)s/1/", permanent=False),
        name="live_location_redirect"
    ),
    # redirect / to /1/ for live server
    url(
        regex=r'',
        view=RedirectView.as_view(url="/jrnl/1/", permanent=False),
        name="live_redirect"
    ),
]