diff --git a/chat/static/chat.js b/chat/static/chat.js index af028d2..9252ea0 100644 --- a/chat/static/chat.js +++ b/chat/static/chat.js @@ -251,4 +251,25 @@ document.addEventListener('DOMContentLoaded', () => { } setupSocket() + + let deferredPrompt = null + + window.addEventListener("beforeinstallprompt", (e) => { + e.preventDefault() + deferredPrompt = e + let btn = document.getElementById('install-app-home-screen') + let alert = document.getElementById('alert-download-chat-app') + btn.classList.remove('d-none') + alert.classList.remove('d-none') + btn.onclick = function () { + deferredPrompt.prompt() + deferredPrompt.userChoice.then((choiceResult) => { + if (choiceResult.outcome === 'accepted') { + deferredPrompt = null + btn.classList.add('d-none') + alert.classList.add('d-none') + } + }) + } + }) }) diff --git a/chat/static/chat.webmanifest b/chat/static/chat.webmanifest new file mode 100644 index 0000000..afddf74 --- /dev/null +++ b/chat/static/chat.webmanifest @@ -0,0 +1,21 @@ +{ + "background_color": "white", + "description": "Chat pour le TFJM²", + "display": "standalone", + "icons": [ + { + "src": "tfjm-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "tfjm-192.png", + "sizes": "192x192", + "type": "image/png" + } + ], + "name": "Chat TFJM²", + "short_name": "Chat TFJM²", + "start_url": "/chat/fullscreen/", + "theme_color": "black" +} diff --git a/chat/templates/chat/chat.html b/chat/templates/chat/chat.html index a57bb63..a7c5c45 100644 --- a/chat/templates/chat/chat.html +++ b/chat/templates/chat/chat.html @@ -3,59 +3,14 @@ {% load static %} {% load i18n %} +{% block extracss %} + +{% endblock %} + {% block content-title %}{% endblock %} {% block content %} - -
-
-

{% trans "Chat channels" %}

- -
-
- -
-
- -
-
-

- - - -

-
-
- - -
- -
+ {% include "chat/content.html" %} {% endblock %} {% block extrajavascript %} diff --git a/chat/templates/chat/content.html b/chat/templates/chat/content.html new file mode 100644 index 0000000..4588ef2 --- /dev/null +++ b/chat/templates/chat/content.html @@ -0,0 +1,61 @@ +{% load i18n %} + + +
+
+

{% trans "Chat channels" %}

+ +
+
+ +
+
+ +
+ {% trans "You can install a shortcut to the chat on your home screen using the download button on the header." %} +
+ +
+
+

+ + + {% if not fullscreen %} + + {% endif %} + +

+
+
+ + +
+ +
\ No newline at end of file diff --git a/chat/templates/chat/fullscreen.html b/chat/templates/chat/fullscreen.html new file mode 100644 index 0000000..8d5053a --- /dev/null +++ b/chat/templates/chat/fullscreen.html @@ -0,0 +1,34 @@ +{% load i18n static %} + + +{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} + + + + + + Chat du TFJM² + + + + {# Favicon #} + + + + {# Bootstrap CSS #} + + + + + {# Bootstrap JavaScript #} + + + + + +{% include "chat/content.html" with fullscreen=True %} + + + + + diff --git a/chat/urls.py b/chat/urls.py index 77d52c2..c47f175 100644 --- a/chat/urls.py +++ b/chat/urls.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.urls import path +from django.views.generic import TemplateView from .views import ChatView @@ -10,4 +11,5 @@ app_name = 'chat' urlpatterns = [ path('', ChatView.as_view(), name='chat'), + path('fullscreen/', TemplateView.as_view(template_name="chat/fullscreen.html"), name='fullscreen'), ] diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 8423487..8e8d78e 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: TFJM\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-27 16:15+0200\n" +"POT-Creation-Date: 2024-04-27 18:49+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Emmy D'Anello \n" "Language-Team: LANGUAGE \n" @@ -143,23 +143,35 @@ msgstr "message" msgid "messages" msgstr "messages" -#: chat/templates/chat/chat.html:10 +#: chat/templates/chat/chat.html:14 msgid "JavaScript must be enabled on your browser to access chat." msgstr "JavaScript doit être activé sur votre navigateur pour accéder au chat." -#: chat/templates/chat/chat.html:14 +#: chat/templates/chat/chat.html:18 msgid "Chat channels" msgstr "Canaux de chat" -#: chat/templates/chat/chat.html:31 +#: chat/templates/chat/chat.html:27 +msgid "" +"You can install a shortcut to the chat on your home screen using the " +"download button on the header." +msgstr "" +"Vous pouvez installer un raccourci vers le chat sur votre écran d'accueil en " +"utilisant le bouton de téléchargement dans l'en-tête." + +#: chat/templates/chat/chat.html:40 msgid "Toggle fullscreen mode" msgstr "Inverse le mode plein écran" -#: chat/templates/chat/chat.html:39 +#: chat/templates/chat/chat.html:44 +msgid "Install app on home screen" +msgstr "Installer l'application sur l'écran d'accueil" + +#: chat/templates/chat/chat.html:52 msgid "Fetch previous messages…" msgstr "Récupérer les messages précédents…" -#: chat/templates/chat/chat.html:51 +#: chat/templates/chat/chat.html:64 msgid "Send message…" msgstr "Envoyer un message…" @@ -3748,7 +3760,7 @@ msgstr "S'inscrire" msgid "My account" msgstr "Mon compte" -#: tfjm/templates/navbar.html:115 +#: tfjm/templates/navbar.html:117 msgid "Log out" msgstr "Déconnexion" diff --git a/tfjm/static/tfjm-192.png b/tfjm/static/tfjm-192.png new file mode 100644 index 0000000..09e57f4 Binary files /dev/null and b/tfjm/static/tfjm-192.png differ diff --git a/tfjm/static/tfjm-512.png b/tfjm/static/tfjm-512.png new file mode 100644 index 0000000..5837e3b Binary files /dev/null and b/tfjm/static/tfjm-512.png differ diff --git a/tfjm/templates/navbar.html b/tfjm/templates/navbar.html index ecdb4dc..1bc75f8 100644 --- a/tfjm/templates/navbar.html +++ b/tfjm/templates/navbar.html @@ -111,9 +111,12 @@
  • - - {% trans "Log out" %} - +
    + {% csrf_token %} + +