Skip to content

Commit 8d76c60

Browse files
authored
- adds CUSTOM_STATIC_DIR and CUSTOM_STYLESHEETS served by {{ url_for('custom_static', filename=filename) }} (#9)
1 parent 8c660ea commit 8d76c60

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

phablytics/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
# Reports
2727

28-
2928
@dataclass
3029
class ReportConfig:
3130
name: str
@@ -123,6 +122,11 @@ class ReportConfig:
123122
),
124123
]
125124

125+
# Web UI
126+
127+
CUSTOM_STATIC_DIR = None
128+
129+
CUSTOM_STYLESHEETS = []
126130

127131
##
128132
# Import Local Settings if `local_settings.py` exists in CWD

phablytics/web/app.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
import uuid
55

66
# Third Party (PyPI) Imports
7-
from flask import Flask
7+
from flask import (
8+
Flask,
9+
send_from_directory,
10+
)
811
from werkzeug.routing import BaseConverter
912

1013
# Phablytics Imports
14+
from phablytics.settings import CUSTOM_STATIC_DIR
1115
from phablytics.web.explore import explore_page
1216
from phablytics.web.help import help_page
1317
from phablytics.web.home import home_page
@@ -56,3 +60,8 @@ def __init__(self, url_map, *items):
5660
@application.errorhandler(404)
5761
def page_not_found(e):
5862
return _r('404.html')
63+
64+
65+
@application.route('/custom_static/<path:filename>')
66+
def custom_static(filename):
67+
return send_from_directory(CUSTOM_STATIC_DIR, filename)

phablytics/web/templates/fragments/css/common.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" />
66

77
<link rel="stylesheet" href="/static/style.css" />
8+
9+
{% for custom_stylesheet in custom_stylesheets %}
10+
<link rel="stylesheet" href="{{ url_for('custom_static', filename=custom_stylesheet) }}" />
11+
{% endfor %}

phablytics/web/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from phablytics.constants import GITHUB_URL
1515
from phablytics.settings import (
1616
ADMIN_USERNAME,
17+
CUSTOM_STYLESHEETS,
1718
PHABRICATOR_INSTANCE_BASE_URL,
1819
)
1920
from phablytics.web.constants import (
@@ -48,6 +49,8 @@ def get_context_data():
4849
page_title = SITE_NAME
4950

5051
context_data = {
52+
# customizations
53+
'custom_stylesheets': CUSTOM_STYLESHEETS,
5154
# page meta
5255
'nav_links': nav_links,
5356
'breadcrumbs': breadcrumbs,

0 commit comments

Comments
 (0)