diff --git a/photologue/static/gallery_detail.js b/photologue/static/gallery_detail.js
new file mode 100644
index 0000000..fbc9c80
--- /dev/null
+++ b/photologue/static/gallery_detail.js
@@ -0,0 +1,9 @@
+// This file is part of photo21
+// Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+// Init gallery
+lightGallery(document.getElementById('lightgallery'), {
+ plugins: [lgAdmin, lgHash, lgThumbnail, lgZoom],
+ customSlideName: true,
+});
diff --git a/photologue/static/lightgallery/plugins/admin/lg-admin.js b/photologue/static/lightgallery/plugins/admin/lg-admin.js
index f0ecf26..e9e143a 100644
--- a/photologue/static/lightgallery/plugins/admin/lg-admin.js
+++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js
@@ -10,8 +10,8 @@ class lgAdmin {
constructor(instance, $LG) {
this.core = instance;
this.$LG = $LG;
- this.isStaff = instance.settings.isStaff;
- this.csrfToken = instance.settings.csrfToken;
+ this.isStaff = document.querySelector('[name=is_staff]').value === "true";
+ this.csrfToken = document.querySelector('[name=csrfmiddlewaretoken]').value;
this.photoId = 0;
return this;
}
diff --git a/photologue/templates/photologue/gallery_detail.html b/photologue/templates/photologue/gallery_detail.html
index 5fa1999..83cab1a 100644
--- a/photologue/templates/photologue/gallery_detail.html
+++ b/photologue/templates/photologue/gallery_detail.html
@@ -15,19 +15,15 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endblock %}
{% block extrajs %}
+{# Javascript code fetches CSRF token from HTML #}
+{% csrf_token %}
+
-
+
{% endblock %}
{% block content %}