Compare commits

...

3 commits

Author SHA1 Message Date
j
0da9097a6a use first format by default 2025-01-31 12:33:34 +05:30
j
017d9be45a add .tiff as supported image format 2025-01-31 10:40:04 +05:30
j
9eb9fbe3a5 cTA 2025-01-30 19:09:43 +05:30
7 changed files with 32 additions and 14 deletions

View file

@ -553,7 +553,7 @@ class File(models.Model):
def process_stream(self):
'''
extract derivatives from webm upload
extract derivatives from stream upload
'''
from . import tasks
return tasks.process_stream.delay(self.id)

View file

@ -56,6 +56,7 @@
"canExportAnnotations": {"friend": true, "staff": true, "admin": true},
"canImportAnnotations": {"staff": true, "admin": true},
"canImportItems": {},
"canTranscribeAudio": {},
"canManageDocuments": {"staff": true, "admin": true},
"canManageEntities": {"staff": true, "admin": true},
"canManageHome": {},

View file

@ -58,6 +58,7 @@
"canImportAnnotations": {"researcher": true, "staff": true, "admin": true},
// import needs to handle itemRequiresVideo=false first
"canImportItems": {},
"canTranscribeAudio": {},
"canManageDocuments": {"member": true, "researcher": true, "staff": true, "admin": true},
"canManageEntities": {"member": true, "researcher": true, "staff": true, "admin": true},
"canManageHome": {"staff": true, "admin": true},

View file

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from glob import glob
import mimetypes
import os
import re
from glob import glob
import unicodedata
import ox
@ -379,11 +380,13 @@ actions.register(sortDocuments, cache=False)
def file(request, id, name=None):
document = get_document_or_404_json(request, id)
accept = request.headers.get("Accept")
mime_type = mimetypes.guess_type(document.file.path)[0]
mime_type = 'image/%s' % document.extension
if accept and 'image/' in accept and document.extension in (
'webp', 'heif', 'heic', 'avif'
) and document.extension not in accept:
'webp', 'heif', 'heic', 'avif', 'tiff'
) and mime_type not in accept:
image_size = max(document.width, document.height)
return HttpFileResponse(document.thumbnail(image_size))
return HttpFileResponse(document.thumbnail(image_size, accept=accept))
return HttpFileResponse(document.file.path)
def thumbnail(request, id, size=256, page=None):

View file

@ -1004,7 +1004,9 @@ def download_source(request, id, part=None):
response['Content-Disposition'] = "attachment; filename*=UTF-8''%s" % quote(filename.encode('utf-8'))
return response
def download(request, id, resolution=None, format='webm', part=None):
def download(request, id, resolution=None, format=None, part=None):
if format is None:
format = settings.CONFIG['video']['formats'][0]
item = get_object_or_404(models.Item, public_id=id)
if not resolution or int(resolution) not in settings.CONFIG['video']['resolutions']:
resolution = max(settings.CONFIG['video']['resolutions'])

View file

@ -8,8 +8,6 @@ pandora.ui.uploadDocumentDialog = function(options, callback) {
existingFiles = [],
uploadFiles = [],
supportedExtensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png', 'webp', 'heic', 'heif', 'avif'],
filename,
ids = [],
@ -72,7 +70,7 @@ pandora.ui.uploadDocumentDialog = function(options, callback) {
});
if (!Ox.every(extensions, function(extension) {
return Ox.contains(supportedExtensions, extension)
return Ox.contains(pandora.documentExtensions, extension)
})) {
return errorDialog(
Ox._('Supported file types are GIF, JPG, PNG and PDF.')

View file

@ -420,13 +420,28 @@ pandora.createLinks = function($element) {
});
};
pandora.imageExtensions = [
'avif',
'gif',
'heic',
'heif',
'jpeg',
'jpg',
'png',
'tiff',
'webp'
];
pandora.documentExtensions = [
'pdf', /* 'epub', 'txt', */
].concat(pandora.imageExtensions);
pandora.uploadDroppedFiles = function(files) {
var documentExtensions = ['pdf', /* 'epub', 'txt', */ 'png', 'gif', 'jpg', 'jpeg', 'webp', 'heic', 'heif', 'avif'];
files = Ox.map(files, function(file) { return file });
if (files.every(function(file) {
var extension = file.name.split('.').pop().toLowerCase()
return Ox.contains(documentExtensions, extension)
return Ox.contains(pandora.documentExtensions, extension)
})) {
pandora.ui.uploadDocumentDialog({
files: files
@ -2132,9 +2147,7 @@ pandora.getSpan = function(state, val, callback) {
} else {
state.span = val;
}
} else if (Ox.contains([
'gif', 'gif', 'jpg', 'png', 'webp', 'heic', 'heif', 'avif'
], extension)) {
} else if (Ox.contains(pandora.imageExtensions, extension)) {
values = val.split(',');
if (values.length == 4) {
state.span = values.map(function(number, index) {