diff --git a/re2o/settings.py b/re2o/settings.py
index 0c30814a..c298b9f8 100644
--- a/re2o/settings.py
+++ b/re2o/settings.py
@@ -173,22 +173,28 @@ if "LOCAL_ROUTERS" in globals():
DATABASE_ROUTERS += LOCAL_ROUTERS
# django-bootstrap3 config
-BOOTSTRAP3 = {
- "css_url": "/javascript/bootstrap/css/bootstrap.min.css",
- "javascript_url": "/javascript/bootstrap/js/bootstrap.min.js",
- "jquery_url": "/javascript/jquery/jquery.min.js",
- "base_url": "/javascript/bootstrap/",
- "include_jquery": True,
-}
-BOOTSTRAP_BASE_URL = "/javascript/bootstrap/"
+if USE_CDN:
+ BOOTSTRAP3 = {
+ "include_jquery": True,
+ }
+else:
+ BOOTSTRAP3 = {
+ "css_url": "/javascript/bootstrap/css/bootstrap.min.css",
+ "javascript_url": "/javascript/bootstrap/js/bootstrap.min.js",
+ "jquery_url": "/javascript/jquery/jquery.min.js",
+ "base_url": "/javascript/bootstrap/",
+ "include_jquery": True,
+ }
+ BOOTSTRAP_BASE_URL = "/javascript/bootstrap/"
# Directories where collectstatic should look for static files
# Use only absolute paths with '/' delimiters even on Windows
-STATICFILES_DIRS = (
+RE2O_STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static").replace("\\", "/"),
- "/usr/share/fonts-font-awesome/",
- "/usr/share/javascript/",
)
+
+STATICFILES_DIRS = RE2O_STATICFILES_DIRS + SYSTEM_STATICFILES_DIRS
+
# Directory where the static files served by the server are stored
STATIC_ROOT = os.path.join(BASE_DIR, "static_files")
# The URL to access the static files
diff --git a/re2o/settings_default.py b/re2o/settings_default.py
index 8f552c2b..8b3cfa34 100644
--- a/re2o/settings_default.py
+++ b/re2o/settings_default.py
@@ -65,6 +65,12 @@ OPTIONNAL_APPS_RE2O = ()
# Some Django apps you want to add in you local project
OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + ()
+# Add statiffiles dir that were installed using system packaging
+SYSTEM_STATICFILES_DIRS = ()
+
+# Wether to use CDN to retrieve bootstrap, font-aweseome and jquery files
+USE_CDN = False
+
# Set auth password validator
AUTH_PASSWORD_VALIDATORS = [
{
diff --git a/re2o/settings_local.example.py b/re2o/settings_local.example.py
index c1e315b8..2a199bbd 100644
--- a/re2o/settings_local.example.py
+++ b/re2o/settings_local.example.py
@@ -115,6 +115,15 @@ OPTIONNAL_APPS_RE2O = ()
# Some Django apps you want to add in you local project
OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + ()
+# Add statiffiles dir that were installed using system packaging
+# Example to reproduce re2o2.9 behavior
+# SYSTEM_STATICFILES_DIRS = ("/usr/share/fonts-font-awesome/", "/usr/share/javascript/")
+SYSTEM_STATICFILES_DIRS = ()
+
+# Wether to use CDN to retrieve bootstrap, font-aweseome and jquery files
+# Default to False
+USE_CDN = False
+
# Set auth password validator
AUTH_PASSWORD_VALIDATORS = [
{
diff --git a/re2o/templatetags/fontawesome.py b/re2o/templatetags/fontawesome.py
new file mode 100644
index 00000000..a68dd250
--- /dev/null
+++ b/re2o/templatetags/fontawesome.py
@@ -0,0 +1,20 @@
+"""
+Templatetags for fontawesome
+"""
+from django import template
+from django.conf import settings
+from django.templatetags.static import static
+
+register = template.Library()
+
+@register.simple_tag
+def font_awesome_url():
+ """Return the font awesome url depending on the use of a CDN.
+
+ Returns:
+ string: url of the font-awesome css file
+ """
+ if settings.USE_CDN:
+ return "https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
+ else:
+ return static("css/font-awesome.min.css")
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
index 324891d0..bf23e66c 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load acl %}
{% load self_adhesion %}
{% load i18n %}
+{% load fontawesome %}
{% self_adhesion as var_sa %}
@@ -46,13 +47,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{# Preload JavaScript #}
{% bootstrap_javascript %}
-
+
{% block custom_js %}{% endblock %}
{# Load CSS #}
{% bootstrap_css %}
-
+
+ {# Load font-awesome #}
+
+
{# load theme #}
{% if request.user.is_authenticated %}