Compare commits

...

6 commits

Author SHA1 Message Date
j
b4c4372394 make existing notes editable 2019-01-31 22:18:53 +05:30
j
3d099f2c5f fix library update 2019-01-31 22:04:56 +05:30
j
a495fc398d remove empty public lists 2019-01-31 22:04:47 +05:30
j
ca35c413fe fix windows select folder 2019-01-31 19:11:13 +05:30
j
0062191db4 don't start animation twice 2019-01-31 17:11:26 +05:30
j
81543edab2 fix adding to queue 2019-01-31 15:25:26 +05:30
12 changed files with 64 additions and 42 deletions

View file

@ -3,11 +3,12 @@
import os
import sys
from os.path import normpath, dirname, abspath, join
import site
base = normpath(dirname(dirname(dirname(abspath(__file__)))))
if sys.platform == 'win32':
from os.path import normpath, dirname, abspath, join
import site
base = normpath(dirname(dirname(dirname(abspath(__file__)))))
for site_packages in (
join(base, 'openmedialibrary'),
join(base, 'platform', 'Shared', 'lib', 'python3.4', 'site-packages'),
@ -20,6 +21,7 @@ if sys.platform == 'win32':
unrar_dll = join(base, 'platform_win32', 'unrar.dll')
if os.path.exists(unrar_dll):
os.environ['UNRAR_LIB_PATH'] = unrar_dll
os.environ['TCL_LIBRARY'] = join(base, 'platform_win32', 'tcl', 'tcl8.6')
import api
import commands
@ -27,6 +29,9 @@ import server
if len(sys.argv) > 1 and sys.argv[1] == 'server':
server.run()
if len(sys.argv) > 1 and sys.argv[1] == 'ui':
import ui
ui.main(sys.argv[2:])
else:
commands.main()
if sys.platform == 'win32':

View file

@ -13,6 +13,7 @@ from oxtornado import actions
import item.api
import user.api
import update
import utils
import logging
logger = logging.getLogger(__name__)
@ -20,8 +21,8 @@ logger = logging.getLogger(__name__)
def win32_ui(type):
base = normpath(dirname(dirname(dirname(abspath(__file__)))))
cmd = [
join(base, 'platform_win32', 'python.exe'),
join(base, 'openmediablirary', 'oml', 'ui.py'), type
join('..', 'platform_win32', 'pythonw.exe'),
join('oml', 'ui.py'), type
]
return cmd
@ -31,14 +32,7 @@ def selectFolder(data):
path
}
'''
cmd = ['./ctl', 'ui', 'folder']
if sys.platform == 'win32':
cmd = win32_ui('folder')
if 'base' in data:
cmd += [data['base']]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip()
path = utils.ctl_output('ui', 'folder')
if path == 'None':
path = None
return {
@ -53,14 +47,7 @@ def selectFile(data):
path
}
'''
cmd = ['./ctl', 'ui', 'file']
if sys.platform == 'win32':
cmd = win32_ui('file')
if 'base' in data:
cmd += [data['base']]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip()
path = utils.ctl_output('ui', 'file')
if path == 'None':
path = None
return {

View file

@ -844,7 +844,7 @@ def download_cover(id):
else:
url = None
logger.debug('download cover %s %s', self.id, url)
logger.debug('download cover %s %s', id, url)
ratio = None
try:
cover = ox.net.read_url(url)

View file

@ -90,11 +90,9 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
DEBUG_HTTP = server.get('debug_http', False)
DEBUG_API = server.get('debug_api', False)
DB_VERSION = 13
FULLTEXT_SUPPORT = fulltext.platform_supported()
if not FULLTEXT_SUPPORT:
config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext']
DB_VERSION = 14

View file

@ -93,6 +93,17 @@ class TkUI:
filename = tkinter.filedialog.askopenfilename(parent=self.root, title=data.get("title", "Select File"))
return short_home(filename)
def main(args):
base = '~'
if len(args) >= 2:
base = args[1]
base = os.path.expanduser(base)
if os.path.exists(base):
os.chdir(base)
if args and args[0] == 'folder':
print(ui.selectFolder({}))
else:
print(ui.selectFile({}))
if use_Gtk:
ui = GtkUI()
@ -100,13 +111,4 @@ else:
ui = TkUI()
if __name__ == '__main__':
base = '~'
if len(sys.argv) >= 3:
base = sys.argv[2]
base = os.path.expanduser(base)
if os.path.exists(base):
os.chdir(base)
if len(sys.argv) >= 2 and sys.argv[1] == 'folder':
print(ui.selectFolder({}))
else:
print(ui.selectFile({}))
main(sys.argv[1:])

View file

@ -617,3 +617,11 @@ def migrate_13():
if revision > -1:
settings.server['revision'] = revision
return 13
def migrate_14():
from user.models import List
with db.session():
l = List.get(':Public')
if l and not len(l.items):
l.remove()
return 14

View file

@ -305,7 +305,7 @@ def addListItems(data):
if data['list'] == ':':
from item.models import Item
for item_id in data['items']:
i = Item.get(item_id)
i = Item.get(item_id, for_update=True)
i.queue_download()
i.update()
elif data['list'] and (data['list'].startswith(':') or data['list'].endswith(':')):

View file

@ -409,6 +409,24 @@ def ctl(*args):
subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args),
close_fds=True, start_new_session=True)
def ctl_output(*args):
import settings
if sys.platform == 'win32':
platform_win32 = os.path.join('..', 'platform_win32')
python = os.path.join(platform_win32, 'python.exe')
cmd = [python, 'oml'] + list(args)
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(cmd, cwd=settings.base_dir, startupinfo=startupinfo,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
p = subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
logger.debug('ctl_output%s -> %s [%s]', args, stdout, stderr)
return stdout.decode('utf-8').strip()
def user_sort_key(u):
return ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or ''))

View file

@ -12,7 +12,7 @@ oml.ui.annotation = function(annotation, $iframe) {
}
})
var notes = annotation.notes.length ? annotation.notes.map(function(note) {
note.editable = note.user == ''
note.editable = !note.user
return note
}) : [{
id: 'A',

View file

@ -64,7 +64,7 @@ oml.ui.list = function() {
&& ui.find.conditions[0].key == 'list'
&& ui.find.conditions[0].operator == '=='
)) {
oml.$ui.folders.updateItems(ui.find.conditions[0].value, data.items);
oml.$ui.folders.updateItems(ui.find.conditions.length ? ui.find.conditions[0].value : "", data.items);
}
oml.$ui.statusbar.set('total', data);
},

View file

@ -287,8 +287,10 @@
// FF3.6 document.body can be undefined here
window.onload = function() {
document.body.style.margin = 0;
if (!animationInterval) {
document.body.appendChild(loadingScreen);
startAnimation();
}
};
// IE8 does not call onload if already loaded before set
document.body && window.onload();

View file

@ -121,8 +121,10 @@
// FF3.6 document.body can be undefined here
window.onload = function() {
document.body.style.margin = 0;
if (!animationInterval) {
document.body.appendChild(loadingScreen);
startAnimation();
}
};
// IE8 does not call onload if already loaded before set
document.body && window.onload();