Minify CSS and JavaScript files

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-06-02 19:47:35 +02:00
parent 635606eb13
commit 5e2add90a8
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
29 changed files with 113 additions and 51 deletions

View File

@ -3,10 +3,12 @@ FROM python:3.12-alpine
ENV PYTHONUNBUFFERED 1
ENV DJANGO_ALLOW_ASYNC_UNSAFE 1
RUN apk add --no-cache gettext nginx gcc git libc-dev libffi-dev libxml2-dev libxslt-dev postgresql-dev libmagic texlive texmf-dist-latexextra
RUN apk add --no-cache gettext nginx gcc git libc-dev libffi-dev libxml2-dev libxslt-dev npm postgresql-dev libmagic texlive texmf-dist-latexextra
RUN apk add --no-cache bash
RUN npm install -g yuglify
RUN mkdir /code /code/docs
WORKDIR /code
COPY requirements.txt /code/requirements.txt

View File

@ -4,19 +4,19 @@
"display": "standalone",
"icons": [
{
"src": "tfjm-square.svg",
"src": "/static/tfjm/img/tfjm-square.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "maskable"
},
{
"src": "tfjm-512.png",
"src": "/static/tfjm/img/tfjm-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "tfjm-192.png",
"src": "/static/tfjm/img/tfjm-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"

View File

@ -2,10 +2,11 @@
{% load static %}
{% load i18n %}
{% load pipeline %}
{% block extracss %}
{# Webmanifest PWA permettant l'installation de l'application sur un écran d'accueil, pour navigateurs supportés #}
<link rel="manifest" href="{% static "chat.webmanifest" %}">
<link rel="manifest" href="{% static "tfjm/chat.webmanifest" %}">
{% endblock %}
{% block content-title %}{% endblock %}
@ -16,5 +17,5 @@
{% block extrajavascript %}
{# Ce script contient toutes les données pour la gestion du chat. #}
<script src="{% static 'chat.js' %}"></script>
{% javascript 'chat' %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% load i18n static %}
{% load i18n pipeline static %}
<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
@ -15,23 +15,21 @@
<link rel="shortcut icon" href="{% static "favicon.ico" %}">
<meta name="theme-color" content="#ffffff">
{# Bootstrap CSS #}
<link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/all.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/v4-shims.css' %}">
{# Bootstrap + Font Awesome CSS #}
{% stylesheet 'bootstrap_fontawesome' %}
{# Bootstrap JavaScript #}
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
{% javascript 'bootstrap' %}
{# Webmanifest PWA permettant l'installation de l'application sur un écran d'accueil, pour navigateurs supportés #}
<link rel="manifest" href="{% static "chat.webmanifest" %}">
<link rel="manifest" href="{% static "tfjm/chat.webmanifest" %}">
</head>
<body class="d-flex w-100 h-100 flex-column">
{% include "chat/content.html" with fullscreen=True %}
{# Inclusion du script permettant de gérer le thème sombre et le thème clair #}
<script src="{% static 'theme.js' %}"></script>
{% javascript 'theme' %}
{# Inclusion du script gérant le chat #}
<script src="{% static 'chat.js' %}"></script>
{% javascript 'chat' %}
</body>
</html>

View File

@ -1,4 +1,4 @@
{% load i18n static %}
{% load i18n pipeline static %}
<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
@ -16,15 +16,13 @@
<meta name="theme-color" content="#ffffff">
{# Bootstrap CSS #}
<link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/all.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/v4-shims.css' %}">
{% stylesheet 'bootstrap_fontawesome' %}
{# Bootstrap JavaScript #}
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
{% javascript 'bootstrap' %}
{# Webmanifest PWA permettant l'installation de l'application sur un écran d'accueil, pour navigateurs supportés #}
<link rel="manifest" href="{% static "chat.webmanifest" %}">
<link rel="manifest" href="{% static "tfjm/chat.webmanifest" %}">
</head>
<body class="d-flex w-100 h-100 flex-column">
<div class="container">
@ -33,6 +31,6 @@
</div>
{# Inclusion du script permettant de gérer le thème sombre et le thème clair #}
<script src="{% static 'theme.js' %}"></script>
{% javascript 'theme' %}
</body>
</html>

View File

@ -2,6 +2,7 @@
{% load static %}
{% load i18n %}
{% load pipeline %}
{% block content %}
{# The navbar to select the tournament #}
@ -40,5 +41,5 @@
{{ problems|length|json_script:'problems_count' }}
{# This script contains all data for the draw management #}
<script src="{% static 'draw.js' %}"></script>
{% javascript 'draw' %}
{% endblock %}

View File

@ -7,10 +7,10 @@
<div id="form-content">
<div class="alert alert-info">
{% trans "Templates:" %}
<a class="alert-link" href="{% static "Fiche_synthèse.pdf" %}"> PDF</a>
<a class="alert-link" href="{% static "Fiche_synthèse.tex" %}"> TEX</a>
<a class="alert-link" href="{% static "Fiche_synthèse.odt" %}"> ODT</a>
<a class="alert-link" href="{% static "Fiche_synthèse.docx" %}" title="{% trans "Warning: non-free format" %}"> DOCX</a>
<a class="alert-link" href="{% static "tfjm/Fiche_synthèse.pdf" %}"> PDF</a>
<a class="alert-link" href="{% static "tfjm/Fiche_synthèse.tex" %}"> TEX</a>
<a class="alert-link" href="{% static "tfjm/Fiche_synthèse.odt" %}"> ODT</a>
<a class="alert-link" href="{% static "tfjm/Fiche_synthèse.docx" %}" title="{% trans "Warning: non-free format" %}"> DOCX</a>
</div>
{% csrf_token %}
{{ form|crispy }}

View File

@ -9,7 +9,7 @@
<div id="form-content">
<div class="alert alert-info">
{% trans "Health sheet template:" %}
<a class="alert-link" href="{% static "Fiche_sanitaire.pdf" %}">{% trans "Download" %}</a>
<a class="alert-link" href="{% static "tfjm/Fiche_sanitaire.pdf" %}">{% trans "Download" %}</a>
</div>
{% csrf_token %}
{{ form|crispy }}

View File

@ -5,14 +5,15 @@ Django>=5.0.3,<6.0
django-crispy-forms~=2.1
django-extensions~=3.2.3
django-filter~=23.5
elasticsearch~=7.17.9
git+https://github.com/django-haystack/django-haystack.git#v3.3b1
git+https://github.com/django-haystack/django-haystack.git#v3.3b2
django-mailer~=2.3.1
django-phonenumber-field~=7.3.0
django-pipeline~=3.1.0
django-polymorphic~=3.1.0
django-tables2~=2.7.0
djangorestframework~=3.14.0
django-rest-polymorphic~=0.1.10
elasticsearch~=7.17.9
gspread~=6.1.0
gunicorn~=21.2.0
odfpy~=1.4.1

View File

@ -7,10 +7,10 @@ Django settings for tfjm project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
import os
@ -25,7 +25,7 @@ PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
ADMINS = [("Emmy D'Anello", "emmy.danello@animath.fr")]
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', 'CHANGE_ME_IN_ENV_SETTINGS')
@ -63,6 +63,7 @@ INSTALLED_APPS = [
'haystack',
'logs',
'phonenumber_field',
'pipeline',
'polymorphic',
'rest_framework',
'rest_framework.authtoken',
@ -95,6 +96,8 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
'django.middleware.gzip.GZipMiddleware',
'pipeline.middleware.MinifyHTMLMiddleware',
'tfjm.middlewares.SessionMiddleware',
'tfjm.middlewares.FetchMiddleware',
]
@ -126,7 +129,7 @@ ASGI_APPLICATION = 'tfjm.asgi.application'
WSGI_APPLICATION = 'tfjm.wsgi.application'
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@ -161,7 +164,7 @@ REST_FRAMEWORK = {
}
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
# https://docs.djangoproject.com/en/5.0/topics/i18n/
LANGUAGE_CODE = 'en'
@ -181,7 +184,7 @@ USE_TZ = True
LOCALE_PATHS = [os.path.join(BASE_DIR, "locale")]
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = '/static/'
@ -191,6 +194,70 @@ STATICFILES_DIRS = [
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
PIPELINE = {
'DISABLE_WRAPPER': True,
'JAVASCRIPT': {
'bootstrap': {
'source_filenames': {
'bootstrap/js/bootstrap.bundle.min.js',
},
'output_filename': 'tfjm/js/bootstrap.bundle.min.js',
},
'bootstrap_select': {
'source_filenames': {
'jquery/jquery.min.js',
'bootstrap-select/js/bootstrap-select.min.js',
'bootstrap-select/js/defaults-fr_FR.min.js',
},
'output_filename': 'tfjm/js/bootstrap-select-jquery.min.js',
},
'main': {
'source_filenames': (
'tfjm/js/main.js',
'tfjm/js/theme.js',
),
'output_filename': 'tfjm/js/main.min.js',
},
'theme': {
'source_filenames': (
'tfjm/js/theme.js',
),
'output_filename': 'tfjm/js/theme.min.js',
},
'chat': {
'source_filenames': (
'tfjm/js/chat.js',
),
'output_filename': 'tfjm/js/chat.min.js',
},
'draw': {
'source_filenames': (
'tfjm/js/draw.js',
),
'output_filename': 'tfjm/js/draw.min.js',
},
},
'STYLESHEETS': {
'bootstrap_fontawesome': {
'source_filenames': (
'bootstrap/css/bootstrap.min.css',
'fontawesome/css/all.css',
'fontawesome/css/v4-shims.css',
'bootstrap-select/css/bootstrap-select.min.css',
),
'output_filename': 'tfjm/css/bootstrap_fontawesome.min.css',
}
},
}
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")

View File

Before

Width:  |  Height:  |  Size: 428 KiB

After

Width:  |  Height:  |  Size: 428 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -1,4 +1,6 @@
{% load i18n static %}
{% load i18n %}
{% load pipeline %}
{% load static %}
<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
@ -16,19 +18,12 @@
<meta name="theme-color" content="#ffffff">
{# Bootstrap CSS #}
<link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/all.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/v4-shims.css' %}">
<link rel="stylesheet" href="{% static 'bootstrap-select/css/bootstrap-select.min.css' %}">
{% stylesheet 'bootstrap_fontawesome' %}
{# Bootstrap JavaScript #}
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
{% javascript 'bootstrap' %}
{# bootstrap-select for beautiful selects and JQuery dependency #}
<script src="{% static 'jquery/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap-select/js/bootstrap-select.min.js' %}"></script>
<script src="{% static 'bootstrap-select/js/defaults-fr_FR.min.js' %}"></script>
{% javascript 'bootstrap_select' %}
{# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #}
{% if form.media %}
@ -87,8 +82,7 @@
{% include "base_modal.html" with modal_id="login" %}
{% endif %}
<script src="{% static 'main.js' %}"></script>
<script src="{% static 'theme.js' %}"></script>
{% javascript 'main' %}
<script>
CSRF_TOKEN = "{{ csrf_token }}";

View File

@ -3,7 +3,7 @@
<nav class="navbar navbar-expand-lg fixed-navbar shadow-sm">
<div class="container-fluid">
<a class="navbar-brand" href="https://tfjm.org/">
<img src="{% static "tfjm.svg" %}" style="height: 2em;" alt="Logo TFJM²" id="navbar-logo">
<img src="{% static "tfjm/img/tfjm.svg" %}" style="height: 2em;" alt="Logo TFJM²" id="navbar-logo">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarNavDropdown"

View File

@ -26,7 +26,7 @@ deps =
pep8-naming
pyflakes
commands =
flake8 api/ chat/ draw/ logs/ participation/ registration/ tfjm/
flake8 api/ chat/ss draw/ logs/ participation/ registration/ tfjm/
[flake8]
exclude =