diff --git a/realms/config/__init__.py b/realms/config/__init__.py index ebf6829..d54bfe0 100644 --- a/realms/config/__init__.py +++ b/realms/config/__init__.py @@ -122,6 +122,7 @@ WIKI_HOME = 'home' ALLOW_ANON = True REGISTRATION_ENABLED = True +PRIVATE_WIKI = False # None, firepad, and/or togetherjs COLLABORATION = 'togetherjs' diff --git a/realms/modules/wiki/views.py b/realms/modules/wiki/views.py index 6ce93b2..3fda3cb 100644 --- a/realms/modules/wiki/views.py +++ b/realms/modules/wiki/views.py @@ -8,6 +8,9 @@ blueprint = Blueprint('wiki', __name__) @blueprint.route("/_commit//") def commit(name, sha): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + return current_app.login_manager.unauthorized() + cname = to_canonical(name) data = g.current_wiki.get_page(cname, sha=sha) @@ -20,6 +23,9 @@ def commit(name, sha): @blueprint.route("/_compare//") def compare(name, fsha, dots, lsha): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + return current_app.login_manager.unauthorized() + diff = g.current_wiki.compare(name, fsha, lsha) return render_template('wiki/compare.html', name=name, diff=diff, old=fsha, new=lsha) @@ -55,6 +61,9 @@ def revert(): @blueprint.route("/_history/") def history(name): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + return current_app.login_manager.unauthorized() + return render_template('wiki/history.html', name=name, history=g.current_wiki.get_history(name)) @@ -96,6 +105,9 @@ def create(name): @blueprint.route("/_index") def index(): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + return current_app.login_manager.unauthorized() + return render_template('wiki/index.html', index=g.current_wiki.get_index()) @@ -154,6 +166,9 @@ def page_write(name): @blueprint.route("/", defaults={'name': 'home'}) @blueprint.route("/") def page(name): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + return current_app.login_manager.unauthorized() + cname = to_canonical(name) if cname != name: return redirect(url_for('wiki.page', name=cname))