mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Top level feed done
This commit is contained in:
parent
1737226363
commit
2457241f11
@ -183,3 +183,28 @@ h2.library_name {
|
|||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
/* Top level {{{ */
|
||||||
|
.toplevel ul {
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toplevel li {
|
||||||
|
margin: 0.75em;
|
||||||
|
padding: 0.75em;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toplevel li:hover {
|
||||||
|
background-color: #d6d3c9;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toplevel li span { display: none }
|
||||||
|
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
<div> </div>
|
<div> </div>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
xxx
|
{main}
|
||||||
</div>
|
</div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
[{library_path}] Created by Kovid Goyal
|
[{library_path}] Created by Kovid Goyal
|
||||||
|
@ -119,5 +119,12 @@ function init() {
|
|||||||
// Top-level feed {{{
|
// Top-level feed {{{
|
||||||
function toplevel() {
|
function toplevel() {
|
||||||
$(".sort_select").hide();
|
$(".sort_select").hide();
|
||||||
|
|
||||||
|
$(".toplevel li").corner("15px");
|
||||||
|
|
||||||
|
$(".toplevel li").click(function() {
|
||||||
|
var href = $(this).children("span").html();
|
||||||
|
window.location = href;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
@ -63,13 +63,37 @@ class BrowseServer(object):
|
|||||||
# Catalogs {{{
|
# Catalogs {{{
|
||||||
def browse_catalog(self, category=None):
|
def browse_catalog(self, category=None):
|
||||||
if category == None:
|
if category == None:
|
||||||
#categories = self.categories_cache()
|
categories = self.categories_cache()
|
||||||
|
category_meta = self.db.field_metadata
|
||||||
|
cats = [
|
||||||
|
(_('Newest'), 'newest'),
|
||||||
|
]
|
||||||
|
def getter(x):
|
||||||
|
return category_meta[x]['name'].lower()
|
||||||
|
for category in sorted(categories,
|
||||||
|
cmp=lambda x,y: cmp(getter(x), getter(y))):
|
||||||
|
if len(categories[category]) == 0:
|
||||||
|
continue
|
||||||
|
if category == 'formats':
|
||||||
|
continue
|
||||||
|
meta = category_meta.get(category, None)
|
||||||
|
if meta is None:
|
||||||
|
continue
|
||||||
|
cats.append((meta['name'], category))
|
||||||
|
cats = ['<li title="{2} {0}">{0}<span>/browse/category/{1}</span></li>'.format(xml(x, True),
|
||||||
|
xml(y), xml(_('Browse books by'))) for x, y in cats]
|
||||||
|
|
||||||
|
main = '<div class="toplevel"><h3>{0}</h3><ul>{1}</ul></div>'\
|
||||||
|
.format(_('Choose a category to browse by:'), '\n\n'.join(cats))
|
||||||
ans = self.browse_template().format(title='',
|
ans = self.browse_template().format(title='',
|
||||||
script='toplevel();')
|
script='toplevel();', main=main)
|
||||||
else:
|
else:
|
||||||
raise cherrypy.HTTPError(404, 'Not found')
|
raise cherrypy.HTTPError(404, 'Not found')
|
||||||
|
|
||||||
cherrypy.response.headers['Content-Type'] = 'text/html'
|
cherrypy.response.headers['Content-Type'] = 'text/html'
|
||||||
cherrypy.response.headers['Last-Modified'] = self.last_modified(self.build_time)
|
updated = self.db.last_modified()
|
||||||
|
cherrypy.response.headers['Last-Modified'] = \
|
||||||
|
self.last_modified(max(updated, self.build_time))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -30,7 +30,10 @@ class Cache(object):
|
|||||||
|
|
||||||
def categories_cache(self, restrict_to=frozenset([])):
|
def categories_cache(self, restrict_to=frozenset([])):
|
||||||
base_restriction = self.search_cache('')
|
base_restriction = self.search_cache('')
|
||||||
restrict_to = frozenset(restrict_to).intersection(base_restriction)
|
if restrict_to:
|
||||||
|
restrict_to = frozenset(restrict_to).intersection(base_restriction)
|
||||||
|
else:
|
||||||
|
restrict_to = base_restriction
|
||||||
old = self._category_cache.pop(frozenset(restrict_to), None)
|
old = self._category_cache.pop(frozenset(restrict_to), None)
|
||||||
if old is None or old[0] <= self.db.last_modified():
|
if old is None or old[0] <= self.db.last_modified():
|
||||||
categories = self.db.get_categories(ids=restrict_to)
|
categories = self.db.get_categories(ids=restrict_to)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user