Compare commits
5 commits
74e89693ff
...
f8d226a3de
| Author | SHA1 | Date | |
|---|---|---|---|
| f8d226a3de | |||
| 3969f6dfa7 | |||
| 0234b8dffb | |||
| f24e095987 | |||
| ee52791a56 |
5 changed files with 53 additions and 48 deletions
|
|
@ -134,7 +134,7 @@ def command_postupdate(*args):
|
||||||
print('usage: -o oldversion -n newversion')
|
print('usage: -o oldversion -n newversion')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if old <= '20140521-65-e14c686' and new > '20140521-65-e14c686':
|
if old <= '20140521-65-e14c686' and new > '20140521-65-e14c686':
|
||||||
if not os.path.exists(settings.db_path):
|
if not os.path.exists(settings.db_path) and sys.platform != 'win32':
|
||||||
r('./ctl', 'setup')
|
r('./ctl', 'setup')
|
||||||
import setup
|
import setup
|
||||||
setup.upgrade_db(old, new)
|
setup.upgrade_db(old, new)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,10 @@ class Icons(dict):
|
||||||
|
|
||||||
def is_available(self):
|
def is_available(self):
|
||||||
folder = os.path.dirname(self._db)
|
folder = os.path.dirname(self._db)
|
||||||
if os.path.exists(folder):
|
base = os.path.dirname(os.path.dirname(folder))
|
||||||
|
if os.path.exists(base):
|
||||||
|
if not os.path.exists(folder):
|
||||||
|
ox.makedirs(folder)
|
||||||
if not os.path.exists(self._db):
|
if not os.path.exists(self._db):
|
||||||
self.create()
|
self.create()
|
||||||
return os.path.exists(self._db)
|
return os.path.exists(self._db)
|
||||||
|
|
@ -137,7 +140,7 @@ def get_icons_db_path():
|
||||||
import settings
|
import settings
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
library = os.path.expanduser(settings.preferences['libraryPath'])
|
library = os.path.normpath(os.path.expanduser(settings.preferences['libraryPath']))
|
||||||
metadata = os.path.join(library, 'Metadata')
|
metadata = os.path.join(library, 'Metadata')
|
||||||
icons_db_path = os.path.join(metadata, 'icons.db')
|
icons_db_path = os.path.join(metadata, 'icons.db')
|
||||||
if os.path.exists(os.path.dirname(library)):
|
if os.path.exists(os.path.dirname(library)):
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ def api_requestPeering(user_id, username, message):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def api_acceptPeering(user_id, username, message):
|
def api_acceptPeering(user_id, username, message):
|
||||||
user = User.get(user_id)
|
user = User.get(user_id, for_update=True)
|
||||||
if user:
|
if user:
|
||||||
logger.debug('incoming acceptPeering event: pending: %s', user.pending)
|
logger.debug('incoming acceptPeering event: pending: %s', user.pending)
|
||||||
if user.pending == 'sent':
|
if user.pending == 'sent':
|
||||||
|
|
@ -50,7 +50,7 @@ def api_acceptPeering(user_id, username, message):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def api_rejectPeering(user_id, message):
|
def api_rejectPeering(user_id, message):
|
||||||
user = User.get(user_id)
|
user = User.get(user_id, for_update=True)
|
||||||
if user:
|
if user:
|
||||||
user.info['message'] = message
|
user.info['message'] = message
|
||||||
user.update_peering(False)
|
user.update_peering(False)
|
||||||
|
|
@ -59,7 +59,7 @@ def api_rejectPeering(user_id, message):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def api_removePeering(user_id, message):
|
def api_removePeering(user_id, message):
|
||||||
user = User.get(user_id)
|
user = User.get(user_id, for_update=True)
|
||||||
if user:
|
if user:
|
||||||
user.info['message'] = message
|
user.info['message'] = message
|
||||||
user.update_peering(False)
|
user.update_peering(False)
|
||||||
|
|
@ -68,7 +68,7 @@ def api_removePeering(user_id, message):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def api_cancelPeering(user_id, message):
|
def api_cancelPeering(user_id, message):
|
||||||
user = User.get(user_id)
|
user = User.get(user_id, for_update=True)
|
||||||
if user:
|
if user:
|
||||||
user.info['message'] = message
|
user.info['message'] = message
|
||||||
user.update_peering(False)
|
user.update_peering(False)
|
||||||
|
|
|
||||||
|
|
@ -121,55 +121,56 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
id = None
|
id = None
|
||||||
if id and len(id) == 32 and id.isalnum():
|
if id and len(id) == 32 and id.isalnum():
|
||||||
|
path = None
|
||||||
|
data = None
|
||||||
with db.session():
|
with db.session():
|
||||||
if preview:
|
if preview:
|
||||||
from item.icons import get_icon_sync
|
from item.icons import get_icon_sync
|
||||||
try:
|
try:
|
||||||
data = get_icon_sync(id, 'preview', 512)
|
content = get_icon_sync(id, 'preview', 512)
|
||||||
except:
|
except:
|
||||||
data = None
|
content = None
|
||||||
if data:
|
if content:
|
||||||
self.send_response(200, 'ok')
|
self.send_response(200, 'ok')
|
||||||
self.send_header('Content-type', 'image/jpg')
|
mimetype = 'image/jpg'
|
||||||
else:
|
else:
|
||||||
self.send_response(404, 'Not Found')
|
self.send_response(404, 'Not Found')
|
||||||
self.send_header('Content-type', 'text/plain')
|
content = b'404 - Not Found'
|
||||||
data = b'404 - Not Found'
|
mimetype = 'text/plain'
|
||||||
content_length = len(data)
|
|
||||||
self.send_header('Content-Length', str(content_length))
|
|
||||||
self.end_headers()
|
|
||||||
self.write_with_limit(data, content_length)
|
|
||||||
return
|
|
||||||
file = item.models.File.get(id)
|
|
||||||
if not file:
|
|
||||||
self.send_response(404, 'Not Found')
|
|
||||||
self.send_header('Content-type', 'text/plain')
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(b'404 - Not Found')
|
|
||||||
return
|
|
||||||
path = file.fullpath()
|
|
||||||
mimetype = {
|
|
||||||
'epub': 'application/epub+zip',
|
|
||||||
'pdf': 'application/pdf',
|
|
||||||
'txt': 'text/plain',
|
|
||||||
}.get(path.split('.')[-1], None)
|
|
||||||
self.send_response(200, 'OK')
|
|
||||||
self.send_header('Content-Type', mimetype)
|
|
||||||
self.send_header('X-Node-Protocol', settings.NODE_PROTOCOL)
|
|
||||||
if mimetype == 'text/plain':
|
|
||||||
with open(path, 'rb') as f:
|
|
||||||
content = f.read()
|
|
||||||
content = self.gzip_data(content)
|
|
||||||
content_length = len(content)
|
|
||||||
else:
|
else:
|
||||||
content = None
|
file = item.models.File.get(id)
|
||||||
content_length = os.path.getsize(path)
|
if file:
|
||||||
self.send_header('Content-Length', str(content_length))
|
path = file.fullpath()
|
||||||
self.end_headers()
|
mimetype = {
|
||||||
if content:
|
'epub': 'application/epub+zip',
|
||||||
self.write_with_limit(content, content_length)
|
'pdf': 'application/pdf',
|
||||||
else:
|
'txt': 'text/plain',
|
||||||
self.write_file_with_limit(path, content_length)
|
}.get(path.split('.')[-1], None)
|
||||||
|
self.send_response(200, 'OK')
|
||||||
|
else:
|
||||||
|
self.send_response(404, 'Not Found')
|
||||||
|
content = b'404 - Not Found'
|
||||||
|
mimetype = 'text/plain'
|
||||||
|
self.send_header('Content-Type', mimetype)
|
||||||
|
self.send_header('X-Node-Protocol', settings.NODE_PROTOCOL)
|
||||||
|
if mimetype == 'text/plain' and path:
|
||||||
|
with open(path, 'rb') as f:
|
||||||
|
content = f.read()
|
||||||
|
content = self.gzip_data(content)
|
||||||
|
content_length = len(content)
|
||||||
|
elif path:
|
||||||
|
content = None
|
||||||
|
content_length = os.path.getsize(path)
|
||||||
|
elif content:
|
||||||
|
content_length = len(content)
|
||||||
|
else:
|
||||||
|
content_length = 0
|
||||||
|
self.send_header('Content-Length', str(content_length))
|
||||||
|
self.end_headers()
|
||||||
|
if content:
|
||||||
|
self.write_with_limit(content, content_length)
|
||||||
|
elif path:
|
||||||
|
self.write_file_with_limit(path, content_length)
|
||||||
elif len(parts) == 2 and parts[1] == 'log':
|
elif len(parts) == 2 and parts[1] == 'log':
|
||||||
self._changelog()
|
self._changelog()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -340,8 +340,9 @@ oml.ui.folders = function() {
|
||||||
var items = lists.filter(function(list) {
|
var items = lists.filter(function(list) {
|
||||||
return list.user == '' && list.type != 'library' && list.name != 'Inbox';
|
return list.user == '' && list.type != 'library' && list.name != 'Inbox';
|
||||||
});
|
});
|
||||||
|
// Library + Inbox + lists
|
||||||
oml.$ui.folder[0].$content
|
oml.$ui.folder[0].$content
|
||||||
.css({height: 16 + items.length * 16 + 'px'});
|
.css({height: 16 + 16 + items.length * 16 + 'px'});
|
||||||
oml.$ui.folderList[0].options({
|
oml.$ui.folderList[0].options({
|
||||||
items: Ox.clone(items, true)
|
items: Ox.clone(items, true)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue