Skip to content

Commit

Permalink
Added settings to allow specifying custom js/css links for using a CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
damionmounts committed Nov 14, 2023
1 parent ff3e4ee commit ef498d1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<link rel="shortcut icon" href="/static/favicon.ico">
<title>Decider: {% block title %}{% endblock %}</title>

{% if frontend_conf.use_minified_srcs %}
{% if frontend_conf.use_cdn_resources %}
{{ user_additions.cdn_css() }}
{% elif frontend_conf.use_minified_srcs %}
<link rel="stylesheet" href="/static/css/lib/bootstrap-5.3.0/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/lib/bootstrap-icons-1.10.5/bootstrap-icons.min.css">
<link rel="stylesheet" href="/static/css/decider.css?cache_bust=23nov14">
Expand Down Expand Up @@ -363,7 +365,9 @@
});
});
</script>
{% if frontend_conf.use_minified_srcs %}
{% if frontend_conf.use_cdn_resources %}
{{ user_additions.cdn_js() }}
{% elif frontend_conf.use_minified_srcs %}
<script src="/static/js/lib/jquery-3.7.0.slim/jquery-3.7.0.slim.min.js"></script>
<script src="/static/js/lib/mark.js-9.0.0/jquery.mark.es6.min.js"></script>
<script src="/static/js/lib/bootstrap-bundle-5.3.0/bootstrap.bundle.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions decider.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use_minified_srcs=True,
classification_level="",
classification_message="",
use_cdn_resources=False,
)
with open("config/frontend.json", "rt") as fh:
try:
Expand Down
7 changes: 5 additions & 2 deletions default_config/frontend.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"base_url_href : change this if not hosting directly at the root path of a server",
"use_minified_srcs : setting this false will make the app use unminified JS/CSS libraries (good for debug)",
"classification_level : 'U', 'C', 'S', or 'T' (see app/static/css/decider.css > Classification Banner Styling)",
"classification_message: when this and level are set, a banner appears at the top and bottom of the site"
"classification_message: when this and level are set, a banner appears at the top and bottom of the site",
"use_cdn_resources : takes precedent over 'use_minified_srcs'. uses cdn_css() and cdn_js() macros from",
" user_additions.html to specify CDN variants of libraries to load (be careful of order)"
],
"base_url_href" : "/",
"use_minified_srcs" : true,
"classification_level" : "",
"classification_message": ""
"classification_message": "",
"use_cdn_resources" : false
}
8 changes: 8 additions & 0 deletions default_config/user_additions.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

Head / Body: Good for CSS / JS / Analytics
Footer : Good for additional links / resources at bottom of page
CDN : Good for specifying CDN links to the CSS / JS libraries
Use with frontend.json > "use_cdn_resources": true

Templating Language: https://jinja.palletsprojects.com/en/3.1.x/

Expand Down Expand Up @@ -35,3 +37,9 @@

{% macro footer_bottom() -%}
{%- endmacro %}

{% macro cdn_css() -%}
{%- endmacro %}

{% macro cdn_js() -%}
{%- endmacro %}

0 comments on commit ef498d1

Please sign in to comment.