annotate piecrust/admin/views/preview.py @ 852:4850f8c21b6e

core: Start of the big refactor for PieCrust 3.0. * Everything is a `ContentSource`, including assets directories. * Most content sources are subclasses of the base file-system source. * A source is processed by a "pipeline", and there are 2 built-in pipelines, one for assets and one for pages. The asset pipeline is vaguely functional, but the page pipeline is completely broken right now. * Rewrite the baking process as just running appropriate pipelines on each content item. This should allow for better parallelization.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 17 May 2017 00:11:48 -0700
parents 82509bce94ca
children dcdec4b951a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
772
3885421c29a3 admin: Make the whole FoodTruck site into a blueprint.
Ludovic Chabant <ludovic@chabant.com>
parents: 704
diff changeset
1 from flask import current_app, g, make_response
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 from flask.ext.login import login_required
704
89ca8cdab020 admin: Fix crash when previewing a website.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
3 from piecrust.app import PieCrustFactory
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 from piecrust.serving.server import Server
772
3885421c29a3 admin: Make the whole FoodTruck site into a blueprint.
Ludovic Chabant <ludovic@chabant.com>
parents: 704
diff changeset
5 from ..blueprint import foodtruck_bp
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7
772
3885421c29a3 admin: Make the whole FoodTruck site into a blueprint.
Ludovic Chabant <ludovic@chabant.com>
parents: 704
diff changeset
8 @foodtruck_bp.route('/site/<sitename>/')
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 @login_required
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 def preview_site_root(sitename):
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 return preview_site(sitename, '/')
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13
772
3885421c29a3 admin: Make the whole FoodTruck site into a blueprint.
Ludovic Chabant <ludovic@chabant.com>
parents: 704
diff changeset
14 @foodtruck_bp.route('/site/<sitename>/<path:url>')
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 @login_required
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 def preview_site(sitename, url):
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 root_dir = g.sites.get_root_dir(sitename)
704
89ca8cdab020 admin: Fix crash when previewing a website.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
18 appfactory = PieCrustFactory(
812
82509bce94ca internal: PEP8 fixup for admin panel code.
Ludovic Chabant <ludovic@chabant.com>
parents: 778
diff changeset
19 root_dir,
82509bce94ca internal: PEP8 fixup for admin panel code.
Ludovic Chabant <ludovic@chabant.com>
parents: 778
diff changeset
20 cache_key='foodtruck',
82509bce94ca internal: PEP8 fixup for admin panel code.
Ludovic Chabant <ludovic@chabant.com>
parents: 778
diff changeset
21 debug=current_app.debug)
704
89ca8cdab020 admin: Fix crash when previewing a website.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
22 server = Server(appfactory,
89ca8cdab020 admin: Fix crash when previewing a website.
Ludovic Chabant <ludovic@chabant.com>
parents: 587
diff changeset
23 root_url='/site/%s/' % sitename)
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 return make_response(server._run_request)
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25