From b36f9c05071ea549ed59e703270fcf223b60df03 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 9 Apr 2017 09:02:09 +0200 Subject: Major rewrite to use jab/oauth. Highlights: - Uses the oauth branch of jab. - Changed design to use bootstrap. - Some minor changes to functionality in file uploading and listing. - API is currently disabled and incomplete. --- fbin/__init__.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 fbin/__init__.py (limited to 'fbin/__init__.py') diff --git a/fbin/__init__.py b/fbin/__init__.py new file mode 100644 index 0000000..bdeaa5d --- /dev/null +++ b/fbin/__init__.py @@ -0,0 +1,39 @@ +from flask import Flask, url_for, Markup, request +from flask_login import current_user +from werkzeug.routing import BaseConverter + +app = Flask(__name__) +app.config.from_pyfile('fbin.cfg') + +# Set up some custom converters. These are needed for file URLs to be properly parsed. + +class HashConverter(BaseConverter): + regex = r'\w+' + +class ExtensionConverter(BaseConverter): + regex = r'\.\w+' + +app.url_map.converters['hash'] = HashConverter +app.url_map.converters['ext'] = ExtensionConverter + +@app.context_processor +def context_processors(): + def nav_html(view, name=None): + url = url_for(view) + if not name: + name = view.rsplit('.', 1)[-1].replace('_', ' ').capitalize() + if view == '.logout': + name += ' [{}]'.format(current_user.username) + return Markup('{}'.format(' class="active"' if url == request.path else '', url, name)) + return { + 'nav_html': nav_html, + } + +with app.app_context(): + # TODO: Enable API when done + from .fbin import app as fbin + #from .api import app as api + from .login import login_manager + app.register_blueprint(fbin) + #app.register_blueprint(api, url_prefix = '/api') + login_manager.init_app(app) -- cgit v1.2.3