/browse: Make category listing also more semantic and pentadactyl friendly

This commit is contained in:
Kovid Goyal 2010-10-30 19:25:50 -06:00
parent d3814a3a5a
commit 39e102e3f8
5 changed files with 21 additions and 12 deletions

View File

@ -263,9 +263,16 @@ h2.library_name {
} }
.category div.category-item span.href { display: none } .category div.category-item a { text-decoration: none; color: inherit; }
#groups span.load_href { display: none } #groups a.load_href {
text-decoration: none;
color: inherit;
font-size: medium;
font-weight: normal;
padding: 0;
padding-left: 0.5em;
}
#groups h3 { #groups h3 {
font-weight: bold; font-weight: bold;

View File

@ -133,7 +133,7 @@ function render_error(msg) {
// Category feed {{{ // Category feed {{{
function category_clicked() { function category_clicked() {
var href = $(this).find("span.href").html(); var href = $(this).find("a").attr('href');
window.location = href; window.location = href;
} }
@ -151,7 +151,7 @@ function category() {
change: function(event, ui) { change: function(event, ui) {
if (ui.newContent) { if (ui.newContent) {
var href = ui.newContent.children("span.load_href").html(); var href = ui.newContent.prev().children("a.load_href").attr('href');
ui.newContent.children(".loading").show(); ui.newContent.children(".loading").show();
if (href) { if (href) {
$.ajax({ $.ajax({

View File

@ -18,7 +18,7 @@ class Server(Command):
def rebuild_monocole(self): def rebuild_monocole(self):
subprocess.check_call(['sprocketize', '-C', self.MONOCLE_PATH, subprocess.check_call(['sprocketize', '-C', self.MONOCLE_PATH,
'-I', 'src', 'src/monocle.js'], '-I', 'src', 'src/monocle.js'],
stdout=open('resources/content_server/monocle.js', 'wb')) stdout=open('resources/content_server/read/monocle.js', 'wb'))
def launch_server(self, log): def launch_server(self, log):
self.rebuild_monocole() self.rebuild_monocole()

View File

@ -123,9 +123,10 @@ def get_category_items(category, items, restriction, datatype, prefix): # {{{
def item(i): def item(i):
templ = (u'<div title="{4}" class="category-item">' templ = (u'<div title="{4}" class="category-item">'
'<div class="category-name">{0}</div><div>{1}</div>' '<div class="category-name">'
'<div>{2}' '<a href="{5}{3}" title="{4}">{0}</a></div>'
'<span class="href">{5}{3}</span></div></div>') '<div>{1}</div>'
'<div>{2}</div></div>')
rating, rstring = render_rating(i.avg_rating, prefix) rating, rstring = render_rating(i.avg_rating, prefix)
name = xml(i.name) name = xml(i.name)
if datatype == 'rating': if datatype == 'rating':
@ -142,7 +143,7 @@ def get_category_items(category, items, restriction, datatype, prefix): # {{{
q = category q = category
href = '/browse/matches/%s/%s'%(quote(q), quote(id_)) href = '/browse/matches/%s/%s'%(quote(q), quote(id_))
return templ.format(xml(name), rating, return templ.format(xml(name), rating,
xml(desc), xml(href), rstring, prefix) xml(desc), xml(href, True), rstring, prefix)
items = list(map(item, items)) items = list(map(item, items))
return '\n'.join(['<div class="category-container">'] + items + ['</div>']) return '\n'.join(['<div class="category-container">'] + items + ['</div>'])
@ -394,14 +395,15 @@ class BrowseServer(object):
for x in sorted(starts): for x in sorted(starts):
category_groups[x] = len([y for y in items if category_groups[x] = len([y for y in items if
getter(y).upper().startswith(x)]) getter(y).upper().startswith(x)])
items = [(u'<h3 title="{0}">{0} <span>[{2}]</span></h3><div>' items = [(u'<h3 title="{0}"><a class="load_href" title="{0}"'
u' href="{4}{3}"><strong>{0}</strong> [{2}]</a></h3><div>'
u'<div class="loaded" style="display:none"></div>' u'<div class="loaded" style="display:none"></div>'
u'<div class="loading"><img alt="{1}" src="{4}/static/loading.gif" /><em>{1}</em></div>' u'<div class="loading"><img alt="{1}" src="{4}/static/loading.gif" /><em>{1}</em></div>'
u'<span class="load_href">{4}{3}</span></div>').format( u'</div>').format(
xml(s, True), xml(s, True),
xml(_('Loading, please wait'))+'&hellip;', xml(_('Loading, please wait'))+'&hellip;',
unicode(c), unicode(c),
xml(u'/browse/category_group/%s/%s'%(category, s)), xml(u'/browse/category_group/%s/%s'%(category, s), True),
self.opts.url_prefix) self.opts.url_prefix)
for s, c in category_groups.items()] for s, c in category_groups.items()]
items = '\n\n'.join(items) items = '\n\n'.join(items)