mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Implement display of notes on server
This commit is contained in:
parent
14f4d8366f
commit
79a88fa17c
@ -192,7 +192,7 @@ def render_metadata(mi, table, book_id, iframe_css): # {{{
|
|||||||
comments = v'[]'
|
comments = v'[]'
|
||||||
link_maps = mi.link_maps or v'{}'
|
link_maps = mi.link_maps or v'{}'
|
||||||
|
|
||||||
def show_note_action(field, name, item_id, item_val):
|
def show_note_action(field, item_id, item_val):
|
||||||
show_note(book_id, field, item_id, item_val)
|
show_note(book_id, field, item_id, item_val)
|
||||||
|
|
||||||
def add_note_link(field, name, val, parent):
|
def add_note_link(field, name, val, parent):
|
||||||
@ -200,7 +200,7 @@ def render_metadata(mi, table, book_id, iframe_css): # {{{
|
|||||||
parent.appendChild(document.createTextNode(' '))
|
parent.appendChild(document.createTextNode(' '))
|
||||||
parent.appendChild(E.a(
|
parent.appendChild(E.a(
|
||||||
svgicon('pencil'), title=_('Show notes for: {}').format(val), href='javascript:void(0)', onclick=show_note_action.bind(
|
svgicon('pencil'), title=_('Show notes for: {}').format(val), href='javascript:void(0)', onclick=show_note_action.bind(
|
||||||
None, book_id, field, mi.items_with_notes[field][val], val), class_='blue-link'))
|
None, field, mi.items_with_notes[field][val], val), class_='blue-link'))
|
||||||
|
|
||||||
def add_row(field, name, val, is_searchable=False, is_html=False, join=None, search_text=None, use_quotes=True):
|
def add_row(field, name, val, is_searchable=False, is_html=False, join=None, search_text=None, use_quotes=True):
|
||||||
if val is undefined or val is None:
|
if val is undefined or val is None:
|
||||||
|
@ -2,10 +2,32 @@
|
|||||||
# License: GPL v3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __python__ import bound_methods, hash_literals
|
from __python__ import bound_methods, hash_literals
|
||||||
|
|
||||||
|
from ajax import ajax
|
||||||
|
from book_list.details_list import sandbox_css
|
||||||
from book_list.router import back, home
|
from book_list.router import back, home
|
||||||
from book_list.top_bar import create_top_bar
|
from book_list.top_bar import create_top_bar
|
||||||
from book_list.ui import set_panel_handler
|
from book_list.ui import set_panel_handler
|
||||||
from utils import parse_url_params
|
from gettext import gettext as _
|
||||||
|
from utils import parse_url_params, sandboxed_html
|
||||||
|
|
||||||
|
|
||||||
|
def make_iframe(html):
|
||||||
|
iframe = sandboxed_html(html, sandbox_css() + '\n\nhtml { overflow: visible; margin: 0.5rem; }')
|
||||||
|
iframe.style.width = '100%'
|
||||||
|
iframe.style.flexGrow = '10'
|
||||||
|
return iframe
|
||||||
|
|
||||||
|
|
||||||
|
def on_notes_fetched(load_type, xhr, ev):
|
||||||
|
if load_type is 'load':
|
||||||
|
html = xhr.responseText
|
||||||
|
else:
|
||||||
|
html = xhr.error_html
|
||||||
|
iframe = make_iframe(html)
|
||||||
|
container = document.getElementById(this)
|
||||||
|
old = container.getElementsByTagName('iframe')[0]
|
||||||
|
old.parentNode.appendChild(iframe)
|
||||||
|
old.parentNode.removeChild(old)
|
||||||
|
|
||||||
|
|
||||||
def init(container_id):
|
def init(container_id):
|
||||||
@ -16,6 +38,14 @@ def init(container_id):
|
|||||||
if ca is 'home':
|
if ca is 'home':
|
||||||
close_action, close_icon = def(): home();, 'home'
|
close_action, close_icon = def(): home();, 'home'
|
||||||
create_top_bar(container, title=q.item, action=close_action, icon=close_icon)
|
create_top_bar(container, title=q.item, action=close_action, icon=close_icon)
|
||||||
|
url = 'get-note/' + encodeURIComponent(q.field) + '/' + encodeURIComponent(q.item_id)
|
||||||
|
if q.library_id:
|
||||||
|
url += '/' + encodeURIComponent(q.library_id)
|
||||||
|
container.style.height = '100vh'
|
||||||
|
container.style.display = 'flex'
|
||||||
|
container.style.flexDirection = 'column'
|
||||||
|
container.appendChild(make_iframe(_('Loading') + '…'))
|
||||||
|
ajax(url, on_notes_fetched.bind(container_id), bypass_cache=False).send()
|
||||||
|
|
||||||
|
|
||||||
set_panel_handler('show_note', init)
|
set_panel_handler('show_note', init)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user