-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from gratipay/no-more-config-scripts
rip out configure-aspen.py
- Loading branch information
Showing
23 changed files
with
121 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"""Configuration script for the http://aspen.io/ website. | ||
""" | ||
import os | ||
import os.path | ||
from aspen.configuration import parse | ||
from aspen.website import Website | ||
|
||
distribution_root = os.path.dirname(__file__) | ||
www_root = os.path.join(distribution_root, 'doc') | ||
project_root = os.path.join(www_root, '.aspen') | ||
website = Website(['--www_root', www_root, '--project_root', project_root]) | ||
opts = {} | ||
|
||
def add_stuff_to_request_context(website, dispatch_result): | ||
|
||
# Define some closures for generating image markup. | ||
# ================================================= | ||
|
||
def translate(src): | ||
if src[0] != '/': | ||
rel = os.path.dirname(dispatch_result.match)[len(website.www_root):] | ||
src = '/'.join([rel, src]) | ||
src = opts['base'] + src | ||
return src | ||
|
||
def img(src): | ||
src = translate(src) | ||
html = '<img src="%s" />' % src | ||
return html | ||
|
||
def screenshot(short, imgtype='png', href=''): | ||
"""Given foo, go with foo.small.png and foo.png. | ||
""" | ||
small = img(short + '.small.' + imgtype) | ||
if not href: | ||
href = translate(short + '.' + imgtype) | ||
html = ('<a title="Click for full size" href="%s"' | ||
'class="screencap">%s</a>') | ||
return html % (href, small) | ||
|
||
|
||
# Make these available within simplates. | ||
# ====================================== | ||
|
||
return { | ||
'img': img, | ||
'screenshot': screenshot, | ||
'translate': translate, | ||
'version': opts['version'], | ||
'homepage': False, | ||
'show_ga': opts['show_ga'], | ||
} | ||
|
||
|
||
opts['show_ga'] = parse.yes_no(os.environ.get( 'ASPEN_IO_SHOW_GA' | ||
, 'no' | ||
).decode('US-ASCII')) | ||
opts['base'] = '' | ||
|
||
# this is a dirty nasty hack. We should store the version in the aspen module somewhere | ||
opts['version'] = open(os.path.join(website.www_root,'..','version.txt')).read()[:-len('-dev')] | ||
|
||
# no idea why this doesn't work | ||
website.renderer_default = 'tornado' | ||
open('/tmp/debugout','a').write('doccnf:' + website.renderer_default + '\n') | ||
|
||
website.algorithm.insert_after('dispatch_request_to_filesystem', add_stuff_to_request_context) | ||
|
||
|
||
if __name__ == '__main__': | ||
from aspen import serve | ||
serve(website) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.