From 97364e4ee7a88a80e3f17ad777de964eb1e14fdf Mon Sep 17 00:00:00 2001 From: j Date: Thu, 5 Dec 2019 13:08:26 +0000 Subject: [PATCH 1/2] add volume from title --- cleanup/add_volume.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 cleanup/add_volume.py diff --git a/cleanup/add_volume.py b/cleanup/add_volume.py new file mode 100755 index 0000000..4aeae0d --- /dev/null +++ b/cleanup/add_volume.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +import re + +import ox +import ox.api + +site = 'archive.leftove.rs' +api = ox.api.signin('https://%s/api/' % site) + +for regex, fragments in ( + ['Vol. \d+, No. \d+', ['Vol.', 'No.']], + ['Vol \d+ no \d+', [' Vol ', ' no ']], + ['Vol:\d+ #\d+', ['Vol:', '#']], +): + for doc in api.findDocuments({ + 'query': { + 'conditions': [ + {'key': 'title', 'operator': '=', 'value': fragment} + for fragment in fragments + ], + 'operator': '&' + }, + 'keys': ['id', 'title', 'volume'], + 'range': [0, 10000] + })['data']['items']: + if 'Vol' not in doc.get('volume', ''): + m = re.compile(regex).findall(doc['title']) + if m: + print(m[0], doc['id'], doc['title']) + api.editDocument({ + 'id': doc['id'], + 'volume': m[0].strip() + }) From 5bc039e965c2f48c5eb0c0d5a9ee4d350709f8b9 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 5 Dec 2019 14:38:52 +0000 Subject: [PATCH 2/2] image preview --- static/js/documentInfoView.leftovers.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static/js/documentInfoView.leftovers.js b/static/js/documentInfoView.leftovers.js index 18f8b47..c4c408b 100644 --- a/static/js/documentInfoView.leftovers.js +++ b/static/js/documentInfoView.leftovers.js @@ -303,15 +303,18 @@ pandora.ui.documentInfoView = function(data, isMixed) { } // Preview - if (data.extension == 'pdf' && !isMultiple) { + if (!isMultiple && data.extension != 'html') { + var $div = $('
').css({ marginTop: '12px', }).html( - Ox.range(1, data.dimensions + 1).map(function(page) { + data.extension == 'pdf' + ? Ox.range(1, data.dimensions + 1).map(function(page) { return '' - }).join('\n') + }).join('\n') + : ('') ) pandora.createLinks($div); $div.appendTo($text)