From 9ef452832dfda1b09acbf64e1b06f94a4d2ac9f2 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Feb 2019 00:14:40 +0530 Subject: [PATCH 1/9] fix migration --- static/js/viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/viewer.js b/static/js/viewer.js index 362e178..bfec72e 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -61,7 +61,7 @@ oml.ui.viewer = function() { note = data.notes[0] delete data.notes } - addAnnotation(data, false) + oml.api.addAnnotation(data) if (note) { data.notes = [note] } else { From edbe4da011835001c6482cd6e3fa54defe213384 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Feb 2019 00:20:26 +0530 Subject: [PATCH 2/9] add annotations to db --- static/js/viewer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/js/viewer.js b/static/js/viewer.js index bfec72e..bcd1d13 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -61,7 +61,10 @@ oml.ui.viewer = function() { note = data.notes[0] delete data.notes } - oml.api.addAnnotation(data) + var a = Ox.extend({}, data) + a.created = a.created || (new Date).toISOString(); + a.item = ui.item + oml.api.addAnnotation(a) if (note) { data.notes = [note] } else { From b181575a37ea6ab82466271cfdf642c8a18b5ac0 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Feb 2019 00:25:00 +0530 Subject: [PATCH 3/9] migrate again --- static/js/viewer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/js/viewer.js b/static/js/viewer.js index bcd1d13..eb4d902 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -93,9 +93,14 @@ oml.ui.viewer = function() { oml.api.getAnnotations({ id: ui.item }, function(result) { - console.log(result) - annotations = result.data.annotations - callback && callback(annotations) + if (!result.data.annotations.length && localStorage[oml.user.ui.item + '.annotations_']) { + localStorage[oml.user.ui.item + '.annotations'] = localStorage[oml.user.ui.item + '.annotations_'] + loadAnnotations(callback) + + } else { + annotations = result.data.annotations + callback && callback(annotations) + } }) } } From eeee4f5a285e44e71553d9338039483c018c2af8 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Feb 2019 14:08:52 +0530 Subject: [PATCH 4/9] only delete own annotations --- static/js/annotation.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/static/js/annotation.js b/static/js/annotation.js index 13887c6..6df2090 100644 --- a/static/js/annotation.js +++ b/static/js/annotation.js @@ -73,9 +73,11 @@ oml.ui.annotation = function(annotation, $iframe) { borderBottom: '1px solid rgb(208, 208, 208)', }).bindEvent({ key_delete: function() { - that.triggerEvent('delete', { - id: annotation.id - }) + if (annotation.user == oml.user.id) { + that.triggerEvent('delete', { + id: annotation.id + }) + } } }).append($quote).append($notes); @@ -98,9 +100,11 @@ oml.ui.annotation = function(annotation, $iframe) { } } that.delete = function() { - that.triggerEvent('delete', { - id: annotation.id - }) + if (annotation.user == oml.user.id) { + that.triggerEvent('delete', { + id: annotation.id + }) + } } that.deselect = function() { that.removeClass('selected') From 85e315be403421f2af47bfecd4ae2d350e8c81a8 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Feb 2019 13:00:06 +0530 Subject: [PATCH 5/9] show annotations in fullscreen mode --- static/css/oml.css | 10 ++++++++++ static/js/fullscreenButton.js | 4 ++-- static/js/mainMenu.js | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/static/css/oml.css b/static/css/oml.css index 946e463..375341b 100644 --- a/static/css/oml.css +++ b/static/css/oml.css @@ -39,3 +39,13 @@ .OxAnnotationFolder div.OxInput { background-image: none; } + +.OxThemeOxlight .OxAnnotationFolder { + background-color: rgb(240, 240, 240); +} +.OxThemeOxmedium .OxAnnotationFolder { + background-color: rgb(144, 144, 144); +} +.OxThemeOxdark .OxAnnotationFolder { + background-color: rgb(16, 16, 16); +} diff --git a/static/js/fullscreenButton.js b/static/js/fullscreenButton.js index 5ab741e..f8b49d0 100644 --- a/static/js/fullscreenButton.js +++ b/static/js/fullscreenButton.js @@ -16,7 +16,7 @@ oml.ui.fullscreenButton = function() { }) .bindEvent({ click: function() { - Ox.Fullscreen.enter(oml.$ui.viewer.find('iframe')[0]); + Ox.Fullscreen.enter(oml.$ui.viewer[0]); }, oml_itemview: function() { that.updateElement(); @@ -31,4 +31,4 @@ oml.ui.fullscreenButton = function() { return that.updateElement(); -}; \ No newline at end of file +}; diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index 039595a..f9e9388 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -566,7 +566,7 @@ oml.ui.mainMenu = function() { ? 'openPreview' : 'closePreview' ](); } else if (id == 'fullscreen') { - Ox.Fullscreen.enter(oml.$ui.viewer.find('iframe')[0]); + Ox.Fullscreen.enter(oml.$ui.viewer[0]); } else if (id == 'debugmode') { if (oml.localStorage('enableDebugMode')) { oml.localStorage['delete']('enableDebugMode'); From 82d7f85bdb2af6bc526675c4725b521d26ed219d Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Feb 2019 13:36:31 +0530 Subject: [PATCH 6/9] go back to current list --- static/js/folders.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/static/js/folders.js b/static/js/folders.js index b96e9c7..9e8718e 100644 --- a/static/js/folders.js +++ b/static/js/folders.js @@ -111,6 +111,11 @@ oml.ui.folders = function() { oml.UI.set({find: getFind('')}); oml.$ui.librariesList.options({selected: ['']}); }, + singleclick: function(data) { + oml.UI.set({ + find: getFind('') + }); + }, selectnext: function() { oml.UI.set(Ox.extend( {find: getFind(':')}, @@ -201,7 +206,14 @@ oml.ui.folders = function() { !index && oml.addList(); }, select: function(data) { - oml.UI.set({find: getFind(data.ids[0])}); + oml.UI.set({ + find: getFind(data.ids[0]), + }); + }, + singleclick: function(data) { + oml.UI.set({ + find: getFind(oml.$ui.libraryList[index].options('selected')[0]) + }); }, selectnext: function() { oml.UI.set({find: getFind(inboxId)}); @@ -290,6 +302,11 @@ oml.ui.folders = function() { open: function(data) { !index && !Ox.contains(data.ids, ':Inbox') && oml.ui.listDialog().open(); }, + singleclick: function(data) { + oml.UI.set({ + find: getFind(oml.$ui.folderList[index].options('selected')[0]) + }); + }, select: function(data) { oml.UI.set({find: getFind(data.ids[0])}); }, From 054edd8a41195b98a6ac1cb31c5564f6f2e71f33 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Feb 2019 13:36:45 +0530 Subject: [PATCH 7/9] linux placeholder --- oml/fulltext.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/oml/fulltext.py b/oml/fulltext.py index d1cd5ee..67ca6bf 100644 --- a/oml/fulltext.py +++ b/oml/fulltext.py @@ -32,6 +32,18 @@ def find_fulltext_windows(query): books = [b.split(':')[0] for b in books] return get_ids(books, prefix) +def find_fulltext_linux(query): + prefix = get_prefix() + cmd = [ + 'tracker', + 'sparql', + '-q', + "SELECT nie:url(?f) WHERE { ?f fts:match '%s' FILTER (tracker:uri-is-descendant ('file://%s', nie:url (?u))) }" % (query, prefix) + ] + books = subprocess.check_output(cmd).decode().strip().split('\n') + books = [b.split(':')[0] for b in books] + return get_ids(books, prefix) + def find_fulltext(query): ids = [] if sys.platform == 'darwin': From 6115850f1747ce4360a7d3d6838cd2ffd3bde2c7 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Feb 2019 13:38:41 +0530 Subject: [PATCH 8/9] load without sidebar --- static/js/itemViewPanel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/itemViewPanel.js b/static/js/itemViewPanel.js index 8052978..e7aa45c 100644 --- a/static/js/itemViewPanel.js +++ b/static/js/itemViewPanel.js @@ -17,7 +17,7 @@ oml.ui.itemViewPanel = function() { ], orientation: 'horizontal', selected: ui.itemView, - size: window.innerWidth - ui.sidebarSize - 1 + size: window.innerWidth - (ui.showSidebar ? ui.sidebarSize : 0) - 1 }) .bindEvent({ oml_itemview: function(data) { @@ -27,4 +27,4 @@ oml.ui.itemViewPanel = function() { return that; -}; \ No newline at end of file +}; From ee315399bbc2e4645f37680f78eab4e622fe15d8 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Feb 2019 13:57:27 +0530 Subject: [PATCH 9/9] linux fulltext search --- oml/fulltext.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/oml/fulltext.py b/oml/fulltext.py index 67ca6bf..4ebe255 100644 --- a/oml/fulltext.py +++ b/oml/fulltext.py @@ -2,6 +2,7 @@ import logging import os import subprocess import sys +from urllib.parse import quote, unquote from sqlalchemy.sql import operators @@ -14,6 +15,8 @@ def get_prefix(): def get_ids(books): from item.models import File + if not books: + return [] ids = [b[0] for b in File.query.filter(operators.in_op(File.path, books)).values('sha1')] return ids @@ -34,23 +37,29 @@ def find_fulltext_windows(query): def find_fulltext_linux(query): prefix = get_prefix() + prefix_url = quote(prefix) cmd = [ 'tracker', 'sparql', '-q', - "SELECT nie:url(?f) WHERE { ?f fts:match '%s' FILTER (tracker:uri-is-descendant ('file://%s', nie:url (?u))) }" % (query, prefix) + "SELECT nie:url(?f) WHERE { ?f fts:match '%s' FILTER (tracker:uri-is-descendant ('file://%s', nie:url (?f))) }" % (query, prefix_url) ] books = subprocess.check_output(cmd).decode().strip().split('\n') - books = [b.split(':')[0] for b in books] - return get_ids(books, prefix) + books = [ + unquote(r.strip()).replace('file://', '')[len(prefix):] + for r in books if r.strip().startswith('file://') + ] + return get_ids(books) def find_fulltext(query): ids = [] if sys.platform == 'darwin': ids = find_fulltext_macos(query) + elif sys.platform == 'linux': + ids = find_fulltext_linux(query) else: logger.debug('missing fulltext search implementation for %s', sys.platform) return ids def platform_supported(): - return sys.platform == 'darwin' + return sys.platform in ('darwin', 'linux')