+ @property
+ def per_page(self):
+ return self.entries_per_page
+
+ def get_subpath(self, obj):
+ if isinstance(obj, BlogEntry):
+ if obj.blog == self.blog:
+ kwargs = {'slug': obj.slug}
+ if self.entry_permalink_style in 'DMY':
+ kwargs.update({'year': str(obj.date.year).zfill(4)})
+ if self.entry_permalink_style in 'DM':
+ kwargs.update({'month': str(obj.date.month).zfill(2)})
+ if self.entry_permalink_style == 'D':
+ kwargs.update({'day': str(obj.date.day).zfill(2)})
+ return reverse(self.entry_view, urlconf=self, kwargs=kwargs)
+ elif isinstance(obj, Tag):
+ if obj in self.blog.entry_tags:
+ return reverse('entries_by_tag', urlconf=self, kwargs={'tag_slugs': obj.slug})
+ elif isinstance(obj, (str, unicode)):
+ split_obj = obj.split(':')
+ if len(split_obj) > 1:
+ kwargs = {}
+ try:
+ kwargs.update({'year': str(int(split_obj[1])).zfill(4)})
+ if len(split_obj) > 2:
+ kwargs.update({'month': str(int(split_obj[2])).zfill(2)})
+ if len(split_obj) > 3:
+ kwargs.update({'day': str(int(split_obj[3])).zfill(2)})
+ return reverse('entries_by_day', urlconf=self, kwargs=kwargs)
+ return reverse('entries_by_month', urlconf=self, kwargs=kwargs)
+ return reverse('entries_by_year', urlconf=self, kwargs=kwargs)
+ except:
+ pass
+ raise ViewCanNotProvideSubpath
+
+ def get_context(self):
+ return {'blog': self.blog}
+