From 9743af7f9316fc75e75d6fe1fd75aa88bd4f6bcc Mon Sep 17 00:00:00 2001 From: Emre Yilmaz Date: Tue, 28 Jun 2016 10:56:49 +0300 Subject: [PATCH] Refactor theme selection logic on web ui. --- storm/__main__.py | 2 +- storm/web.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/storm/__main__.py b/storm/__main__.py index 8381cac..7f0b323 100644 --- a/storm/__main__.py +++ b/storm/__main__.py @@ -295,7 +295,7 @@ def backup(target_file, config=None): @command('web') @arg('port', nargs='?', default=9002, type=int) -@arg('theme', nargs='?', default="modern") +@arg('theme', nargs='?', default="modern", choices=['modern', 'black', 'storm']) @arg('debug', action='store_true', default=False) def web(port, debug=False, theme="modern", ssh_config=None): """Starts the web UI.""" diff --git a/storm/web.py b/storm/web.py index 8b6133b..2661d90 100644 --- a/storm/web.py +++ b/storm/web.py @@ -11,16 +11,15 @@ app = Flask(__name__) __THEME__ = "modern" + def render(template, theme): static_dir = os.path.dirname(os.path.abspath(__file__)) path = os.path.join(static_dir, 'templates', template) with open(path) as fobj: content = fobj.read() - if 'theme' in request.args: - theme = request.args.get('theme') + content = content.replace('__THEME__', request.args.get('theme', theme)) - content = content.replace("__THEME__", theme) return make_response(content)