Skip to content

Commit

Permalink
feat: Add orejime to manage cookies
Browse files Browse the repository at this point in the history
Ajout d'un gestionnaire de cookies. Orejime a été choisi.
Il permet d'avoir une popup afin d'accepter ou de refuser les cookies sur l'application.
  • Loading branch information
juggler31 committed Nov 27, 2024
1 parent 537906a commit 192a706
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 23 deletions.
6 changes: 6 additions & 0 deletions atlas/atlasRoutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,18 @@ def index():
connection.close()
session.close()

personal_data = False
args_personal_data = request.args.get("personal_data")
if args_personal_data and args_personal_data.lower() == "true":
personal_data = True

return render_template(
"templates/home/_main.html",
observations=observations,
mostViewTaxon=mostViewTaxon,
customStatMedias=customStatMedias,
lastDiscoveries=lastDiscoveries,
personal_data=personal_data,
)


Expand Down
43 changes: 26 additions & 17 deletions atlas/static/custom/templates/footer.html.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
|
<a data-toggle="modal" href="#"
data-target="#modalPersonalData">{{ _('personal_data') }}</a>
| <a id="preferences-cookies" href="#" onclick="orejime.show()">{{ _('preferences_cookies') }}</a>
{% endif %}
</small>

Expand Down Expand Up @@ -74,22 +75,30 @@
</div>
{% endif %}

{% if configuration.ID_GOOGLE_ANALYTICS != "UA-xxxxxxx-xx" %}
<!-- Script Google Analytics -->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
<!-- Check ID_GOOGLE_ANALYTICS to keep compability with old Geonature-atlas -->
{% if configuration.OREJIME_APPS|length > 0 %}
<!-- Sample script Analytics Google -->
{% for app in configuration.OREJIME_APPS %}
{% if app.name == "scripts-gtm" %}
<script
type="opt-in"
data-type="application/javascript"
data-name="scripts-gtm">
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

ga('create', '{{configuration.ID_GOOGLE_ANALYTICS}}', 'auto');
ga('send', 'pageview');
</script>
ga('create', '{{configuration.ID_GOOGLE_ANALYTICS}}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
{% endfor %}
{% endif %}
18 changes: 18 additions & 0 deletions atlas/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,21 @@ if (configuration.GLOSSAIRE) {
});
});
}


var orejimeConfig = {
elementID: "orejime",
appElement: "main",
cookieName: "orejime",
cookieExpiresAfterDays: 365,
privacyPolicy: "/?personal_data=true",
default: true,
mustConsent: false,
mustNotice: false,
lang: configuration.DEFAULT_LANGUAGE,
logo: false,
debug: configuration.modeDebug,
translations: configuration.OREJIME_TRANSLATIONS,
apps: configuration.OREJIME_APPS,
categories: configuration.OREJIME_CATEGORIES
}
84 changes: 82 additions & 2 deletions atlas/static/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions atlas/static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"leaflet.snogylop": "^0.4.0",
"leaflet.zoomhome": "^1.0.0",
"lightbox2": "^2.8.2",
"orejime": "^2.3.0",
"popper.js": "^1.16.0",
"raphael": "^2.2.0",
"slick": "^1.12.2",
Expand Down
4 changes: 4 additions & 0 deletions atlas/templates/core/assets_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@
<link rel="SHORTCUT ICON" href="{{ url_for('static', filename='custom/images/favicon.ico') }}">
<link rel="stylesheet" href="{{url_for('static', filename='css/atlas.css') }}" />

<!-- GDPR -->
<script src="{{url_for('static', filename='node_modules/orejime/dist/orejime.js') }}"></script>
<link rel="stylesheet" href="{{url_for('static', filename='node_modules/orejime/dist/orejime.css') }}" />

{% endblock %}
6 changes: 6 additions & 0 deletions atlas/templates/home/_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
</script>
<script src="{{ url_for('static', filename='index.js') }}"></script>

{% if personal_data %}
<script>
$("#modalPersonalData").modal('show');
</script>
{% endif %}

{% endblock %}


Expand Down
Binary file modified atlas/translations/en/LC_MESSAGES/messages.mo
Binary file not shown.
6 changes: 5 additions & 1 deletion atlas/translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2024-11-27 10:43+0100\n"
"PO-Revision-Date: 2021-07-12 12:12+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down Expand Up @@ -47,6 +47,10 @@ msgstr "Legal mentions"
msgid "personal_data"
msgstr "Personal data"

#: static/custom/templates/footer.html:12
msgid "preferences_cookies"
msgstr "Changing cookie preferences"

#: static/custom/templates/footer.html:17
#: static/custom/templates/footer.html.sample:17
msgid "atlas.fauna.flora"
Expand Down
Binary file modified atlas/translations/fr/LC_MESSAGES/messages.mo
Binary file not shown.
8 changes: 6 additions & 2 deletions atlas/translations/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2024-11-27 10:38+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
Expand Down Expand Up @@ -47,7 +47,11 @@ msgstr "Mentions légales"
msgid "personal_data"
msgstr "Données personnelles"

#: static/custom/templates/footer.html:17
#: static/custom/templates/footer.html:12
msgid "preferences_cookies"
msgstr "Modifier les préférences de cookies"

#: static/custom/templates/footer.html:18
#: static/custom/templates/footer.html.sample:17
msgid "atlas.fauna.flora"
msgstr "Atlas de la faune et de la flore"
Expand Down
Binary file modified atlas/translations/it/LC_MESSAGES/messages.mo
Binary file not shown.
6 changes: 5 additions & 1 deletion atlas/translations/it/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2024-11-27 10:43+0100\n"
"PO-Revision-Date: 2021-07-19 09:53+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: it\n"
Expand Down Expand Up @@ -47,6 +47,10 @@ msgstr "Nota legale"
msgid "personal_data"
msgstr "Dati personali"

#: atlas/static/custom/templates/footer.html:12
msgid "preferences_cookies"
msgstr ""

#: static/custom/templates/footer.html:17
#: static/custom/templates/footer.html.sample:17
msgid "atlas.fauna.flora"
Expand Down
Binary file added docs/images/choice_rgpd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 192a706

Please sign in to comment.