diff --git a/resources/content-server/index.html b/resources/content-server/index.html index ae000a82db..414ce0ae9c 100644 --- a/resources/content-server/index.html +++ b/resources/content-server/index.html @@ -2,7 +2,10 @@ calibre - + + + + diff --git a/resources/content-server/reset.css b/resources/content-server/reset.css index 293a29b4c4..a6329e8717 100644 --- a/resources/content-server/reset.css +++ b/resources/content-server/reset.css @@ -25,7 +25,7 @@ time, mark, audio, video { body { line-height:1.2; - font-family: sans-serif; + font-family:sans-serif; } article,aside,details,figcaption,figure, diff --git a/src/calibre/srv/ajax.py b/src/calibre/srv/ajax.py index 2062891078..95b4dd8f8d 100644 --- a/src/calibre/srv/ajax.py +++ b/src/calibre/srv/ajax.py @@ -567,7 +567,7 @@ def interface_data(ctx, rd, library_id): ''' Return the data needed to create the server main UI - Optional: ?num=75 + Optional: ?num=50 ''' session = rd.session ans = {'session_data': {k:session[k] for k in defaults.iterkeys()}} @@ -578,7 +578,7 @@ def interface_data(ctx, rd, library_id): sorts.append(s.strip()), orders.append(o.strip()) sort, sort_order = ans['session_data']['sort'].partition(',')[0].partition(':')[::2] try: - num = int(rd.query.get('num', 75)) + num = int(rd.query.get('num', 50)) except Exception: raise HTTPNotFound('Invalid number of books: %r' % rd.query.get('num')) db = get_db(ctx, library_id) diff --git a/src/pyj/ajax.pyj b/src/pyj/ajax.pyj index a1e4586cd9..7ade844f37 100644 --- a/src/pyj/ajax.pyj +++ b/src/pyj/ajax.pyj @@ -23,7 +23,7 @@ def ajax(path, on_complete, on_progress=None, bypass_cache=True, method='GET'): if end_type != 'load': on_complete(end_type, xhr, ev) return - if not (200 <= xhr.status < 300): + if xhr.status != 200: end_type = 'error' on_complete(end_type, xhr, ev) diff --git a/src/pyj/book_list/__init__.pyj b/src/pyj/book_list/__init__.pyj new file mode 100644 index 0000000000..a675d20d80 --- /dev/null +++ b/src/pyj/book_list/__init__.pyj @@ -0,0 +1,2 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2015, Kovid Goyal diff --git a/src/pyj/book_list/boss.pyj b/src/pyj/book_list/boss.pyj new file mode 100644 index 0000000000..6f051a74a8 --- /dev/null +++ b/src/pyj/book_list/boss.pyj @@ -0,0 +1,17 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2015, Kovid Goyal + +from book_list.ui import BookList + +class Boss: + + def __init__(self, interface_data): + self.interface_data = interface_data + self.current_library_id = interface_data['default_library'] + self.current_library_name = interface_data['library_map'][self.current_library_id] + self.update_window_title() + self.book_list = BookList(interface_data) + + def update_window_title(self): + document.title = 'calibre :: ' + self.current_library_name + diff --git a/src/pyj/book_list/globals.pyj b/src/pyj/book_list/globals.pyj new file mode 100644 index 0000000000..34681493e8 --- /dev/null +++ b/src/pyj/book_list/globals.pyj @@ -0,0 +1,12 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2015, Kovid Goyal + +boss = None + +def get_boss(): + nonlocal boss + return boss + +def set_boss(obj): + nonlocal boss + boss = obj diff --git a/src/pyj/book_list/theme.pyj b/src/pyj/book_list/theme.pyj new file mode 100644 index 0000000000..5479ba9c6d --- /dev/null +++ b/src/pyj/book_list/theme.pyj @@ -0,0 +1,11 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2015, Kovid Goyal + +def get_color(name): + return { + 'window-background': '#F6F3E9', + 'window-foreground': 'black', + 'bar-background': '#39322B', + 'bar-foreground': 'white', + }[name] + diff --git a/src/pyj/book_list/top_bar.pyj b/src/pyj/book_list/top_bar.pyj new file mode 100644 index 0000000000..a028f9f733 --- /dev/null +++ b/src/pyj/book_list/top_bar.pyj @@ -0,0 +1,29 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2015, Kovid Goyal + +from book_list.theme import get_color +from dom import set_css +from elementmaker import E + +bar_counter = 0 + +class TopBar: + + def __init__(self): + nonlocal bar_counter + bar_counter += 1 + self.bar_id, self.dummy_bar_id = 'top-bar-' + bar_counter, 'dummy-top-bar-' + bar_counter + db, b = E.div(id=self.dummy_bar_id), E.div(id=self.bar_id) + set_css(b, position='fixed', left='0', top='0') + document.body.appendChild(db) + document.body.appendChild(b) + for bar in db, b: + set_css(bar, width='100%', min_height='25px', background_color=get_color('bar-background'), padding='0.1rem') + + @property + def bar(self): + return document.getElementById(self.bar_id) + + @property + def dummy_bar(self): + return document.getElementById(self.dummy_bar_id) diff --git a/src/pyj/book_list/ui.pyj b/src/pyj/book_list/ui.pyj new file mode 100644 index 0000000000..7da6f5a46a --- /dev/null +++ b/src/pyj/book_list/ui.pyj @@ -0,0 +1,13 @@ +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2015, Kovid Goyal + +from book_list.theme import get_color +from book_list.top_bar import TopBar +from dom import set_css + +class BookList: + + def __init__(self, interface_data): + set_css(document.body, background_color=get_color('window-background')) + self.top_bar = TopBar() + diff --git a/src/pyj/srv.pyj b/src/pyj/srv.pyj index 523254781c..dec82912c5 100644 --- a/src/pyj/srv.pyj +++ b/src/pyj/srv.pyj @@ -4,13 +4,15 @@ from ajax import ajax from elementmaker import E from gettext import gettext as _ +from book_list.boss import Boss +from book_list.globals import set_boss def on_library_loaded(end_type, xhr, ev): p = document.getElementById('page_load_progress') p.parentNode.removeChild(p) if end_type == 'load': - data = xhr.response - data + boss = Boss(JSON.parse(xhr.responseText)) + set_boss(boss) else: document.body.appendChild(E.p(style="color:red", str.format(_( 'Failed to download library data from "{}", with status: [{}] {}'),