diff options
-rw-r--r-- | apioforum/__init__.py | 10 | ||||
-rw-r--r-- | apioforum/templates/base.html | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/apioforum/__init__.py b/apioforum/__init__.py index 7baa7c1..c4348a3 100644 --- a/apioforum/__init__.py +++ b/apioforum/__init__.py @@ -1,7 +1,7 @@ # boilerplate boilerplate boilerplate # yay -from flask import Flask +from flask import Flask, request from .db import get_db import os @@ -32,6 +32,14 @@ def create_app(): from .fuzzy import fuzzy app.jinja_env.filters['fuzzy']=fuzzy + @app.context_processor + def path_for_next(): + p = request.path + if len(request.query_string) > 0: + p += "?" + request.query_string.decode("utf-8") + return dict(path_for_next=p) + + app.add_url_rule("/",endpoint="index") return app diff --git a/apioforum/templates/base.html b/apioforum/templates/base.html index ba96c91..87b142f 100644 --- a/apioforum/templates/base.html +++ b/apioforum/templates/base.html @@ -21,18 +21,18 @@ {% if g.user %} <p>{{ g.user }}</p> <p> - <a href="{{ url_for('auth.logout',next=request.path) }}"> + <a href="{{ url_for('auth.logout',next=path_for_next) }}"> logout </a> </p> {% else %} <p> - <a href="{{ url_for('auth.login',next=request.path) }}"> + <a href="{{ url_for('auth.login',next=path_for_next) }}"> login </a> </p> <p> - <a href="{{ url_for('auth.register',next=request.path) }}"> + <a href="{{ url_for('auth.register',next=path_for_next) }}"> register </a> </p> |