2017-10-24 21:01:52 -04:00
|
|
|
from django.conf.urls import url
|
2018-03-06 23:46:21 -05:00
|
|
|
from . import kinds
|
|
|
|
from .views import feeds, lists, perma
|
2017-10-27 01:16:08 -04:00
|
|
|
from lemoncurry import breadcrumbs as crumbs
|
|
|
|
|
|
|
|
|
2017-10-27 23:01:31 -04:00
|
|
|
def to_pat(*args):
|
|
|
|
return '^{0}$'.format(''.join(args))
|
2017-10-27 01:16:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
def prefix(route):
|
|
|
|
return app_name + ':' + route
|
|
|
|
|
2017-10-24 21:01:52 -04:00
|
|
|
|
2017-12-12 17:56:18 -05:00
|
|
|
page = '(?:/page/(?P<page>\d+))?'
|
2017-12-12 02:35:13 -05:00
|
|
|
slug = r'/(?P<slug>[^/]+)'
|
|
|
|
|
2017-10-24 21:01:52 -04:00
|
|
|
app_name = 'entries'
|
2017-10-31 18:29:59 -04:00
|
|
|
urlpatterns = [
|
2017-11-12 21:16:46 -05:00
|
|
|
url('^atom$', feeds.AtomHomeEntries(), name='atom'),
|
|
|
|
url('^rss$', feeds.RssHomeEntries(), name='rss'),
|
2018-03-06 23:46:21 -05:00
|
|
|
url(to_pat('cats', slug, page), lists.by_cat, name='cat'),
|
2017-10-31 18:29:59 -04:00
|
|
|
]
|
2017-11-19 19:09:30 -05:00
|
|
|
crumbs.add(prefix('cat'), parent='home:index')
|
2017-11-19 18:59:03 -05:00
|
|
|
|
2017-12-12 02:35:13 -05:00
|
|
|
slug = '(?:' + slug + ')?'
|
|
|
|
|
2017-10-24 21:01:52 -04:00
|
|
|
for k in kinds.all:
|
2017-10-27 01:16:08 -04:00
|
|
|
kind = k.plural
|
2017-10-27 23:01:31 -04:00
|
|
|
id = r'/(?P<id>\d+)'
|
2017-10-27 01:16:08 -04:00
|
|
|
urlpatterns += (
|
2018-03-06 23:46:21 -05:00
|
|
|
url(to_pat(kind, page), lists.by_kind, name=k.index, kwargs={'kind': k}),
|
2017-10-31 18:29:59 -04:00
|
|
|
url(to_pat(kind, '/atom'), feeds.AtomByKind(k), name=k.atom),
|
|
|
|
url(to_pat(kind, '/rss'), feeds.RssByKind(k), name=k.rss),
|
2018-03-06 23:46:21 -05:00
|
|
|
url(to_pat(kind, id, slug, '/amp'), perma.entry_amp, name=k.entry_amp),
|
|
|
|
url(to_pat(kind, id, slug), perma.entry, name=k.entry),
|
2017-10-24 21:31:08 -04:00
|
|
|
)
|
|
|
|
|
2017-10-27 01:16:08 -04:00
|
|
|
crumbs.add(prefix(k.index), label=k.plural, parent='home:index')
|
|
|
|
crumbs.add(prefix(k.entry), parent=prefix(k.index))
|