diff --git a/inside_gratipay.py b/inside_gratipay.py index da598cd..3296eab 100644 --- a/inside_gratipay.py +++ b/inside_gratipay.py @@ -1,14 +1,19 @@ import os import string import random -from os.path import basename, dirname, join, realpath, isdir +from os.path import basename, dirname from aspen import Response +from aspen.website import Website + import canonizer import gfm from nav import NavItem +website = Website(www_root='www', project_root='.') + + # Manually register markdown renderer to work around Heroku deployment woes. website.renderer_factories['markdown'] = gfm.Factory(website) website.renderer_factories['jinja2'].Renderer.global_context = { diff --git a/nav.py b/nav.py index 3824ba0..f59011b 100644 --- a/nav.py +++ b/nav.py @@ -6,12 +6,12 @@ from os.path import join, realpath, isfile, isdir, basename from aspen import resources -from aspen.resources.static_resource import StaticResource +from aspen.http.resource import Static def get_simplate_context(website, fs): resource = resources.get(website, fs) - return {} if isinstance(resource, StaticResource) else resource.pages[0] + return {} if isinstance(resource, Static) else resource.pages[0] class NavItem(OrderedDict): diff --git a/startapp.py b/startapp.py index c465812..07218bc 100644 --- a/startapp.py +++ b/startapp.py @@ -8,25 +8,18 @@ PORT = 8536 # default/devserver port import sys -from aspen.website import Website - -aspen_config = [ - '--www_root=www/', - '--project_root=.' -] - + for param in sys.argv: if param.startswith('--port'): _, PORT = param.split('=') PORT = int(PORT) - - + + # by WSGI convention, we need to create webapp object # and by default most WSGI servers look for 'application' -application = Website(aspen_config) - +from inside_gratipay import website as application + if __name__ == '__main__': from wsgiref.simple_server import make_server - print("* Running development server on http://%s:%s" % (HOST, PORT)) + print("* Running development server on http://%s:%s" % (HOST or 'localhost', PORT)) make_server(HOST, PORT, application).serve_forever() -