Compare commits
9 Commits
e0cba14d6a
...
ee315399bb
Author | SHA1 | Date |
---|---|---|
j | ee315399bb | |
j | 6115850f17 | |
j | 054edd8a41 | |
j | 82d7f85bdb | |
j | 85e315be40 | |
j | eeee4f5a28 | |
j | b181575a37 | |
j | edbe4da011 | |
j | 9ef452832d |
|
@ -2,6 +2,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from urllib.parse import quote, unquote
|
||||||
|
|
||||||
from sqlalchemy.sql import operators
|
from sqlalchemy.sql import operators
|
||||||
|
|
||||||
|
@ -14,6 +15,8 @@ def get_prefix():
|
||||||
|
|
||||||
def get_ids(books):
|
def get_ids(books):
|
||||||
from item.models import File
|
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')]
|
ids = [b[0] for b in File.query.filter(operators.in_op(File.path, books)).values('sha1')]
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
@ -32,13 +35,31 @@ def find_fulltext_windows(query):
|
||||||
books = [b.split(':')[0] for b in books]
|
books = [b.split(':')[0] for b in books]
|
||||||
return get_ids(books, prefix)
|
return get_ids(books, prefix)
|
||||||
|
|
||||||
|
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 (?f))) }" % (query, prefix_url)
|
||||||
|
]
|
||||||
|
books = subprocess.check_output(cmd).decode().strip().split('\n')
|
||||||
|
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):
|
def find_fulltext(query):
|
||||||
ids = []
|
ids = []
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
ids = find_fulltext_macos(query)
|
ids = find_fulltext_macos(query)
|
||||||
|
elif sys.platform == 'linux':
|
||||||
|
ids = find_fulltext_linux(query)
|
||||||
else:
|
else:
|
||||||
logger.debug('missing fulltext search implementation for %s', sys.platform)
|
logger.debug('missing fulltext search implementation for %s', sys.platform)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
def platform_supported():
|
def platform_supported():
|
||||||
return sys.platform == 'darwin'
|
return sys.platform in ('darwin', 'linux')
|
||||||
|
|
|
@ -39,3 +39,13 @@
|
||||||
.OxAnnotationFolder div.OxInput {
|
.OxAnnotationFolder div.OxInput {
|
||||||
background-image: none;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -73,9 +73,11 @@ oml.ui.annotation = function(annotation, $iframe) {
|
||||||
borderBottom: '1px solid rgb(208, 208, 208)',
|
borderBottom: '1px solid rgb(208, 208, 208)',
|
||||||
}).bindEvent({
|
}).bindEvent({
|
||||||
key_delete: function() {
|
key_delete: function() {
|
||||||
that.triggerEvent('delete', {
|
if (annotation.user == oml.user.id) {
|
||||||
id: annotation.id
|
that.triggerEvent('delete', {
|
||||||
})
|
id: annotation.id
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).append($quote).append($notes);
|
}).append($quote).append($notes);
|
||||||
|
|
||||||
|
@ -98,9 +100,11 @@ oml.ui.annotation = function(annotation, $iframe) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.delete = function() {
|
that.delete = function() {
|
||||||
that.triggerEvent('delete', {
|
if (annotation.user == oml.user.id) {
|
||||||
id: annotation.id
|
that.triggerEvent('delete', {
|
||||||
})
|
id: annotation.id
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
that.deselect = function() {
|
that.deselect = function() {
|
||||||
that.removeClass('selected')
|
that.removeClass('selected')
|
||||||
|
|
|
@ -111,6 +111,11 @@ oml.ui.folders = function() {
|
||||||
oml.UI.set({find: getFind('')});
|
oml.UI.set({find: getFind('')});
|
||||||
oml.$ui.librariesList.options({selected: ['']});
|
oml.$ui.librariesList.options({selected: ['']});
|
||||||
},
|
},
|
||||||
|
singleclick: function(data) {
|
||||||
|
oml.UI.set({
|
||||||
|
find: getFind('')
|
||||||
|
});
|
||||||
|
},
|
||||||
selectnext: function() {
|
selectnext: function() {
|
||||||
oml.UI.set(Ox.extend(
|
oml.UI.set(Ox.extend(
|
||||||
{find: getFind(':')},
|
{find: getFind(':')},
|
||||||
|
@ -201,7 +206,14 @@ oml.ui.folders = function() {
|
||||||
!index && oml.addList();
|
!index && oml.addList();
|
||||||
},
|
},
|
||||||
select: function(data) {
|
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() {
|
selectnext: function() {
|
||||||
oml.UI.set({find: getFind(inboxId)});
|
oml.UI.set({find: getFind(inboxId)});
|
||||||
|
@ -290,6 +302,11 @@ oml.ui.folders = function() {
|
||||||
open: function(data) {
|
open: function(data) {
|
||||||
!index && !Ox.contains(data.ids, ':Inbox') && oml.ui.listDialog().open();
|
!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) {
|
select: function(data) {
|
||||||
oml.UI.set({find: getFind(data.ids[0])});
|
oml.UI.set({find: getFind(data.ids[0])});
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@ oml.ui.fullscreenButton = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
Ox.Fullscreen.enter(oml.$ui.viewer.find('iframe')[0]);
|
Ox.Fullscreen.enter(oml.$ui.viewer[0]);
|
||||||
},
|
},
|
||||||
oml_itemview: function() {
|
oml_itemview: function() {
|
||||||
that.updateElement();
|
that.updateElement();
|
||||||
|
@ -31,4 +31,4 @@ oml.ui.fullscreenButton = function() {
|
||||||
|
|
||||||
return that.updateElement();
|
return that.updateElement();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ oml.ui.itemViewPanel = function() {
|
||||||
],
|
],
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
selected: ui.itemView,
|
selected: ui.itemView,
|
||||||
size: window.innerWidth - ui.sidebarSize - 1
|
size: window.innerWidth - (ui.showSidebar ? ui.sidebarSize : 0) - 1
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
oml_itemview: function(data) {
|
oml_itemview: function(data) {
|
||||||
|
@ -27,4 +27,4 @@ oml.ui.itemViewPanel = function() {
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -566,7 +566,7 @@ oml.ui.mainMenu = function() {
|
||||||
? 'openPreview' : 'closePreview'
|
? 'openPreview' : 'closePreview'
|
||||||
]();
|
]();
|
||||||
} else if (id == 'fullscreen') {
|
} else if (id == 'fullscreen') {
|
||||||
Ox.Fullscreen.enter(oml.$ui.viewer.find('iframe')[0]);
|
Ox.Fullscreen.enter(oml.$ui.viewer[0]);
|
||||||
} else if (id == 'debugmode') {
|
} else if (id == 'debugmode') {
|
||||||
if (oml.localStorage('enableDebugMode')) {
|
if (oml.localStorage('enableDebugMode')) {
|
||||||
oml.localStorage['delete']('enableDebugMode');
|
oml.localStorage['delete']('enableDebugMode');
|
||||||
|
|
|
@ -61,7 +61,10 @@ oml.ui.viewer = function() {
|
||||||
note = data.notes[0]
|
note = data.notes[0]
|
||||||
delete data.notes
|
delete data.notes
|
||||||
}
|
}
|
||||||
addAnnotation(data, false)
|
var a = Ox.extend({}, data)
|
||||||
|
a.created = a.created || (new Date).toISOString();
|
||||||
|
a.item = ui.item
|
||||||
|
oml.api.addAnnotation(a)
|
||||||
if (note) {
|
if (note) {
|
||||||
data.notes = [note]
|
data.notes = [note]
|
||||||
} else {
|
} else {
|
||||||
|
@ -90,9 +93,14 @@ oml.ui.viewer = function() {
|
||||||
oml.api.getAnnotations({
|
oml.api.getAnnotations({
|
||||||
id: ui.item
|
id: ui.item
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
console.log(result)
|
if (!result.data.annotations.length && localStorage[oml.user.ui.item + '.annotations_']) {
|
||||||
annotations = result.data.annotations
|
localStorage[oml.user.ui.item + '.annotations'] = localStorage[oml.user.ui.item + '.annotations_']
|
||||||
callback && callback(annotations)
|
loadAnnotations(callback)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
annotations = result.data.annotations
|
||||||
|
callback && callback(annotations)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue