mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Fix using a bookmark to load the book list not working is server is password protected. Fixes #1819025 [Error message in Chrome when trying to log in to a bookmarked page in the content server](https://bugs.launchpad.net/calibre/+bug/1819025)
This commit is contained in:
parent
7308f4073f
commit
0a07da5515
@ -10,7 +10,7 @@ from lru_cache import LRUCache
|
|||||||
from session import get_interface_data
|
from session import get_interface_data
|
||||||
from utils import parse_url_params
|
from utils import parse_url_params
|
||||||
|
|
||||||
load_status = {'loading':True, 'ok':False, 'error_html':None, 'current_fetch': None}
|
load_status = {'loading':True, 'ok':False, 'error_html':None, 'current_fetch': None, 'http_error_code': 0}
|
||||||
library_data = {'metadata':{}, 'previous_book_ids': v'[]', 'force_refresh': False}
|
library_data = {'metadata':{}, 'previous_book_ids': v'[]', 'force_refresh': False}
|
||||||
|
|
||||||
|
|
||||||
@ -78,6 +78,7 @@ def update_library_data(data):
|
|||||||
load_status.loading = False
|
load_status.loading = False
|
||||||
load_status.ok = True
|
load_status.ok = True
|
||||||
load_status.error_html = None
|
load_status.error_html = None
|
||||||
|
load_status.http_error_code = 0
|
||||||
library_data.previous_book_ids = v'[]'
|
library_data.previous_book_ids = v'[]'
|
||||||
if library_data.for_library is not current_library_id():
|
if library_data.for_library is not current_library_id():
|
||||||
library_data.field_names = {}
|
library_data.field_names = {}
|
||||||
@ -122,6 +123,7 @@ def on_data_loaded(end_type, xhr, ev):
|
|||||||
load_status.ok = False
|
load_status.ok = False
|
||||||
load_status.loading = False
|
load_status.loading = False
|
||||||
load_status.error_html = msg or xhr.error_html
|
load_status.error_html = msg or xhr.error_html
|
||||||
|
load_status.http_error_code = xhr.status
|
||||||
|
|
||||||
if end_type is 'load':
|
if end_type is 'load':
|
||||||
data = JSON.parse(xhr.responseText)
|
data = JSON.parse(xhr.responseText)
|
||||||
|
@ -9,17 +9,18 @@ from gettext import gettext as _
|
|||||||
from ajax import ajax_send
|
from ajax import ajax_send
|
||||||
from book_list.add import add_books_panel
|
from book_list.add import add_books_panel
|
||||||
from book_list.cover_grid import (
|
from book_list.cover_grid import (
|
||||||
description as COVER_GRID_DESCRIPTION, append_item as cover_grid_append_item,
|
append_item as cover_grid_append_item, cover_grid_css,
|
||||||
cover_grid_css, create_item as create_cover_grid_item, init as init_cover_grid
|
create_item as create_cover_grid_item, description as COVER_GRID_DESCRIPTION,
|
||||||
|
init as init_cover_grid
|
||||||
)
|
)
|
||||||
from book_list.custom_list import (
|
from book_list.custom_list import (
|
||||||
description as CUSTOM_LIST_DESCRIPTION, append_item as custom_list_append_item,
|
append_item as custom_list_append_item, create_item as create_custom_list_item,
|
||||||
create_item as create_custom_list_item, custom_list_css,
|
custom_list_css, description as CUSTOM_LIST_DESCRIPTION,
|
||||||
init as init_custom_list
|
init as init_custom_list
|
||||||
)
|
)
|
||||||
from book_list.details_list import (
|
from book_list.details_list import (
|
||||||
description as DETAILS_LIST_DESCRIPTION, append_item as details_list_append_item,
|
append_item as details_list_append_item, create_item as create_details_list_item,
|
||||||
create_item as create_details_list_item, details_list_css,
|
description as DETAILS_LIST_DESCRIPTION, details_list_css,
|
||||||
init as init_details_list
|
init as init_details_list
|
||||||
)
|
)
|
||||||
from book_list.globals import get_session_data
|
from book_list.globals import get_session_data
|
||||||
@ -283,12 +284,20 @@ def create_books_list(container):
|
|||||||
|
|
||||||
def check_for_books_loaded():
|
def check_for_books_loaded():
|
||||||
container = this
|
container = this
|
||||||
|
container_id = container.id
|
||||||
if load_status.loading:
|
if load_status.loading:
|
||||||
conditional_timeout(container.id, 5, check_for_books_loaded)
|
conditional_timeout(container_id, 5, check_for_books_loaded)
|
||||||
return
|
return
|
||||||
container = container.lastChild
|
container = container.lastChild
|
||||||
clear(container)
|
clear(container)
|
||||||
if not load_status.ok:
|
if not load_status.ok:
|
||||||
|
if load_status.http_error_code is 401:
|
||||||
|
# Unauthorized, keep retrying until the user provides a
|
||||||
|
# username/password
|
||||||
|
container.appendChild(E.div(_('Username/password required, retrying...')))
|
||||||
|
ensure_current_library_data()
|
||||||
|
conditional_timeout(container_id, 100, check_for_books_loaded)
|
||||||
|
return
|
||||||
err = E.div()
|
err = E.div()
|
||||||
safe_set_inner_html(err, load_status.error_html)
|
safe_set_inner_html(err, load_status.error_html)
|
||||||
container.appendChild(E.div(
|
container.appendChild(E.div(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user