From 9c82a18585ed0ac6483a8f0d02a900a9d49215fe Mon Sep 17 00:00:00 2001 From: j Date: Thu, 18 Jul 2019 11:24:04 +0200 Subject: [PATCH 001/139] use lower value --- etc/nginx/pandora | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/nginx/pandora b/etc/nginx/pandora index 24125480..8ef1f433 100644 --- a/etc/nginx/pandora +++ b/etc/nginx/pandora @@ -42,7 +42,7 @@ server { proxy_set_header Proxy ""; proxy_redirect off; proxy_buffering off; - proxy_read_timeout 999999999; + proxy_read_timeout 99999; proxy_pass http://127.0.0.1:2622/; } From 97b5c0538a2c7d21709aa28fb9896ae1505c5170 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Jul 2019 12:21:45 +0200 Subject: [PATCH 002/139] use bionic for VM --- vm/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/build.sh b/vm/build.sh index 0f2f86bc..c1940ba9 100755 --- a/vm/build.sh +++ b/vm/build.sh @@ -5,11 +5,11 @@ BASE=`pwd` VERSION=`cd ..;git rev-list HEAD --count` TARGET=${BASE}/pandora-r${VERSION}.vdi -img=xenial-server-cloudimg-amd64-disk1.img +img=bionic-server-cloudimg-amd64.img if [ ! -e $img ]; then echo downloading $img - curl -s -O https://cloud-images.ubuntu.com/xenial/current/$img + curl -s -O https://cloud-images.ubuntu.com/bionic/current/$img fi echo preparing ${TARGET}.img cp -a $img ${TARGET}.img From 2650e5b50b8b667f6231b254fda90afd8198aaa8 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Jul 2019 12:55:05 +0200 Subject: [PATCH 003/139] 2 cores are enough to build --- vm/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/build.sh b/vm/build.sh index c1940ba9..06ee5817 100755 --- a/vm/build.sh +++ b/vm/build.sh @@ -19,7 +19,7 @@ qemu-img resize ${TARGET}.img +998G echo boot image and install pandora kvm -m 1024 \ - -smp 4 \ + -smp 2 \ -cdrom seed.img \ -device e1000,netdev=user.0 \ -netdev user,id=user.0,hostfwd=tcp::5555-:22,hostfwd=tcp::2620-:80 \ From 0076aae8968c937017cabceb7d748f13c13681a5 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Jul 2019 19:04:12 +0200 Subject: [PATCH 004/139] import drag and drop files --- static/js/addItemDialog.js | 9 +++++++ static/js/importScreen.js | 54 ++++++++++++++++++++++++++++++++++++++ static/js/pandora.js | 31 ++++++++++++++++++++++ static/js/utils.js | 25 ++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 static/js/importScreen.js diff --git a/static/js/addItemDialog.js b/static/js/addItemDialog.js index 465a8da7..71361fda 100644 --- a/static/js/addItemDialog.js +++ b/static/js/addItemDialog.js @@ -69,6 +69,15 @@ pandora.ui.addItemDialog = function(options) { title: Ox._('Add {0}', [pandora.site.itemName.singular]), width: 544 }); + if (options.files) { + that.options({content: $screen.start()}); + $button.options({disabled: true}); + Ox.serialMap(options.files, function(file, index, files, callback) { + getFileInfo(file, function(info) { + callback(Ox.extend(info, {file: file})); + }); + }, onInfo); + } function createButton() { $button = Ox[selected == 'upload' ? 'FileButton' : 'Button']({ diff --git a/static/js/importScreen.js b/static/js/importScreen.js new file mode 100644 index 00000000..8749647c --- /dev/null +++ b/static/js/importScreen.js @@ -0,0 +1,54 @@ +'use strict'; + +pandora.ui.importScreen = function() { + + var that = Ox.Element() + .attr({id: 'importScreen'}) + .css({ + position: 'absolute', + left: 0, + top: 0, + right: 0, + bottom: 0, + backgroundColor: 'rgba(0, 0, 0, 0.5)', + zIndex: 1000 + }) + .on({ + click: function() { + that.remove(); + }, + dragleave: function() { + that.remove(); + } + }); + + Ox.Element() + .css({ + position: 'absolute', + left: 0, + top: 0, + right: 0, + bottom: 0, + width: pandora.hasCapability('canAddItems') ? 192 : 256, + height: 16, + padding: '8px 0', + borderRadius: 8, + margin: 'auto', + background: 'rgba(255, 255, 255, 0.9)', + fontSize: 13, + color: 'rgb(0, 0, 0)', + textAlign: 'center' + }) + .text( + Ox._(pandora.hasCapability('canAddItems') ? ( + 'Import {0}' + ) : ( + 'You are not allowed to import {0}' + ), + [pandora.user.ui.section == 'documents' ? 'Documents' : pandora.site.itemName.plural]) + ) + .appendTo(that); + + return that; + +}; diff --git a/static/js/pandora.js b/static/js/pandora.js index 0962c235..0c0f76ba 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -281,6 +281,37 @@ appPanel resize: pandora.resizeWindow, unload: pandora.unloadWindow }) + Ox.$document.on({ + dragenter: function(event) { + if (Ox.contains(event.originalEvent.dataTransfer.types, 'Files')) { + event.originalEvent.preventDefault(); + event.originalEvent.stopPropagation(); + if (!$('#importScreen').length) { + pandora.ui.importScreen().appendTo(Ox.$body); + } + } else { + console.log(event.originalEvent.dataTransfer); + } + }, + dragover: function(event) { + event.originalEvent.preventDefault(); + event.originalEvent.stopPropagation(); + }, + dragstart: function(event) { + event.originalEvent.preventDefault(); + event.originalEvent.stopPropagation(); + }, + drop: function(event) { + $('#importScreen').remove(); + if (pandora.hasCapability('canAddItems')) { + if (event.originalEvent.dataTransfer.files.length) { + event.originalEvent.preventDefault(); + event.originalEvent.stopPropagation(); + pandora.uploadDroppedFiles(event.originalEvent.dataTransfer.files) + } + } + } + }); Ox.extend(pandora, { $ui: {}, site: data.site, diff --git a/static/js/utils.js b/static/js/utils.js index 5825e724..8bb3a9dc 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -404,6 +404,31 @@ pandora.createLinks = function($element) { }); }; +pandora.uploadDroppedFiles = function(files) { + var documentExtensions = ['pdf', /* 'epub', 'txt', */ 'png', 'gif', 'jpg']; + 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) + })) { + pandora.ui.uploadDocumentDialog({ + files: files + }, function(files) { + if (files) { + Ox.Request.clearCache('findDocuments'); + if (pandora.user.ui.document || pandora.user.ui.section != 'documents') { + pandora.UI.set({section: 'documents', document: ''}); + } else { + pandora.$ui.list && pandora.$ui.list.reloadList(); + } + } + }).open(); + } else { + pandora.ui.addItemDialog({files: files}).open() + } +}; + (function() { pandora.doHistory = function(action, items, targets, index, callback) { From f838a6be6070e872a8e960f0b6f12c8078edd1de Mon Sep 17 00:00:00 2001 From: j Date: Mon, 22 Jul 2019 11:11:04 +0200 Subject: [PATCH 005/139] default to multiple videos --- static/js/addFilesDialog.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/static/js/addFilesDialog.js b/static/js/addFilesDialog.js index 75bdca18..e718b218 100644 --- a/static/js/addFilesDialog.js +++ b/static/js/addFilesDialog.js @@ -117,6 +117,15 @@ pandora.ui.addFilesDialog = function(options) { ) }); } else { + if (options.items.length > 1) { + selectItems.push({ + id: 'multiple', + title: Ox._( + 'Create multiple {0}', + [pandora.site.itemName.plural.toLowerCase()] + ) + }); + } selectItems.push({ id: 'one', title: Ox._( @@ -125,15 +134,6 @@ pandora.ui.addFilesDialog = function(options) { ) }); } - if (options.items.length > 1) { - selectItems.push({ - id: 'multiple', - title: Ox._( - 'Create multiple {0}', - [pandora.site.itemName.plural.toLowerCase()] - ) - }); - } var $select = Ox.Select({ items: selectItems, width: 256 From 33b105b9b80ede56c8c93261934d86758d9fef54 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 22 Jul 2019 11:11:25 +0200 Subject: [PATCH 006/139] avoid password autocompltee --- static/js/preferencesDialog.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/static/js/preferencesDialog.js b/static/js/preferencesDialog.js index aa74d003..70af78f2 100644 --- a/static/js/preferencesDialog.js +++ b/static/js/preferencesDialog.js @@ -47,6 +47,9 @@ pandora.ui.preferencesDialog = function() { validate: pandora.validateNewPassword, width: 320 }) + .attr({ + autocomplete: 'new-password' + }) .bindEvent({ validate: function(data) { data.valid && pandora.api.editPreferences({password: data.value}); From 115f05625c3dc9872a4250251ebfb887825723d5 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 22 Jul 2019 11:11:34 +0200 Subject: [PATCH 007/139] ignore old migrations --- update.py | 1 + 1 file changed, 1 insertion(+) diff --git a/update.py b/update.py index 41283454..119f9adb 100755 --- a/update.py +++ b/update.py @@ -332,6 +332,7 @@ if __name__ == "__main__": '-- Model missing for table: djcelery_intervalschedule\n', '-- Model missing for table: djcelery_workerstate\n', '-- Model missing for table: djcelery_taskstate\n', + '-- Model missing for table: south_migrationhistory\n', '-- Model missing for table: cache\n', ]: if row in diff: From 0b8ea2d517e694dd7fce9aa8ca973daac37bc7a9 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 22 Jul 2019 11:11:42 +0200 Subject: [PATCH 008/139] space --- static/js/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/utils.js b/static/js/utils.js index 8bb3a9dc..79ab43d8 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -406,7 +406,7 @@ pandora.createLinks = function($element) { pandora.uploadDroppedFiles = function(files) { var documentExtensions = ['pdf', /* 'epub', 'txt', */ 'png', 'gif', 'jpg']; - files = Ox.map(files, function(file) { return file}); + files = Ox.map(files, function(file) { return file }); if (files.every(function(file) { var extension = file.name.split('.').pop().toLowerCase() From a786f5d9bcb1d1a90faff2934611b3daaf4f50d2 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Jul 2019 11:26:13 +0200 Subject: [PATCH 009/139] remove unused code --- static/js/uploadVideoDialog.js | 599 --------------------------------- static/js/utils.js | 5 +- 2 files changed, 2 insertions(+), 602 deletions(-) delete mode 100644 static/js/uploadVideoDialog.js diff --git a/static/js/uploadVideoDialog.js b/static/js/uploadVideoDialog.js deleted file mode 100644 index cb455a67..00000000 --- a/static/js/uploadVideoDialog.js +++ /dev/null @@ -1,599 +0,0 @@ -'use strict'; - -pandora.ui.uploadVideoDialog = function(data) { - - var cancelled = false, - file, - hasFirefogg = !(Ox.isUndefined(window.Firefogg)) && ( - $.browser.version < '35' || Firefogg().version >= 334 - ), - infoContent = Ox._('Please select the video file that you want to upload.'), - itemView = pandora.hasCapability('canSeeExtraItemViews') ? 'media' : 'info', - selectFile, - $actionButton, - $closeButton, - $content = Ox.Element().css({margin: '16px'}), - $info = $('
') - .css({padding: '4px'}) - .html(infoContent), - $progress, - $status = $('
').css({padding: '4px', paddingTop: '8px'}), - that = Ox.Dialog({ - buttons: [ - $closeButton = Ox.Button({ - id: 'close', - title: Ox._('Close') - }).css({ - float: 'left' - }).bindEvent({ - click: function() { - if ($closeButton.options('title') == Ox._('Cancel')) { - cancelled = true; - $info.html(infoContent); - $status.html(''); - pandora.firefogg && pandora.firefogg.cancel(); - pandora.$ui.upload && pandora.$ui.upload.abort(); - $closeButton.options('title', Ox._('Close')); - if ($actionButton.options('title') == Ox._('Upload')) { - $closeButton.options('title', Ox._('Close')); - $actionButton.replaceWith($actionButton = hasFirefogg - ? getFirefoggButton() - : getSelectVideoButton() - ); - } - $actionButton.show(); - } else { - that.triggerEvent('close'); - } - } - }), - $actionButton = hasFirefogg ? getFirefoggButton() : getSelectVideoButton() - ], - content: $content, - height: 128, - removeOnClose: true, - width: 368, - title: Ox._('Upload Video'), - }) - .bindEvent({ - close: function(data) { - if (pandora.firefogg) { - pandora.firefogg.cancel(); - delete pandora.firefogg; - } - that.close(); - } - }); - - if (!pandora.site.itemRequiresVideo && !pandora.user.ui.item) { - $info.html(Ox._( - 'You can only upload a video to an existing {0}.' - + ' Please check if an entry for the {0}' - + ' you want to upload exists, and create one otherwise.', - [pandora.site.itemName.singular.toLowerCase()] - )); - $actionButton.hide(); - } - $content.append($info); - $content.append($status); - - function aspectratio(ratio) { - var denominator, numerator; - ratio = ratio.split(':'); - numerator = ratio[0]; - if (ratio.length == 2) { - denominator = ratio[1]; - } - if (Math.abs(numerator / denominator - 4/3) < 0.03) { - numerator = 4; - denominator = 3; - } else if (Math.abs(numerator / denominator - 16/9) < 0.02) { - numerator = 16; - denominator = 9; - } - return { - denominator: denominator, - 'float': numerator / denominator, - numerator: numerator, - ratio: numerator + ':' + denominator - }; - } - - function resetProgress(status) { - $progress = Ox.Progressbar({ - progress: 0, - showPercent: true, - showTime: true, - width: 304 - }); - $status.html(status || '').append($progress); - } - - function directUpload(file, info) { - resetProgress(); - pandora.api.addMedia({ - filename: info.name, - id: info.oshash, - item: pandora.site.itemRequiresVideo - ? undefined - : pandora.user.ui.item - }, function(result) { - uploadStream(result.data.item, info, file); - }); - } - - function encode() { - var filename = pandora.firefogg.sourceFilename, - info = JSON.parse(pandora.firefogg.sourceInfo), - item, - oshash = info.oshash; - $info.html('' + filename + '
' + Ox._('encoding...')); - resetProgress(); - pandora.api.addMedia({ - filename: filename, - id: oshash, - info: info, - item: pandora.site.itemRequiresVideo - ? undefined - : pandora.user.ui.item - }, function(result) { - item = result.data.item; - pandora.firefogg.encode( - getEncodingOptions(info), - function(result, file) { - result = JSON.parse(result); - if (result.progress != 1) { - $status.html( - cancelled - ? Ox._('Encoding cancelled.') - : Ox._('Encoding failed.') - ); - delete pandora.firefogg; - return; - } - setTimeout(function() { - $info.html( - '' + filename + '
' - + Ox._('uploading...') - ); - uploadStream(item, info, file); - }); - }, - Ox.throttle(function(progress) { - progress = JSON.parse(progress).progress || 0; - $progress.options({progress: progress}); - }, 1000) - ); - }); - } - - function getInfo(file, callback) { - Ox.oshash(file, function(oshash) { - var $video = $('