Mercurial > wikked
changeset 335:cc038c636901
Better 'dev' server mode by serving some assets from their original folder.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 19 Apr 2015 20:54:10 -0700 |
parents | be7275021f3a |
children | 03e3e793fa22 |
files | wikked/templates/index-dev.html wikked/web.py |
diffstat | 2 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/wikked/templates/index-dev.html Sun Apr 19 19:58:49 2015 -0700 +++ b/wikked/templates/index-dev.html Sun Apr 19 20:54:10 2015 -0700 @@ -11,10 +11,10 @@ </div> <script type="text/javascript"> var require = { - baseUrl: "/static/", - deps: ["/static/js/wikked.js{{cache_bust}}"] + baseUrl: "/dev-assets/", + deps: ["/dev-assets/js/wikked.js"] }; </script> - <script src="/static/js/require.js"></script> + <script src="/dev-assets/js/require.js"></script> </body> </html>
--- a/wikked/web.py Sun Apr 19 19:58:49 2015 -0700 +++ b/wikked/web.py Sun Apr 19 20:54:10 2015 -0700 @@ -1,6 +1,7 @@ import os import os.path import logging +from werkzeug import SharedDataMiddleware from flask import Flask, abort, g from wikked.wiki import Wiki, WikiParameters @@ -54,13 +55,18 @@ # Make the app serve static content and wiki assets in DEBUG mode. if app.config['WIKI_DEV_ASSETS'] or app.config['WIKI_SERVE_FILES']: - from werkzeug import SharedDataMiddleware - import os app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { '/files': os.path.join(wiki_root, '_files') }) +# In DEBUG mode, also serve raw assets instead of static ones. +if app.config['WIKI_DEV_ASSETS']: + assets_folder = os.path.join(os.path.dirname(__file__), 'assets') + app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { + '/dev-assets': assets_folder}) + + # Profiling if app.config['PROFILE']: profile_dir = app.config['PROFILE_DIR']