1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Description: Adjust flask_app.py to locate template, static and theme files
On Debian, we install template, static and theme files under
/usr/share/pagure (instead of /usr/lib/python3/dist-packages/pagure,
which is upstream's default). For that reason, we have to adjust
flask_app.py in order to make it properly locate these files.
Author: Sergio Durigan Junior <sergiodj@debian.org>
Forwarded: not-needed
--- a/pagure/flask_app.py
+++ b/pagure/flask_app.py
@@ -177,9 +177,13 @@ def create_app(config=None):
app.register_blueprint(blueprint)
themename = pagure_config.get("THEME", "default")
- here = os.path.abspath(
- os.path.join(os.path.dirname(os.path.abspath(__file__)))
- )
+ # Debian installs the themes, static and template files under
+ # /usr/share/pagure.
+ here = "/usr/share/pagure"
+ if not os.path.exists(here): # build-time tests
+ here = os.path.abspath(
+ os.path.join(os.path.dirname(os.path.abspath(__file__)))
+ )
themeblueprint = flask.Blueprint(
"theme",
__name__,
@@ -188,6 +192,8 @@ def create_app(config=None):
)
# Jinja can be told to look for templates in different folders
# That's what we do here
+ # Debian install templates under /usr/share/pagure.
+ app.template_folder = os.path.join(here, "templates")
template_folders = os.path.join(
app.root_path,
app.template_folder,
|