mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
feat: 🎨 Allow the use of CDN and generalise the staticfiles.
A CDN can be used. Other locations than the debian ones can be used for staticfiles. python3 manage.py runserver is now functionnal Configuration need to be changed to have re2o2.9 behavior
This commit is contained in:
parent
608cbdb634
commit
3b6af9d01a
5 changed files with 58 additions and 13 deletions
|
@ -173,22 +173,28 @@ if "LOCAL_ROUTERS" in globals():
|
|||
DATABASE_ROUTERS += LOCAL_ROUTERS
|
||||
|
||||
# django-bootstrap3 config
|
||||
BOOTSTRAP3 = {
|
||||
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/"
|
||||
}
|
||||
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
|
||||
|
|
|
@ -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 = [
|
||||
{
|
||||
|
|
|
@ -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 = [
|
||||
{
|
||||
|
|
20
re2o/templatetags/fontawesome.py
Normal file
20
re2o/templatetags/fontawesome.py
Normal file
|
@ -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")
|
|
@ -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 %}
|
||||
<!DOCTYPE html>
|
||||
|
@ -52,7 +53,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{# Load CSS #}
|
||||
{% bootstrap_css %}
|
||||
<link href="{% static 'css/autocomplete.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet">
|
||||
|
||||
{# Load font-awesome #}
|
||||
<link rel="stylesheet" href="{% font_awesome_url %}"/>
|
||||
|
||||
{# load theme #}
|
||||
{% if request.user.is_authenticated %}
|
||||
<link href="{% static 'css/themes/' %}{{request.user.theme}}" rel="stylesheet">
|
||||
|
|
Loading…
Reference in a new issue