Skip to content

Commit 1172bac

Browse files
committed
feat(ui): Add option to define custom css and js
1 parent 7b5ab4d commit 1172bac

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

dojo/context_processors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def globalize_vars(request):
2626
"DOCUMENTATION_URL": settings.DOCUMENTATION_URL,
2727
"API_TOKENS_ENABLED": settings.API_TOKENS_ENABLED,
2828
"API_TOKEN_AUTH_ENDPOINT_ENABLED": settings.API_TOKEN_AUTH_ENDPOINT_ENABLED,
29+
"CUSTOM_CSS": settings.CUSTOM_CSS,
30+
"CUSTOM_JS": settings.CUSTOM_JS,
2931
}
3032

3133

dojo/settings/settings.dist.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@
304304
# For HTTP requests, how long connection is open before timeout
305305
# This settings apply only on requests performed by "requests" lib used in Dojo code (if some included lib is using "requests" as well, this does not apply there)
306306
DD_REQUESTS_TIMEOUT=(int, 30),
307+
# Add custom styles and/or scripts to UI. All files need to be stored in "static" dir and path need to relative to this dir
308+
DD_CUSTOM_CSS=(list, []),
309+
DD_CUSTOM_JS=(list, []),
307310
)
308311

309312

@@ -820,6 +823,14 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
820823
},
821824
]
822825

826+
# ------------------------------------------------------------------------------
827+
# UI
828+
# ------------------------------------------------------------------------------
829+
830+
# Add custom styles and/or scripts to UI
831+
CUSTOM_CSS = env("DD_CUSTOM_CSS")
832+
CUSTOM_JS = env("DD_CUSTOM_JS")
833+
823834
# ------------------------------------------------------------------------------
824835
# APPS
825836
# ------------------------------------------------------------------------------

dojo/templates/base.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161

6262
<script src="{% static "jszip/dist/jszip.min.js" %}"></script>
6363

64+
{% if CUSTOM_JS %}
65+
<!-- Custom JS -->
66+
{% for one_js in CUSTOM_JS %}
67+
<script src="{% static one_js %}"></script>
68+
{% endfor %}
69+
{% endif %}
70+
6471
<!-- Bootstrap Core CSS -->
6572
<link href="{% static "bootstrap/dist/css/bootstrap.min.css" %}" rel="stylesheet">
6673

@@ -96,6 +103,14 @@
96103
{% block add_styles %}
97104
{% endblock %}
98105
</style>
106+
107+
{% if CUSTOM_CSS %}
108+
<!-- Custom CSS -->
109+
{% for one_css in CUSTOM_CSS %}
110+
<link rel="stylesheet" href="{% static one_css %}">
111+
{% endfor %}
112+
{% endif %}
113+
99114
</head>
100115
<body class="{% dojo_body_class %}">
101116
<div id="wrapper">

0 commit comments

Comments
 (0)