From ebff5a81532b99a8b5f80092448e153bfe50e739 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 25 Jan 2019 14:47:36 +0530 Subject: [PATCH 1/3] fix UI path with space --- ctl | 2 +- oml/ui.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ctl b/ctl index 805595c..1abac88 100755 --- a/ctl +++ b/ctl @@ -187,7 +187,7 @@ fi if [ "$1" == "ui" ]; then shift - $PYTHON "$NAME/oml/ui.py" $@ + $PYTHON "$NAME/oml/ui.py" "$@" exit $? fi if [ "$1" == "init" ]; then diff --git a/oml/ui.py b/oml/ui.py index ba4630a..5b9dc26 100644 --- a/oml/ui.py +++ b/oml/ui.py @@ -104,7 +104,8 @@ if __name__ == '__main__': if len(sys.argv) >= 3: base = sys.argv[2] base = os.path.expanduser(base) - os.chdir(base) + if os.path.exists(base): + os.chdir(base) if len(sys.argv) >= 2 and sys.argv[1] == 'folder': print(ui.selectFolder({})) else: From 0bfbebb21d4989bdabd90580531f9f91d543f865 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 25 Jan 2019 16:36:54 +0530 Subject: [PATCH 2/3] gtkstatus is broken, just launch oml for now --- ctl | 10 ++++++---- oml/gtkstatus.py | 14 +++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ctl b/ctl index 1abac88..4c05511 100755 --- a/ctl +++ b/ctl @@ -162,12 +162,14 @@ if [ "$1" == "open" ]; then xdg-open "file://${BASE}/openmedialibrary/static/html/load.html" fi else - $PYTHON "${NAME}/oml/gtkstatus.py" $@ - exit $? + #$PYTHON "${NAME}/oml/gtkstatus.py" $@ + #exit $? + "$0" start & fi else - $PYTHON "$NAME/oml/gtkstatus.py" $@ - exit $? + #$PYTHON "$NAME/oml/gtkstatus.py" $@ + #exit $? + "$0" start & fi fi exit 0 diff --git a/oml/gtkstatus.py b/oml/gtkstatus.py index 726afc5..d9abb0d 100644 --- a/oml/gtkstatus.py +++ b/oml/gtkstatus.py @@ -22,6 +22,18 @@ title = "Open Media Library" ctl = base + '/ctl' +def check_pid(pid): + if not os.path.exists(pid): + return False + try: + with open(pid, 'r') as fd: + pid = int(fd.read().strip()) + os.kill(pid, 0) + except OSError: + return False + else: + return True + class OMLIcon: menu = None icon = None @@ -81,7 +93,7 @@ class OMLIcon: @classmethod def is_running(cls): pid = cls.get_pid() - if pid and os.path.exists(pid): + if pid and check_pid(pid): return True else: return False From d97d396ef306a4bba9ab156f470c9db6d435d4d0 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 25 Jan 2019 16:38:45 +0530 Subject: [PATCH 3/3] scroll select annotation into view --- static/reader/pdf.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/reader/pdf.js b/static/reader/pdf.js index 6e095f1..15b4487 100644 --- a/static/reader/pdf.js +++ b/static/reader/pdf.js @@ -11,14 +11,21 @@ Ox.load({ console.log('got', event, 'data', data) if (event == 'selectAnnotation') { var annotation = annotations.filter(function(a) { return a.id == data.id })[0] + var delay = 0 if ( annotation && annotation.page && PDFViewerApplication.pdfViewer.currentPageNumber != annotation.page ) { - //FIXME: scroll into view PDFViewerApplication.pdfViewer.currentPageNumber = annotation.page; + delay = 250 } + setTimeout(function() { + var el = document.querySelector('.a' + annotation.id); + if (el) { + document.querySelector('#viewerContainer').scrollTop = el.offsetTop + el.parentElement.offsetTop - 64; + } + }, delay) selectAnnotation(data.id) } else if (event == 'addAnnotations') { data.annotations.forEach(function(annotation) {