mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
...
This commit is contained in:
parent
4599583764
commit
d68ff1ebc1
@ -9,7 +9,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from binascii import hexlify, unhexlify
|
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
@ -188,7 +187,7 @@ class AjaxServer(object):
|
|||||||
if category.startswith('@'):
|
if category.startswith('@'):
|
||||||
category = category.partition('.')[0]
|
category = category.partition('.')[0]
|
||||||
display_name = category[1:]
|
display_name = category[1:]
|
||||||
url = hexlify(force_unicode(category).encode('utf-8'))
|
url = force_unicode(category).encode('utf-8')
|
||||||
icon = category_icon(category, meta)
|
icon = category_icon(category, meta)
|
||||||
ans[url] = (display_name, icon)
|
ans[url] = (display_name, icon)
|
||||||
|
|
||||||
@ -245,10 +244,7 @@ class AjaxServer(object):
|
|||||||
toplevel = name
|
toplevel = name
|
||||||
subcategory = None
|
subcategory = None
|
||||||
else:
|
else:
|
||||||
try:
|
subcategory = name
|
||||||
subcategory = unhexlify(name)
|
|
||||||
except:
|
|
||||||
raise cherrypy.HTTPError(404, 'Invalid category id: %r'%name)
|
|
||||||
toplevel = subcategory.partition('.')[0]
|
toplevel = subcategory.partition('.')[0]
|
||||||
if toplevel == subcategory:
|
if toplevel == subcategory:
|
||||||
subcategory = None
|
subcategory = None
|
||||||
@ -310,7 +306,7 @@ class AjaxServer(object):
|
|||||||
children = set('.'.join(x[:lsp+1]) for x in category_names if len(x) >
|
children = set('.'.join(x[:lsp+1]) for x in category_names if len(x) >
|
||||||
lsp+1 and x[:lsp] == subcategory_parts)
|
lsp+1 and x[:lsp] == subcategory_parts)
|
||||||
subcategories = [{'name':x.rpartition('.')[-1],
|
subcategories = [{'name':x.rpartition('.')[-1],
|
||||||
'url':hexlify(toplevel+'.'+x),
|
'url':toplevel+'.'+x,
|
||||||
'icon':category_icon(toplevel, meta)} for x in children]
|
'icon':category_icon(toplevel, meta)} for x in children]
|
||||||
else:
|
else:
|
||||||
items = categories[toplevel]
|
items = categories[toplevel]
|
||||||
@ -333,7 +329,8 @@ class AjaxServer(object):
|
|||||||
'average_rating': x.avg_rating,
|
'average_rating': x.avg_rating,
|
||||||
'count': x.count,
|
'count': x.count,
|
||||||
'url': absurl(self.opts.url_prefix, '/ajax/books_in/%s/%s'%(
|
'url': absurl(self.opts.url_prefix, '/ajax/books_in/%s/%s'%(
|
||||||
hexlify(toplevel), hexlify(x.original_name))),
|
x.category if x.category else toplevel,
|
||||||
|
x.original_name)),
|
||||||
'has_children': x.original_name in children,
|
'has_children': x.original_name in children,
|
||||||
} for x in items]
|
} for x in items]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user