Fix exposing abs_url_for to templates

This commit is contained in:
rubenwardy 2020-03-28 19:01:39 +00:00
parent 144ae69f5c
commit 663a9ba07b
3 changed files with 8 additions and 5 deletions

View File

@ -60,7 +60,6 @@ if not app.debug and app.config["MAIL_UTILS_ERROR_SEND_TO"]:
from .markdown import init_app
init_app(app)
# @babel.localeselector
# def get_locale():
# return request.accept_languages.best_match(app.config['LANGUAGES'].keys())

View File

@ -1,10 +1,16 @@
from . import app
from .utils import abs_url_for
from urllib.parse import urlparse
@app.context_processor
def inject_debug():
return dict(debug=app.debug)
@app.context_processor
def inject_functions():
return dict(abs_url_for=abs_url_for)
@app.template_filter()
def throw(err):
raise Exception(err)

View File

@ -18,12 +18,10 @@
from flask import request, flash, abort, redirect
from flask_user import *
from flask_login import login_user, logout_user
from app.models import *
from app import app
from .models import *
from . import app
import random, string, os, imghdr
@app.template_filter()
def abs_url_for(path, **kwargs):
scheme = "https" if app.config["BASE_URL"][:5] == "https" else "http"
return url_for(path, _external=True, _scheme=scheme, **kwargs)