Skip to content

Commit a1ccecd

Browse files
committed
Moved existing files into static-files, added vendor dir, manage.py, and wsgi script for updating on post-commit.
1 parent 2049606 commit a1ccecd

File tree

182 files changed

+104
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+104
-4
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "vendor"]
2+
path = vendor
3+
url = git://github.com/toolness/hackasaurus-lib.git

README.md

Lines changed: 10 additions & 1 deletion

manage.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import sys
2+
import os
3+
from wsgiref.util import shift_path_info
4+
5+
ROOT = os.path.dirname(os.path.abspath(__file__))
6+
7+
def path(*a):
8+
return os.path.join(ROOT, *a)
9+
10+
sys.path.insert(0, path('wsgi-scripts'))
11+
sys.path.insert(0, path('vendor'))
12+
13+
import hackbook_dot_hackasaurus_dot_org
14+
import jinja2
15+
from hackasaurus.management import execute_manager
16+
from hackasaurus.lamp_emulation import load_php
17+
18+
static_files_dir = path('static-files')
19+
20+
def handle_html_file_as_jinja2_template(root_dir, fullpath):
21+
loader = jinja2.FileSystemLoader(root_dir, encoding='utf-8')
22+
env = jinja2.Environment(loader=loader)
23+
template = env.get_template(fullpath[len(root_dir):])
24+
return ('text/html', template.render().encode('utf-8'))
25+
26+
def handle_php_file(root_dir, fullpath):
27+
return ('text/html', load_php(root_dir, fullpath))
28+
29+
def wsgi_api_handler(env, start):
30+
if env['PATH_INFO'].startswith('/wsgi/'):
31+
shift_path_info(env)
32+
return hackbook_dot_hackasaurus_dot_org.application(env, start)
33+
34+
if __name__ == '__main__':
35+
execute_manager(
36+
build_dir=path('build'),
37+
static_files_dir=static_files_dir,
38+
ext_handlers={
39+
'.html': handle_html_file_as_jinja2_template,
40+
'.php': handle_php_file
41+
},
42+
handlers=[wsgi_api_handler],
43+
default_filenames=['index.html', 'index.php'],
44+
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)