2017-10-24 21:01:52 -04:00
|
|
|
from django.conf.urls import url
|
2017-10-31 18:29:59 -04:00
|
|
|
from . import feeds, kinds, views
|
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
|
|
|
|
|
|
|
app_name = 'entries'
|
2017-10-31 18:29:59 -04:00
|
|
|
urlpatterns = [
|
|
|
|
url('^atom$', feeds.AtomAllEntries(), name='atom'),
|
|
|
|
url('^rss$', feeds.RssAllEntries(), name='rss'),
|
|
|
|
]
|
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+)'
|
|
|
|
slug = r'(?:/(?P<slug>.+))?'
|
2017-10-27 01:16:08 -04:00
|
|
|
urlpatterns += (
|
2017-10-27 23:01:31 -04:00
|
|
|
url(to_pat(kind), views.index, 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),
|
2017-10-27 23:01:31 -04:00
|
|
|
url(to_pat(kind, id, slug), views.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))
|