diff --git a/.gitignore b/.gitignore index b68caadc..1739a98e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ static/fonts/* .webassets-cache scss/assets .pytest_cache/ +.venv/ diff --git a/app.py b/app.py index 8c1f0c08..b4e36c1e 100755 --- a/app.py +++ b/app.py @@ -1,42 +1,11 @@ #!/usr/bin/env python +from atst.app import make_app 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(): - app = tornado.web.Application([ - (r"/", MainHandler), - ], - debug=os.getenv('DEBUG',False), - template_path=os.path.join(os.path.dirname(__file__), "templates"), - static_path=static_path - ) - return app - -if __name__ == "__main__": - app = make_app() - app.listen(8888) - print("Listening on http://localhost:8888") - tornado.ioloop.IOLoop.current().start() +app = make_app(debug=os.getenv('DEBUG',False)) +port = 8888 +app.listen(port) +print("Listening on http://localhost:%i" % port) +tornado.ioloop.IOLoop.current().start() diff --git a/atst/__init__.py b/atst/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/atst/app.py b/atst/app.py new file mode 100644 index 00000000..259a6539 --- /dev/null +++ b/atst/app.py @@ -0,0 +1,18 @@ +import tornado.web +from atst.handlers.main import MainHandler +from atst.home import home +from tornado.web import url + +def make_app(**kwargs): + app = tornado.web.Application([ + url( r"/", MainHandler, {'page': 'home'}, name='home' ), + url( r"/requests", MainHandler, {'page': 'requests'}, name='requests' ), + url( r"/users", MainHandler, {'page': 'users'}, name='users' ), + url( r"/reports", MainHandler, {'page': 'reports'}, name='reports' ), + url( r"/calculator", MainHandler, {'page': 'calculator'}, name='calculator' ), + ], + template_path = home.child('templates'), + static_path = home.child('static'), + **kwargs + ) + return app diff --git a/atst/handler.py b/atst/handler.py new file mode 100644 index 00000000..dd151c4c --- /dev/null +++ b/atst/handler.py @@ -0,0 +1,26 @@ +import os +from webassets import Environment, Bundle +import tornado.web +from atst.home import home + +# module variables used by the handlers + +assets = Environment( + directory = home.child('scss'), + url = '/static') +css = Bundle( + 'atat.scss', + filters = 'scss', + output = '../static/assets/out.css') + +assets.register( 'css', css ) +helpers = { + 'assets': assets +} + +class BaseHandler(tornado.web.RequestHandler): + + def get_template_namespace(self): + ns = super(BaseHandler, self).get_template_namespace() + ns.update(helpers) + return ns diff --git a/atst/handlers/__init__.py b/atst/handlers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/atst/handlers/main.py b/atst/handlers/main.py new file mode 100644 index 00000000..10b6780e --- /dev/null +++ b/atst/handlers/main.py @@ -0,0 +1,9 @@ +from atst.handler import BaseHandler + +class MainHandler(BaseHandler): + + def initialize(self,page): + self.page = page + + def get(self): + self.render( '%s.html.to' % self.page, page = self.page ) diff --git a/atst/home.py b/atst/home.py new file mode 100644 index 00000000..8d72d7c0 --- /dev/null +++ b/atst/home.py @@ -0,0 +1,3 @@ +from unipath import Path + +home = Path( __file__ ).parent.parent diff --git a/requirements.txt b/requirements.txt index fbddde00..470daaa4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ tornado==5.0.2 webassets==0.12.1 pytest==3.6.0 pytest-tornado==0.5.0 +Unipath==1.1 diff --git a/scss/atat.scss b/scss/atat.scss index b25f4223..65ec64a6 100644 --- a/scss/atat.scss +++ b/scss/atat.scss @@ -1,2 +1,2 @@ -@import 'variables.scss'; @import '../node_modules/uswds/src/stylesheets/uswds.scss'; +@import 'variables.scss'; \ No newline at end of file diff --git a/scss/variables.scss b/scss/variables.scss index 8b137891..e69de29b 100644 --- a/scss/variables.scss +++ b/scss/variables.scss @@ -1 +0,0 @@ - diff --git a/static/img/foo.png b/static/img/foo.png new file mode 100644 index 00000000..64a689a0 Binary files /dev/null and b/static/img/foo.png differ diff --git a/static/img/logo.png b/static/img/logo.png new file mode 100644 index 00000000..49909d23 Binary files /dev/null and b/static/img/logo.png differ diff --git a/templates/base.html.to b/templates/base.html.to index b50fb5c0..63643cd9 100644 --- a/templates/base.html.to +++ b/templates/base.html.to @@ -4,25 +4,23 @@