diff --git a/README.md b/README.md index bceafd1..95ee960 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ or SixSS (https://sixxs.net). Development ----------- -On Linux you need to always install python-imaging python-lxml ghostscript: +On Linux you need to always install PIL, pyhon-lxml and poppler-utils: - apt-get install python-imaging python-lxml ghostscript poppler-utils + apt-get install python-imaging python-lxml poppler-utils Now checkout the source and prepare for use: diff --git a/oml/media/pdf.py b/oml/media/pdf.py index df62a81..9bb493e 100644 --- a/oml/media/pdf.py +++ b/oml/media/pdf.py @@ -25,29 +25,53 @@ def cover(pdf): return page(pdf, 1) def ql_cover(pdf): - tmp = tempfile.mkdtemp() - cmd = [ - 'qlmanage', - '-t', - '-s', - '1024', - '-o', - tmp, - pdf - ] - p = subprocess.Popen(cmd) - p.wait() - image = glob('%s/*' % tmp) - if image: - image = image[0] - with open(image, 'rb') as fd: - data = fd.read() - else: - logger.debug('qlmanage did not create cover for %s', pdf) - data = None - shutil.rmtree(tmp) - return data + tmp = tempfile.mkdtemp() + cmd = [ + 'qlmanage', + '-t', + '-s', + '1024', + '-o', + tmp, + pdf + ] + p = subprocess.Popen(cmd) + p.wait() + image = glob('%s/*' % tmp) + if image: + image = image[0] + with open(image, 'rb') as fd: + data = fd.read() + else: + logger.debug('qlmanage did not create cover for %s', pdf) + data = None + shutil.rmtree(tmp) + return data +def page(pdf, page): + tmp = tempfile.mkdtemp() + cmd = [ + 'pdftocairo', + pdf, + '-jpeg', + '-f', str(page), '-l', str(page), + '-scale-to', '1024', '-cropbox', + os.path.join(tmp, 'page') + ] + p = subprocess.Popen(cmd) + p.wait() + image = glob('%s/*' % tmp) + if image: + image = image[0] + with open(image, 'rb') as fd: + data = fd.read() + else: + logger.debug('pdftocairo %s %s', pdf, ' '.join(cmd)) + data = None + shutil.rmtree(tmp) + return data + +''' def page(pdf, page): image = tempfile.mkstemp('.jpg')[1] cmd = [ @@ -69,6 +93,7 @@ def page(pdf, page): data = fd.read() os.unlink(image) return data +''' def info(pdf): data = {} diff --git a/oml/user/api.py b/oml/user/api.py index 23baecd..f4193cd 100644 --- a/oml/user/api.py +++ b/oml/user/api.py @@ -255,6 +255,7 @@ def editUser(data): del p.info['nickname'] p.update_name() p.save() + return p.json() return {} actions.register(editUser, cache=False) diff --git a/static/js/folders.js b/static/js/folders.js index 2567111..c27cbe0 100644 --- a/static/js/folders.js +++ b/static/js/folders.js @@ -306,6 +306,10 @@ oml.ui.folders = function() { }); }; + that.updateUser = function(id, name) {s + // ... + }; + oml.bindEvent({ activity: function(data) { if (data.activity == 'import') { diff --git a/static/js/usersDialog.js b/static/js/usersDialog.js index b899dbb..8933f1c 100644 --- a/static/js/usersDialog.js +++ b/static/js/usersDialog.js @@ -269,8 +269,15 @@ oml.ui.usersDialog = function() { id: user.id, nickname: data.value }, function(result) { - Ox.print('EDIT USER', result.data); - // ... + Ox.print('EDIT USER', result.data, folder); + // FIXME: ugly + Ox.forEach($lists, function($list) { + var selected = $list.options('selected'); + if (selected.length) { + $list.value(user.id, 'name', result.data.name); + return false; + } + }); }); } }) @@ -479,6 +486,14 @@ oml.ui.usersDialog = function() { height: folder.items.length * 16 + 'px' }) .bindEvent({ + move: function(data) { + Ox.print('MOVE', data) + oml.api.sortUsers({ + ids: data.ids + }, function(result) { + Ox.print('USER ORDER CHANGED', result.data); + }); + }, select: function(data) { if (data.ids.length) { selectItem($list); @@ -554,7 +569,8 @@ oml.ui.usersDialog = function() { folder.items.length ? renderUserList(folder) : renderSectionList(folder) - ).appendTo($folders[index].$content) + ) + .appendTo($folders[index].$content) ); });