mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Small performance improvements for the content server kepub patch
This commit is contained in:
parent
a3afa17761
commit
609c2de0e4
@ -254,7 +254,7 @@ class ContentServer(object):
|
|||||||
|
|
||||||
ua = cherrypy.request.headers.get('User-Agent', '').strip()
|
ua = cherrypy.request.headers.get('User-Agent', '').strip()
|
||||||
have_kobo_browser = self.is_kobo_browser(ua)
|
have_kobo_browser = self.is_kobo_browser(ua)
|
||||||
file_extension = "kepub.epub" if format.lower() == "kepub" and have_kobo_browser else format
|
file_extension = "kepub.epub" if have_kobo_browser and format.lower() == "kepub" else format
|
||||||
|
|
||||||
au = authors_to_string(newmi.authors if newmi.authors else
|
au = authors_to_string(newmi.authors if newmi.authors else
|
||||||
[_('Unknown')])
|
[_('Unknown')])
|
||||||
|
@ -122,7 +122,7 @@ def build_index(books, num, search, sort, order, start, total, url_base, CKEYS,
|
|||||||
for fmt in book['formats'].split(','):
|
for fmt in book['formats'].split(','):
|
||||||
if not fmt or fmt.lower().startswith('original_'):
|
if not fmt or fmt.lower().startswith('original_'):
|
||||||
continue
|
continue
|
||||||
file_extension = "kepub.epub" if fmt.lower() == "kepub" and have_kobo_browser else fmt
|
file_extension = "kepub.epub" if have_kobo_browser and fmt.lower() == "kepub" else fmt
|
||||||
a = quote(ascii_filename(book['authors']))
|
a = quote(ascii_filename(book['authors']))
|
||||||
t = quote(ascii_filename(book['title']))
|
t = quote(ascii_filename(book['title']))
|
||||||
s = SPAN(
|
s = SPAN(
|
||||||
@ -183,15 +183,13 @@ class MobileServer(object):
|
|||||||
'A view optimized for browsers in mobile devices'
|
'A view optimized for browsers in mobile devices'
|
||||||
|
|
||||||
MOBILE_UA = re.compile('(?i)(?:iPhone|Opera Mini|NetFront|webOS|Mobile|Android|imode|DoCoMo|Minimo|Blackberry|MIDP|Symbian|HD2|Kindle)')
|
MOBILE_UA = re.compile('(?i)(?:iPhone|Opera Mini|NetFront|webOS|Mobile|Android|imode|DoCoMo|Minimo|Blackberry|MIDP|Symbian|HD2|Kindle)')
|
||||||
KOBO_UA = re.compile('(?i)(?:Kobo Touch)')
|
|
||||||
|
|
||||||
def is_mobile_browser(self, ua):
|
def is_mobile_browser(self, ua):
|
||||||
match = self.MOBILE_UA.search(ua)
|
match = self.MOBILE_UA.search(ua)
|
||||||
return match is not None and 'iPad' not in ua
|
return match is not None and 'iPad' not in ua
|
||||||
|
|
||||||
def is_kobo_browser(self, ua):
|
def is_kobo_browser(self, ua):
|
||||||
match = self.KOBO_UA.search(ua)
|
return 'Kobo Touch' in ua
|
||||||
return match is not None
|
|
||||||
|
|
||||||
def add_routes(self, connect):
|
def add_routes(self, connect):
|
||||||
connect('mobile', '/mobile', self.mobile)
|
connect('mobile', '/mobile', self.mobile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user