Fix exposing abs_url_for to templates
This commit is contained in:
parent
144ae69f5c
commit
663a9ba07b
|
@ -60,7 +60,6 @@ if not app.debug and app.config["MAIL_UTILS_ERROR_SEND_TO"]:
|
||||||
from .markdown import init_app
|
from .markdown import init_app
|
||||||
init_app(app)
|
init_app(app)
|
||||||
|
|
||||||
|
|
||||||
# @babel.localeselector
|
# @babel.localeselector
|
||||||
# def get_locale():
|
# def get_locale():
|
||||||
# return request.accept_languages.best_match(app.config['LANGUAGES'].keys())
|
# return request.accept_languages.best_match(app.config['LANGUAGES'].keys())
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
from . import app
|
from . import app
|
||||||
|
from .utils import abs_url_for
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_debug():
|
def inject_debug():
|
||||||
return dict(debug=app.debug)
|
return dict(debug=app.debug)
|
||||||
|
|
||||||
|
|
||||||
|
@app.context_processor
|
||||||
|
def inject_functions():
|
||||||
|
return dict(abs_url_for=abs_url_for)
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
def throw(err):
|
def throw(err):
|
||||||
raise Exception(err)
|
raise Exception(err)
|
||||||
|
|
|
@ -18,12 +18,10 @@
|
||||||
from flask import request, flash, abort, redirect
|
from flask import request, flash, abort, redirect
|
||||||
from flask_user import *
|
from flask_user import *
|
||||||
from flask_login import login_user, logout_user
|
from flask_login import login_user, logout_user
|
||||||
from app.models import *
|
from .models import *
|
||||||
from app import app
|
from . import app
|
||||||
import random, string, os, imghdr
|
import random, string, os, imghdr
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter()
|
|
||||||
def abs_url_for(path, **kwargs):
|
def abs_url_for(path, **kwargs):
|
||||||
scheme = "https" if app.config["BASE_URL"][:5] == "https" else "http"
|
scheme = "https" if app.config["BASE_URL"][:5] == "https" else "http"
|
||||||
return url_for(path, _external=True, _scheme=scheme, **kwargs)
|
return url_for(path, _external=True, _scheme=scheme, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue