Compare commits
7 commits
fe9b0618ed
...
dd48312aff
| Author | SHA1 | Date | |
|---|---|---|---|
| dd48312aff | |||
| b467b93fb6 | |||
| 031db4c888 | |||
| ca32106e2b | |||
| 79b5818cc4 | |||
| 028415c090 | |||
| 5a8e08b2c2 |
11 changed files with 40 additions and 41 deletions
|
|
@ -29,7 +29,7 @@ import server
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'server':
|
if len(sys.argv) > 1 and sys.argv[1] == 'server':
|
||||||
server.run()
|
server.run()
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'ui':
|
elif len(sys.argv) > 1 and sys.argv[1] == 'ui':
|
||||||
import ui
|
import ui
|
||||||
ui.main(sys.argv[2:])
|
ui.main(sys.argv[2:])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,8 @@ def run_scan():
|
||||||
file.item.added = file.item.accessed
|
file.item.added = file.item.accessed
|
||||||
file.item.save()
|
file.item.save()
|
||||||
library_items = len(user.library.items)
|
library_items = len(user.library.items)
|
||||||
|
if state.shutdown:
|
||||||
|
return
|
||||||
if added:
|
if added:
|
||||||
trigger_event('change', {})
|
trigger_event('change', {})
|
||||||
logger.debug('imported %s unknown books', added)
|
logger.debug('imported %s unknown books', added)
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,6 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
self.send_header('Content-Length', str(content_length))
|
self.send_header('Content-Length', str(content_length))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(content)
|
self.wfile.write(content)
|
||||||
logger.debug('%s bytes response', content_length)
|
|
||||||
|
|
||||||
def chunk_size(self, content_length):
|
def chunk_size(self, content_length):
|
||||||
return min(16*1024, content_length)
|
return min(16*1024, content_length)
|
||||||
|
|
|
||||||
|
|
@ -486,9 +486,6 @@ class Nodes(Thread):
|
||||||
self._q = Queue()
|
self._q = Queue()
|
||||||
with db.session():
|
with db.session():
|
||||||
for u in user.models.User.query.filter_by(peered=True):
|
for u in user.models.User.query.filter_by(peered=True):
|
||||||
if 'local' in u.info:
|
|
||||||
del u.info['local']
|
|
||||||
u.save()
|
|
||||||
self.queue('add', u.id)
|
self.queue('add', u.id)
|
||||||
get_peer(u.id)
|
get_peer(u.id)
|
||||||
for u in user.models.User.query.filter_by(queued=True):
|
for u in user.models.User.query.filter_by(queued=True):
|
||||||
|
|
@ -507,6 +504,7 @@ class Nodes(Thread):
|
||||||
while not state.shutdown:
|
while not state.shutdown:
|
||||||
args = self._q.get()
|
args = self._q.get()
|
||||||
if args:
|
if args:
|
||||||
|
logger.debug('processing nodes queue: next: %s, %s entries in queue', args[0], self._q.qsize())
|
||||||
if args[0] == 'add':
|
if args[0] == 'add':
|
||||||
self._add(*args[1:])
|
self._add(*args[1:])
|
||||||
elif args[0] == 'pull':
|
elif args[0] == 'pull':
|
||||||
|
|
@ -515,6 +513,8 @@ class Nodes(Thread):
|
||||||
self._call(*args)
|
self._call(*args)
|
||||||
|
|
||||||
def queue(self, *args):
|
def queue(self, *args):
|
||||||
|
if args:
|
||||||
|
logger.debug('add %s to queue, queue currently has %s entries', args[0], self._q.qsize())
|
||||||
self._q.put(list(args))
|
self._q.put(list(args))
|
||||||
|
|
||||||
def is_online(self, id):
|
def is_online(self, id):
|
||||||
|
|
|
||||||
|
|
@ -95,4 +95,4 @@ FULLTEXT_SUPPORT = fulltext.platform_supported()
|
||||||
if not FULLTEXT_SUPPORT:
|
if not FULLTEXT_SUPPORT:
|
||||||
config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext']
|
config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext']
|
||||||
|
|
||||||
DB_VERSION = 14
|
DB_VERSION = 15
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ shutdown = False
|
||||||
websockets = []
|
websockets = []
|
||||||
uisockets = []
|
uisockets = []
|
||||||
peers = {}
|
peers = {}
|
||||||
|
|
||||||
changelog_size = None
|
changelog_size = None
|
||||||
|
|
||||||
activity = {}
|
activity = {}
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,9 @@ class Update(Thread):
|
||||||
db_version = migrate_12()
|
db_version = migrate_12()
|
||||||
if db_version < 13:
|
if db_version < 13:
|
||||||
db_version = migrate_13()
|
db_version = migrate_13()
|
||||||
settings.server['db_version'] = settings.DB_VERSION
|
if db_version < 15:
|
||||||
|
db_version = migrate_15()
|
||||||
|
settings.server['db_version'] = db_version
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.status('Checking for updates...')
|
self.status('Checking for updates...')
|
||||||
|
|
@ -618,10 +620,14 @@ def migrate_13():
|
||||||
settings.server['revision'] = revision
|
settings.server['revision'] = revision
|
||||||
return 13
|
return 13
|
||||||
|
|
||||||
def migrate_14():
|
def migrate_15():
|
||||||
from user.models import List
|
from user.models import List, User
|
||||||
with db.session():
|
with db.session():
|
||||||
l = List.get(':Public')
|
l = List.get(':Public')
|
||||||
if l and not len(l.items):
|
if l and not len(l.items):
|
||||||
l.remove()
|
l.remove()
|
||||||
return 14
|
for u in User.query:
|
||||||
|
if 'local' in u.info:
|
||||||
|
del u.info['local']
|
||||||
|
u.save()
|
||||||
|
return 15
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,7 @@ class User(db.Model):
|
||||||
user = cls(id=id, peered=False, online=False)
|
user = cls(id=id, peered=False, online=False)
|
||||||
user.info = {}
|
user.info = {}
|
||||||
if state.nodes and state.nodes.local and id in state.nodes.local:
|
if state.nodes and state.nodes.local and id in state.nodes.local:
|
||||||
user.info['local'] = state.nodes.local[id]
|
user.info['username'] = state.nodes.local[id]['username']
|
||||||
user.info['username'] = user.info['local']['username']
|
|
||||||
user.update_name()
|
user.update_name()
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
||||||
|
|
@ -84,6 +83,8 @@ class User(db.Model):
|
||||||
j = {}
|
j = {}
|
||||||
if self.info:
|
if self.info:
|
||||||
j.update(self.info)
|
j.update(self.info)
|
||||||
|
if state.nodes and self.id in state.nodes.local:
|
||||||
|
j['local'] = state.nodes.local[self.id].copy()
|
||||||
j['id'] = self.id
|
j['id'] = self.id
|
||||||
if self.pending:
|
if self.pending:
|
||||||
j['pending'] = self.pending
|
j['pending'] = self.pending
|
||||||
|
|
@ -603,25 +604,15 @@ def update_user_peering(user_id, peered, username=None):
|
||||||
u.update_peering(peered, username)
|
u.update_peering(peered, username)
|
||||||
|
|
||||||
def remove_local_info(id):
|
def remove_local_info(id):
|
||||||
with db.session():
|
if state.nodes:
|
||||||
u = User.get(id, for_update=True)
|
trigger_event('status', {
|
||||||
if u and 'local' in u.info:
|
'id': id,
|
||||||
del u.info['local']
|
'online': state.nodes.is_online(id)
|
||||||
u.save()
|
})
|
||||||
u.trigger_status()
|
|
||||||
|
|
||||||
def add_local_info(data):
|
def add_local_info(data):
|
||||||
with db.session():
|
if state.nodes:
|
||||||
u = User.get(data['id'], for_update=True)
|
state.nodes.queue('add', data['id'])
|
||||||
if u:
|
|
||||||
if u.info['username'] != data['username']:
|
|
||||||
u.info['username'] = data['username']
|
|
||||||
u.update_name()
|
|
||||||
u.info['local'] = data
|
|
||||||
u.save()
|
|
||||||
if state.nodes:
|
|
||||||
state.nodes.queue('add', u.id)
|
|
||||||
|
|
||||||
|
|
||||||
def upload(data):
|
def upload(data):
|
||||||
delay = 60
|
delay = 60
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
.OMLQuote {
|
.OMLQuote {
|
||||||
|
padding: 8px;
|
||||||
color: rgb(0, 0, 0);
|
color: rgb(0, 0, 0);
|
||||||
background-color: rgb(255, 255, 255);
|
background-color: rgb(255, 255, 255);
|
||||||
font-family: Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif;
|
font-family: Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
oml.ui.annotation = function(annotation, $iframe) {
|
oml.ui.annotation = function(annotation, $iframe) {
|
||||||
var $quote = Ox.Element().addClass('OxSelectable OMLQuote').css({
|
var $quote = Ox.Element()
|
||||||
padding: '8px'
|
.addClass('OxSelectable OMLQuote')
|
||||||
}).html(Ox.encodeHTMLEntities(annotation.text).replace(/\n/g, '<br/>')).on({
|
.append(
|
||||||
click: function(event) {
|
Ox.Element().html(Ox.encodeHTMLEntities(annotation.text).replace(/\n/g, '<br/>'))
|
||||||
that.select()
|
).on({
|
||||||
$iframe.postMessage('selectAnnotation', {
|
click: function(event) {
|
||||||
id: annotation.id
|
that.select()
|
||||||
|
$iframe.postMessage('selectAnnotation', {
|
||||||
|
id: annotation.id
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
|
||||||
var notes = annotation.notes.length ? annotation.notes.map(function(note) {
|
var notes = annotation.notes.length ? annotation.notes.map(function(note) {
|
||||||
note.editable = !note.user
|
note.editable = !note.user
|
||||||
return note
|
return note
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,6 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
) {
|
) {
|
||||||
var targets = drag.action == 'copy' ? drag.target.id
|
var targets = drag.action == 'copy' ? drag.target.id
|
||||||
: [oml.user.ui._list, drag.target.id];
|
: [oml.user.ui._list, drag.target.id];
|
||||||
cleanup(250);
|
|
||||||
oml.doHistory(drag.action, data.ids, targets, function() {
|
oml.doHistory(drag.action, data.ids, targets, function() {
|
||||||
Ox.Request.clearCache('find');
|
Ox.Request.clearCache('find');
|
||||||
oml.api.find({
|
oml.api.find({
|
||||||
|
|
@ -455,6 +454,7 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
if (drag.action == 'move') {
|
if (drag.action == 'move') {
|
||||||
oml.$ui.list.updateElement();
|
oml.$ui.list.updateElement();
|
||||||
}
|
}
|
||||||
|
cleanup(250);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
@ -492,7 +492,6 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
text = Ox._('You cannot move books<br>out of a smart list.');
|
text = Ox._('You cannot move books<br>out of a smart list.');
|
||||||
}
|
}
|
||||||
} else if (drag.target) {
|
} else if (drag.target) {
|
||||||
console.log(drag.target)
|
|
||||||
targetText = drag.target.type == 'libraries' ? Ox._('a library')
|
targetText = drag.target.type == 'libraries' ? Ox._('a library')
|
||||||
: drag.target.type == 'library' ?
|
: drag.target.type == 'library' ?
|
||||||
drag.target.user == ''
|
drag.target.user == ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue