Mercurial > piecrust2
comparison foodtruck/views/sources.py @ 657:c1a94e1beb9d
admin: Show a more classic blog post listing in FoodTruck.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 25 Feb 2016 22:30:16 -0800 |
parents | efc1dc916e7c |
children | 3885421c29a3 |
comparison
equal
deleted
inserted
replaced
656:dba53f0f7671 | 657:c1a94e1beb9d |
---|---|
14 source = site.getSource(source_name) | 14 source = site.getSource(source_name) |
15 if source is None: | 15 if source is None: |
16 abort(400) | 16 abort(400) |
17 | 17 |
18 i = 0 | 18 i = 0 |
19 default_author = site.config.get('site/author') | |
19 data = {'title': "List %s" % source_name} | 20 data = {'title': "List %s" % source_name} |
20 data['pages'] = [] | 21 data['pages'] = [] |
21 pgn = Paginator(None, source, page_num=page_num, items_per_page=20) | 22 pgn = Paginator(None, source, page_num=page_num, items_per_page=20) |
22 for p in pgn.items: | 23 for p in pgn.items: |
23 page_data = { | 24 page_data = { |
24 'title': p['title'], | 25 'title': p['title'], |
26 'author': p.get('author', default_author), | |
25 'slug': p['slug'], | 27 'slug': p['slug'], |
28 'timestamp': p['timestamp'], | |
29 'tags': p.get('tags', []), | |
30 'category': p.get('category'), | |
26 'source': source_name, | 31 'source': source_name, |
27 'url': url_for('edit_page', slug=p['slug']), | 32 'url': url_for('edit_page', slug=p['slug']) |
28 'text': text_preview(html_to_text(p['content']), length=300)} | 33 } |
29 data['pages'].append(page_data) | 34 data['pages'].append(page_data) |
30 | 35 |
31 prev_page_url = None | 36 prev_page_url = None |
32 if pgn.prev_page_number: | 37 if pgn.prev_page_number: |
33 prev_page_url = url_for( | 38 prev_page_url = url_for( |