Mercurial > piecrust2
comparison piecrust/admin/views/menu.py @ 886:dcdec4b951a1
admin: Get the admin panel working again.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 20 Jun 2017 21:13:08 -0700 |
parents | 82509bce94ca |
children | 98430e7143d2 |
comparison
equal
deleted
inserted
replaced
885:13e8b50a2113 | 886:dcdec4b951a1 |
---|---|
1 from flask import g, request, url_for | 1 from flask import g, request, url_for |
2 from flask.ext.login import current_user | 2 from flask.ext.login import current_user |
3 from piecrust.sources.interfaces import IInteractiveSource | |
3 | 4 |
4 | 5 |
5 def get_menu_context(): | 6 def get_menu_context(): |
6 entries = [] | 7 entries = [] |
7 entries.append({ | 8 entries.append({ |
8 'url': '/', | 9 'url': '/', |
9 'title': "Dashboard", | 10 'title': "Dashboard", |
10 'icon': 'speedometer'}) | 11 'icon': 'speedometer'}) |
11 | 12 |
12 site = g.site.piecrust_app | 13 site = g.site.piecrust_app |
13 for s in site.sources: | 14 for source in site.sources: |
14 if s.is_theme_source: | 15 if source.is_theme_source: |
16 continue | |
17 if not isinstance(source, IInteractiveSource): | |
15 continue | 18 continue |
16 | 19 |
17 source_icon = s.config.get('admin_icon', 'document') | 20 # Figure out the icon to use... we do some hard-coded stuff to |
18 if s.name == 'pages': | 21 # have something vaguely pretty out of the box. |
19 source_icon = 'document-text' | 22 source_icon = source.config.get('admin_icon') |
20 elif 'blog' in s.name: | 23 if source_icon is None: |
21 source_icon = 'filing' | 24 if source.name == 'pages': |
25 source_icon = 'document-text' | |
26 elif 'blog' in source.name or 'posts' in source.name: | |
27 source_icon = 'filing' | |
28 else: | |
29 source_icon = 'document' | |
22 | 30 |
23 url_write = url_for('.write_page', source_name=s.name) | 31 url_write = url_for('.write_page', source_name=source.name) |
24 url_listall = url_for('.list_source', source_name=s.name) | 32 url_listall = url_for('.list_source', source_name=source.name) |
25 | 33 |
26 ctx = { | 34 ctx = { |
27 'url': url_listall, | 35 'url': url_listall, |
28 'title': s.name, | 36 'title': source.name, |
29 'icon': source_icon, | 37 'icon': source_icon, |
30 'quicklink': { | 38 'quicklink': { |
31 'icon': 'plus-round', | 39 'icon': 'plus-round', |
32 'url': url_write, | 40 'url': url_write, |
33 'title': "Write New" | 41 'title': "Write New" |
42 entries.append({ | 50 entries.append({ |
43 'url': url_for('.publish'), | 51 'url': url_for('.publish'), |
44 'title': "Publish", | 52 'title': "Publish", |
45 'icon': 'upload'}) | 53 'icon': 'upload'}) |
46 | 54 |
55 # TODO: re-enable settings UI at some point. | |
47 # entries.append({ | 56 # entries.append({ |
48 # 'url': url_for('.settings'), | 57 # 'url': url_for('.settings'), |
49 # 'title': "Settings", | 58 # 'title': "Settings", |
50 # 'icon': 'gear-b'}) | 59 # 'icon': 'gear-b'}) |
51 | 60 |