diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..93e14570 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +.sass-cache/ +static/fonts/* +.webassets-cache +scss/assets diff --git a/app.py b/app.py index e5dbda82..9acd810c 100755 --- a/app.py +++ b/app.py @@ -3,19 +3,37 @@ import tornado.ioloop import tornado.web import os +from webassets import Environment, Bundle + +# Set up assets. +static_path = os.path.join(os.path.dirname(__file__), "static") +scss_path = os.path.join(os.path.dirname(__file__), "scss") +assets = Environment(directory=scss_path, url='/static') +css = Bundle('atat.scss', output='assets/out.css') +assets.register('css', css) +helpers = { + 'assets': assets +} class MainHandler(tornado.web.RequestHandler): + + def get_template_namespace(self): + ns = super(MainHandler, self).get_template_namespace() + ns.update(helpers) + return ns + def get(self): self.render("hello.html.to") def make_app(): - return tornado.web.Application([ + app = tornado.web.Application([ (r"/", MainHandler), ], debug=os.getenv('DEBUG',False), template_path=os.path.join(os.path.dirname(__file__), "templates"), - static_path=os.path.join(os.path.dirname(__file__), "static"), + static_path=static_path ) + return app if __name__ == "__main__": app = make_app() diff --git a/requirements.txt b/requirements.txt index 041ebcb4..69d97d96 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ tornado==5.0.2 +webassets==0.12.1 diff --git a/templates/base.html.to b/templates/base.html.to index 6d6f0b98..b097ce5f 100644 --- a/templates/base.html.to +++ b/templates/base.html.to @@ -4,7 +4,9 @@