Mercurial > piecrust2
view piecrust/admin/views/menu.py @ 853:f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
The asset pipeline is still the only function pipeline at this point.
* No more `QualifiedPage`, and several other pieces of code deleted.
* Data providers are simpler and more focused. For instance, the page iterator
doesn't try to support other types of items.
* Route parameters are proper known source metadata to remove the confusion
between the two.
* Make the baker and pipeline more correctly manage records and record
histories.
* Add support for record collapsing and deleting stale outputs in the asset
pipeline.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 21 May 2017 00:06:59 -0700 |
parents | 82509bce94ca |
children | dcdec4b951a1 |
line wrap: on
line source
from flask import g, request, url_for from flask.ext.login import current_user def get_menu_context(): entries = [] entries.append({ 'url': '/', 'title': "Dashboard", 'icon': 'speedometer'}) site = g.site.piecrust_app for s in site.sources: if s.is_theme_source: continue source_icon = s.config.get('admin_icon', 'document') if s.name == 'pages': source_icon = 'document-text' elif 'blog' in s.name: source_icon = 'filing' url_write = url_for('.write_page', source_name=s.name) url_listall = url_for('.list_source', source_name=s.name) ctx = { 'url': url_listall, 'title': s.name, 'icon': source_icon, 'quicklink': { 'icon': 'plus-round', 'url': url_write, 'title': "Write New" }, 'entries': [ {'url': url_listall, 'title': "List All"}, {'url': url_write, 'title': "Write New"} ] } entries.append(ctx) entries.append({ 'url': url_for('.publish'), 'title': "Publish", 'icon': 'upload'}) # entries.append({ # 'url': url_for('.settings'), # 'title': "Settings", # 'icon': 'gear-b'}) for e in entries: needs_more_break = False if 'entries' in e: for e2 in e['entries']: if e2['url'] == request.path: e['open'] = True e2['active'] = True needs_more_break = True break if needs_more_break: break if e['url'] == request.path: e['active'] = True break data = {'entries': entries, 'user': current_user, 'url_logout': url_for('.logout')} return data