Mercurial > piecrust2
view piecrust/admin/views/publish.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
import copy import logging from flask import request, g, url_for, render_template, Response from flask.ext.login import login_required from ..blueprint import foodtruck_bp from ..pubutil import PublishLogReader from ..views import with_menu_context logger = logging.getLogger(__name__) @foodtruck_bp.route('/publish', methods=['GET', 'POST']) @login_required def publish(): if request.method == 'POST': target = request.form.get('target') if not target: raise Exception("No target specified.") g.site.publish(target) site = g.site pub_cfg = copy.deepcopy(site.piecrust_app.config.get('publish', {})) if not pub_cfg: data = {'error': "There are not publish targets defined in your " "configuration file."} return render_template('error.html', **data) data = {} data['url_run'] = url_for('.publish') data['site_title'] = site.piecrust_app.config.get('site/title', site.name) data['targets'] = [] for tn in sorted(pub_cfg.keys()): tc = pub_cfg[tn] desc = None if isinstance(tc, dict): desc = tc.get('description') data['targets'].append({ 'name': tn, 'description': desc }) with_menu_context(data) return render_template('publish.html', **data) @foodtruck_bp.route('/publish-log') @login_required def stream_publish_log(): pid_path = g.site.publish_pid_file log_path = g.site.publish_log_file rdr = PublishLogReader(pid_path, log_path) response = Response(rdr.run(), mimetype='text/event-stream') response.headers['Cache-Control'] = 'no-cache' return response