2011-10-05 21:35:41 +00:00
|
|
|
from jinja2 import Environment, FileSystemLoader
|
2012-06-01 21:15:42 +00:00
|
|
|
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, send_from_directory, safe_join
|
|
|
|
import os.path
|
|
|
|
import fileinput
|
|
|
|
|
|
|
|
|
|
|
|
TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'pages')
|
|
|
|
MEETINGS_DIR = os.path.join(os.path.dirname(__file__), 'meetings')
|
|
|
|
|
|
|
|
app = application = Flask(__name__, template_folder=TEMPLATE_DIR)
|
|
|
|
app.debug = bool(os.environ.get('APP_DEBUG', 'False'))
|
|
|
|
|
2011-10-05 21:35:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.url_value_preprocessor
|
|
|
|
def pull_lang(endpoint, values):
|
|
|
|
if not values:
|
|
|
|
return
|
|
|
|
g.lang=values.pop('lang', None)
|
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/')
|
2011-10-05 21:35:41 +00:00
|
|
|
def main_index():
|
2012-06-01 21:15:42 +00:00
|
|
|
return redirect(url_for('site_show', lang='en'))
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/site/')
|
|
|
|
@app.route('/<string:lang>/site/<path:page>')
|
2011-10-05 21:35:41 +00:00
|
|
|
def site_show(page=''):
|
|
|
|
# TODO: set content_type
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/meetings/')
|
2011-10-05 21:35:41 +00:00
|
|
|
def meetings_index():
|
|
|
|
return render_template('meetings/index.html')
|
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/meetings/<int:id>')
|
|
|
|
def meetings_show(id, raw=False):
|
|
|
|
"""
|
|
|
|
Render the meeting X.
|
|
|
|
Either display the raw IRC .log or render as html and include .rst as header if it exists
|
|
|
|
"""
|
|
|
|
# generate file name for the raw meeting file(and header)
|
|
|
|
lname = str(id) + '.log'
|
|
|
|
hname = str(id) + '.rst'
|
|
|
|
lfile = safe_join(MEETINGS_DIR, lname)
|
|
|
|
hfile = safe_join(MEETINGS_DIR, hname)
|
|
|
|
|
|
|
|
# check if meeting file exists and throw error if it does not..
|
|
|
|
if not os.path.exists(lfile):
|
|
|
|
abort(404)
|
|
|
|
|
|
|
|
log=''
|
|
|
|
header=None
|
|
|
|
|
|
|
|
# load log
|
|
|
|
with open(lfile, 'rb') as fd:
|
|
|
|
log = fd.read()
|
|
|
|
|
|
|
|
# now try to load header if that makes sense
|
|
|
|
if os.path.exists(hfile):
|
|
|
|
with open(hfile, 'rb') as fd:
|
|
|
|
header = fd.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# now only rendering left to do
|
|
|
|
if raw:
|
|
|
|
# hmm... maybe replace with something non-render_template like?
|
|
|
|
# return render_template('meetings/show_raw.html', log=log)
|
|
|
|
return send_from_directory(MEETINGS_DIR, lname, mimetype='text/plain')
|
|
|
|
else:
|
|
|
|
return render_template('meetings/show.html', log=log, header=header)
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/<string:lang>/meetings/<int:id>/raw')
|
2011-10-05 21:35:41 +00:00
|
|
|
def meetings_show_raw(id):
|
2012-06-01 21:15:42 +00:00
|
|
|
return meetings_show(id, raw=True)
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/download')
|
2011-10-05 21:35:41 +00:00
|
|
|
def downloads_list():
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/download/<path:file>')
|
2011-10-05 21:35:41 +00:00
|
|
|
def downloads_select(file):
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/download/<string:protocol>/any/<path:file>')
|
|
|
|
@app.route('/download/<string:protocol>/<string:mirror>/<path:file>')
|
2011-10-05 21:35:41 +00:00
|
|
|
def downloads_redirect(protocol, file, mirror=None):
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/blog/')
|
|
|
|
@app.route('/<string:lang>/blog/page/<int:page>')
|
2011-10-05 21:35:41 +00:00
|
|
|
def blog_index(page=0):
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/<string:lang>/blog/entry/<path:slug>')
|
2011-10-05 21:35:41 +00:00
|
|
|
def blog_entry(slug):
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/feed/blog/rss')
|
2011-10-05 21:35:41 +00:00
|
|
|
def blog_rss():
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/feed/blog/atom')
|
2011-10-05 21:35:41 +00:00
|
|
|
def blog_atom():
|
|
|
|
# TODO: implement
|
2012-06-01 21:15:42 +00:00
|
|
|
pass
|
2011-10-05 21:35:41 +00:00
|
|
|
|
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
## legacy stuff:
|
|
|
|
|
|
|
|
@app.route('/meeting<int:id>')
|
|
|
|
@app.route('/meeting<int:id>.html')
|
2011-10-05 21:35:41 +00:00
|
|
|
def legacy_meeting(id):
|
|
|
|
redirect(url_for('meetings_show', id=id, lang='en'))
|
|
|
|
|
2012-06-01 21:15:42 +00:00
|
|
|
@app.route('/status-<int:year>-<int:month>-<int:day>')
|
|
|
|
@app.route('/status-<int:year>-<int:month>-<int:day>.html')
|
2011-10-05 21:35:41 +00:00
|
|
|
def legacy_status(year, month, day):
|
|
|
|
redirect(url_for('blog_entry', lang='en', slug=('%s/%s/%s/status' % (year, month, day))))
|
2012-06-01 21:15:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.route('/<string:f>')
|
|
|
|
def legacy_show(f):
|
|
|
|
# TODO: redirect to correct new url
|
|
|
|
pass
|