commit
141fcb83a9
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
.sass-cache/
|
||||
static/fonts/*
|
||||
.webassets-cache
|
||||
scss/assets
|
@ -9,7 +9,7 @@
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
npm install
|
||||
./gen-css
|
||||
gem install sass
|
||||
|
||||
## Running (development)
|
||||
|
||||
@ -17,10 +17,6 @@ To start the app and watch for changes:
|
||||
|
||||
DEBUG=1 ./app.py
|
||||
|
||||
To rebuild css whenever the scss changes:
|
||||
|
||||
./gen-css --watch
|
||||
|
||||
## Notes
|
||||
|
||||
tornado templates are like mustache templates -- add the
|
||||
|
22
app.py
22
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', filters='scss', output='../static/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()
|
||||
|
14
gen-css
14
gen-css
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
opts=$1
|
||||
|
||||
cp -a node_modules/uswds/dist/fonts static/
|
||||
|
||||
if [ "$opts" == "--watch" ]; then
|
||||
set -x
|
||||
sass --watch scss/atat.scss:static/assets/atat.css
|
||||
else
|
||||
set -x
|
||||
sass scss/atat.scss > static/assets/atat.css
|
||||
fi
|
||||
|
@ -1 +1,2 @@
|
||||
tornado==5.0.2
|
||||
webassets==0.12.1
|
||||
|
@ -4,7 +4,9 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>{% block title %}JEDI{% end %}</title>
|
||||
<link rel="stylesheet" href="static/assets/atat.css">
|
||||
{% for url in assets['css'].urls() %}
|
||||
<link rel="stylesheet" href="{{ url }}" type="text/css">
|
||||
{% end %}
|
||||
</head>
|
||||
<body>
|
||||
<header class="usa-header usa-header-basic" role="banner">
|
||||
@ -21,7 +23,6 @@
|
||||
these are not the droids you are looking for
|
||||
{% end %}
|
||||
</div>
|
||||
<script src="static/uswds-1.6.3/js/uswds.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user