def why_hello_im(request, blog_dir, blog_url, image_url): entries = get_entries_cached(blog_dir, blog_url, image_url) entry, this_month, years = get_entry(entries, None, None, None) return { 'entries': entries, 'entry': entry, 'this_month': this_month, 'years': years, 'is_index': True, }
def named_article(request, blog_dir, blog_url, image_url, year, name): y = year and int(year) article = get_named_article(blog_dir, blog_url, image_url, y, name) entries = get_entries_cached(blog_dir, blog_url, image_url) # Needed for archive navigation entry, this_month, years = get_entry(entries, y, None, None) return { 'article': article, 'years': years, 'this_year_months': get_year_months(entries, y), }
def index_view(request, blog_dir, blog_url, image_url): entries = get_entries_cached(blog_dir, blog_url, image_url) entry, this_month, years = get_entry(entries, None, None, None) return { 'entries': entries, 'entry': entry, 'this_month': this_month, 'years': years, 'this_year_months': get_year_months(entries, entry.published.year), 'is_index': True, }
def test_react_data_for_entry(self): entry, this_month, years = get_entry(self.entries, 2010, 4, 18) react_data = self.entries.get_react_data(entry) expected = { 'minYear': 2008, 'maxYear': 2010, 'years': {2010: ANY}, } self.assertEqual(expected, react_data) expected2 = self.entries.get_react_year_data(2010) expected2['months'][1]['entries'][0]['isActive'] = True self.assertEqual(expected2, react_data['years'][2010])
def entry_view(request, blog_dir, blog_url, image_url, year, month, day): entries = get_entries_cached(blog_dir, blog_url, image_url) y = year and int(year) m = month and int(month, 10) d = day and int(day, 10) entry, this_month, years = get_entry(entries, y, m, d) return { 'entries': entries, 'entry': entry, 'this_month': this_month, 'years': years, 'this_year_months': get_year_months(entries, y), 'react_data_json': safestring.mark_safe(json.dumps(entries.get_react_data(entry))), 'is_index': False, }
def month_entries(request, blog_dir, blog_url, image_url, year=None, month=None): entries = get_entries_cached(blog_dir, blog_url, image_url) y = year and int(year) m = month and int(month, 10) d = None entry, this_month, years = get_entry(entries, y, m, d) return { 'entry': entry, 'entries': entries, 'this_month': this_month, 'prev': this_month[0].prev, 'next': this_month[-1].next, 'years': years, 'this_year_months': get_year_months(entries, y), }
def test_no_article_specified_gets_last_article(self): entry, this_month, years = get_entry(self.entries, None, None, None) self.assertEqual('B', entry.title) self.assertEqual(['A', 'B'], [x.title for x in this_month]) self.assertEqual(['E', 'D', 'B'], [x.title for x in years])
def test_get_article_by_date(self): entry, this_month, years = get_entry(self.entries, 2010, 4, 18) self.assertEqual('A', entry.title) self.assertEqual(['A', 'B'], [x.title for x in this_month]) self.assertEqual(['E', 'D', 'B'], [x.title for x in years])