Skip to content

Commit

Permalink
feat(ui): Add option to define custom css and js
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Jan 16, 2025
1 parent 7b5ab4d commit 1172bac
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dojo/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def globalize_vars(request):
"DOCUMENTATION_URL": settings.DOCUMENTATION_URL,
"API_TOKENS_ENABLED": settings.API_TOKENS_ENABLED,
"API_TOKEN_AUTH_ENDPOINT_ENABLED": settings.API_TOKEN_AUTH_ENDPOINT_ENABLED,
"CUSTOM_CSS": settings.CUSTOM_CSS,
"CUSTOM_JS": settings.CUSTOM_JS,
}


Expand Down
11 changes: 11 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@
# For HTTP requests, how long connection is open before timeout
# 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)
DD_REQUESTS_TIMEOUT=(int, 30),
# 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
DD_CUSTOM_CSS=(list, []),
DD_CUSTOM_JS=(list, []),
)


Expand Down Expand Up @@ -820,6 +823,14 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
},
]

# ------------------------------------------------------------------------------
# UI
# ------------------------------------------------------------------------------

# Add custom styles and/or scripts to UI
CUSTOM_CSS = env("DD_CUSTOM_CSS")
CUSTOM_JS = env("DD_CUSTOM_JS")

# ------------------------------------------------------------------------------
# APPS
# ------------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions dojo/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@

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

{% if CUSTOM_JS %}
<!-- Custom JS -->
{% for one_js in CUSTOM_JS %}
<script src="{% static one_js %}"></script>
{% endfor %}
{% endif %}

<!-- Bootstrap Core CSS -->
<link href="{% static "bootstrap/dist/css/bootstrap.min.css" %}" rel="stylesheet">

Expand Down Expand Up @@ -96,6 +103,14 @@
{% block add_styles %}
{% endblock %}
</style>

{% if CUSTOM_CSS %}
<!-- Custom CSS -->
{% for one_css in CUSTOM_CSS %}
<link rel="stylesheet" href="{% static one_css %}">
{% endfor %}
{% endif %}

</head>
<body class="{% dojo_body_class %}">
<div id="wrapper">
Expand Down

0 comments on commit 1172bac

Please sign in to comment.