mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More work on the new server UI
This commit is contained in:
parent
67f7b5f2b9
commit
18533eeebc
@ -2,7 +2,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>calibre</title>
|
||||
<meta charset="utf-8"/>
|
||||
<meta charset="utf-8">
|
||||
<meta name="robots" content="noindex">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/png" href="favicon.png">
|
||||
<script>window.interface_data_url = 'ajax/interface-data';</script>
|
||||
<script type="text/javascript" src="static/main.js"></script>
|
||||
<link rel="stylesheet" href="static/reset.css"></link>
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
2
src/pyj/book_list/__init__.pyj
Normal file
2
src/pyj/book_list/__init__.pyj
Normal file
@ -0,0 +1,2 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
17
src/pyj/book_list/boss.pyj
Normal file
17
src/pyj/book_list/boss.pyj
Normal file
@ -0,0 +1,17 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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
|
||||
|
12
src/pyj/book_list/globals.pyj
Normal file
12
src/pyj/book_list/globals.pyj
Normal file
@ -0,0 +1,12 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
boss = None
|
||||
|
||||
def get_boss():
|
||||
nonlocal boss
|
||||
return boss
|
||||
|
||||
def set_boss(obj):
|
||||
nonlocal boss
|
||||
boss = obj
|
11
src/pyj/book_list/theme.pyj
Normal file
11
src/pyj/book_list/theme.pyj
Normal file
@ -0,0 +1,11 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
def get_color(name):
|
||||
return {
|
||||
'window-background': '#F6F3E9',
|
||||
'window-foreground': 'black',
|
||||
'bar-background': '#39322B',
|
||||
'bar-foreground': 'white',
|
||||
}[name]
|
||||
|
29
src/pyj/book_list/top_bar.pyj
Normal file
29
src/pyj/book_list/top_bar.pyj
Normal file
@ -0,0 +1,29 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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)
|
13
src/pyj/book_list/ui.pyj
Normal file
13
src/pyj/book_list/ui.pyj
Normal file
@ -0,0 +1,13 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
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()
|
||||
|
@ -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: [{}] {}'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user