Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add orejime to manage cookies #583

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions atlas/configuration/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class Meta:
AFFICHAGE_LOGOS_HOME = fields.Boolean(load_default=True)
AFFICHAGE_FOOTER = fields.Boolean(load_default=True)
AFFICHAGE_RGPD = fields.Boolean(load_default=True)
OREJIME_APPS = fields.List(fields.Dict(), load_default=[])
AFFICHAGE_STAT_GLOBALES = fields.Boolean(load_default=True)
AFFICHAGE_DERNIERES_OBS = fields.Boolean(load_default=True)
AFFICHAGE_EN_CE_MOMENT = fields.Boolean(load_default=True)
Expand Down
45 changes: 27 additions & 18 deletions atlas/static/custom/templates/footer.html.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
data-target="#modalCredits">{{ _('credits') }}</a> |
<a data-toggle="modal" href="#"
data-target="#modalMentions">{{ _('legal') }}</a>
{% if configuration.AFFICHAGE_RGPD %}
{% if configuration.AFFICHAGE_RGPD and configuration.OREJIME_APPS | length > 0 %}
|
<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 %}
19 changes: 19 additions & 0 deletions atlas/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,22 @@ if (configuration.GLOSSAIRE) {
});
});
}

if (configuration.OREJIME_APPS.length > 0) {
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