Add video support with unified media display.
All checks were successful
Docker / build (release) Successful in 9s
All checks were successful
Docker / build (release) Successful in 9s
This commit is contained in:
parent
a634cc88bd
commit
f4052a3d99
16 changed files with 700 additions and 224 deletions
|
|
@ -15,6 +15,9 @@ class lgAdmin {
|
|||
this.canResolveCensorship = document.querySelector('[name=can_resolve_censorship]').value === "true";
|
||||
this.csrfToken = document.querySelector('[name=csrfmiddlewaretoken]').value;
|
||||
this.photoId = 0;
|
||||
this.deleteUrl = '';
|
||||
this.adminUrl = '';
|
||||
this.isVideo = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -49,14 +52,19 @@ class lgAdmin {
|
|||
// Event called when showing a new slide
|
||||
onAfterSlide(event) {
|
||||
this.photoId = this.core.galleryItems[event.detail.index].slideName;
|
||||
document.getElementById("lg-admin").href = `/admin/photologue/photo/${this.photoId}/change/`;
|
||||
const el = document.querySelector(`[data-slide-name='${this.photoId}']`);
|
||||
this.deleteUrl = el ? el.dataset.deleteUrl : '';
|
||||
this.adminUrl = el ? el.dataset.adminUrl : '';
|
||||
this.reportUrl = el ? el.dataset.reportUrl : '';
|
||||
this.uncensorUrl = el ? el.dataset.uncensorUrl : '';
|
||||
this.isVideo = el ? el.dataset.video !== undefined : false;
|
||||
document.getElementById("lg-admin").href = this.adminUrl;
|
||||
const ownerId = el ? el.dataset.ownerId : null;
|
||||
const canDelete = this.isStaff || (ownerId && ownerId === this.userId);
|
||||
document.getElementById("lg-delete").style.display = canDelete ? 'block' : 'none';
|
||||
document.getElementById("lg-report").style.display = canDelete ? 'none' : 'block';
|
||||
document.getElementById("lg-report").style.display = (!canDelete && this.reportUrl) ? 'block' : 'none';
|
||||
const isCensored = el ? el.dataset.isPublic === 'false' : false;
|
||||
document.getElementById("lg-restore").style.display = (this.canResolveCensorship && isCensored) ? 'block' : 'none';
|
||||
document.getElementById("lg-restore").style.display = (this.canResolveCensorship && isCensored && this.uncensorUrl) ? 'block' : 'none';
|
||||
}
|
||||
|
||||
// Event called when user clicks the restore (uncensor) button
|
||||
|
|
@ -66,11 +74,12 @@ class lgAdmin {
|
|||
const photoId = this.photoId;
|
||||
let data = new FormData();
|
||||
data.append('csrfmiddlewaretoken', this.csrfToken);
|
||||
fetch(`/photo/${photoId}/uncensor/`, {
|
||||
fetch(this.uncensorUrl, {
|
||||
method: "POST",
|
||||
body: data,
|
||||
credentials: 'same-origin',
|
||||
}).then(() => {
|
||||
}).then(response => {
|
||||
if (!response.ok) { console.error('Uncensor failed', response.status, this.uncensorUrl); return; }
|
||||
const el = document.querySelector(`[data-slide-name='${photoId}']`);
|
||||
if (el) {
|
||||
el.dataset.isPublic = 'true';
|
||||
|
|
@ -132,7 +141,7 @@ class lgAdmin {
|
|||
const currentIndex = this.core.index;
|
||||
let data = new FormData();
|
||||
data.append('csrfmiddlewaretoken', this.csrfToken);
|
||||
fetch(`/photo/${photoId}/delete/`, {
|
||||
fetch(this.deleteUrl, {
|
||||
method: "POST",
|
||||
redirect: "manual", // do not load gallery again
|
||||
body: data,
|
||||
|
|
@ -150,7 +159,7 @@ class lgAdmin {
|
|||
const currentIndex = this.core.index;
|
||||
let data = new FormData();
|
||||
data.append('csrfmiddlewaretoken', this.csrfToken);
|
||||
fetch(`/photo/${photoId}/report/`, {
|
||||
fetch(this.reportUrl, {
|
||||
method: "POST",
|
||||
redirect: "manual", // do not load gallery again
|
||||
body: data,
|
||||
|
|
|
|||
8
photologue/static/lightgallery/plugins/video/lg-video.min.js
vendored
Normal file
8
photologue/static/lightgallery/plugins/video/lg-video.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue