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 Oct 17, 2024
1 parent 537906a commit c7f3d06
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 19 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
42 changes: 25 additions & 17 deletions atlas/static/custom/templates/footer.html.sample
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,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 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 c7f3d06

Please sign in to comment.