KG updates

This commit is contained in:
GRiker 2010-11-18 10:14:24 -07:00
commit 1c74d73553
10 changed files with 87 additions and 17 deletions

View File

@ -355,6 +355,25 @@ h2.library_name {
color: red;
}
#booklist > #pagelist { display: none; }
#goto_page_dialog ul {
list-style-type: none;
font-size: medium;
}
#goto_page_dialog li {
margin-bottom: 1.5ex;
}
#goto_page_dialog a {
text-decoration: none;
color: blue;
}
#goto_page_dialog a:hover {
color: red;
}
#booklist .left .ui-button-text {
font-size: medium;

View File

@ -96,5 +96,6 @@
</div>
</div>
<div id="book_details_dialog"></div>
<div id="goto_page_dialog"></div>
</body>
</html>

View File

@ -202,6 +202,23 @@ function previous_page() {
else last_page();
}
function gp_internal(id) {
var gp = $('#goto_page_dialog');
gp.dialog('close');
var elem = $("#booklist #" + id);
load_page(elem);
}
function goto_page() {
var gp = $('#goto_page_dialog');
var pl = $('#booklist > #pagelist');
gp.html(pl.html());
gp.dialog('option', 'title', pl.attr('title'));
gp.dialog('option', 'height', $(window).height() - 100);
gp.dialog('open');
}
function load_page(elem) {
if (elem.is(":visible")) return;
var ld = elem.find('.load_data');
@ -251,6 +268,12 @@ function booklist(hide_sort) {
modal: true,
show: 'slide'
});
$("#goto_page_dialog").dialog({
autoOpen: false,
modal: true,
show: 'slide'
});
first_page();
}

View File

@ -13,7 +13,6 @@ class IrishTimes(BasicNewsRecipe):
language = 'en_IE'
timefmt = ' (%A, %B %d, %Y)'
oldest_article = 3
no_stylesheets = True
simultaneous_downloads= 1
@ -35,12 +34,11 @@ class IrishTimes(BasicNewsRecipe):
def print_version(self, url):
if url.count('rss.feedsportal.com'):
u = 'http://www.irishtimes.com' + \
(((url[69:].replace('0C','/')).replace('0A','0'))).replace('0Bhtml/story01..htm','_pf.html')
u = 'http://www.irishtimes.com' + \
(((url[69:].replace('0C','/')).replace('0A','0'))).replace('0Bhtml/story01.htm','_pf.html')
else:
u = url.replace('.html','_pf.html')
return u
def get_article_url(self, article):
return article.link

View File

@ -241,9 +241,12 @@ class EPUBOutput(OutputFormatPlugin):
self.log.debug('Encrypting font:', uri)
with open(path, 'r+b') as f:
data = f.read(1024)
f.seek(0)
for i in range(1024):
f.write(chr(ord(data[i]) ^ key[i%16]))
if len(data) >= 1024:
f.seek(0)
for i in range(1024):
f.write(chr(ord(data[i]) ^ key[i%16]))
else:
self.log.warn('Font', path, 'is invalid, ignoring')
if not isinstance(uri, unicode):
uri = uri.decode('utf-8')
fonts.append(u'''

View File

@ -118,8 +118,8 @@ class SNBFile:
return False
if self.rev80 != SNBFile.REV80:
return False
if self.revA3 != SNBFile.REVA3:
return False
# if self.revA3 != SNBFile.REVA3:
# return False
if self.revZ1 != SNBFile.REVZ1:
return False
if self.revZ2 != SNBFile.REVZ2:

View File

@ -315,6 +315,9 @@ class ToolBar(QToolBar): # {{{
self.child_bar.addWidget(self.spacers[1])
if gprefs['show_child_bar']:
self.addWidget(self.spacers[3])
else:
for s in self.spacers[2:]:
s.setVisible(False)
def setup_tool_button(self, ac, menu_mode=None):
ch = self.widgetForAction(ac)

View File

@ -131,7 +131,8 @@ def comments_to_html(comments):
def sanitize_comments_html(html):
text = html2text(html)
md = markdown.Markdown(safe_mode=True)
return md.convert(text)
cleansed = re.sub('\n+', '', md.convert(text))
return cleansed
def test():
for pat, val in [

View File

@ -147,7 +147,7 @@ class LibraryServer(ContentServer, MobileServer, XMLServer, OPDSServer, Cache,
self.config['/'] = {
'tools.digest_auth.on' : True,
'tools.digest_auth.realm' : (
_('Password to access your calibre library. Username is ')
'Password to access your calibre library. Username is '
+ opts.username.strip()),
'tools.digest_auth.users' : {opts.username.strip():opts.password.strip()},
}

View File

@ -43,18 +43,33 @@ def render_book_list(ids, prefix, suffix=''): # {{{
<div class="loaded"></div>
</div>
'''
rpages = []
pagelist_template = u'''\
<div class="pagelist">
<ul>
{pages}
</ul>
</div>
'''
rpages, lpages = [], []
for i, x in enumerate(pages):
pg, pos = x
ld = xml(json.dumps(pg), True)
start, end = pos+1, pos+len(pg)
rpages.append(page_template.format(i, ld,
xml(_('Loading, please wait')) + '&hellip;',
start=pos+1, end=pos+len(pg), prefix=prefix))
start=start, end=end, prefix=prefix))
lpages.append(' '*20 + (u'<li><a href="#" title="Books {start} to {end}"'
' onclick="gp_internal(\'{id}\'); return false;"> '
'{start}&nbsp;to&nbsp;{end}</a></li>').format(start=start, end=end,
id='page%d'%i))
rpages = u'\n\n'.join(rpages)
lpages = u'\n'.join(lpages)
pagelist = pagelist_template.format(pages=lpages)
templ = u'''\
<h3>{0} {suffix}</h3>
<div id="booklist">
<div id="pagelist" title="{goto}">{pagelist}</div>
<div class="listnav topnav">
{navbar}
</div>
@ -64,24 +79,31 @@ def render_book_list(ids, prefix, suffix=''): # {{{
</div>
</div>
'''
gp_start = gp_end = ''
if len(pages) > 1:
gp_start = '<a href="#" onclick="goto_page(); return false;" title="%s">' % \
(_('Go to') + '&hellip;')
gp_end = '</a>'
navbar = u'''\
<div class="navleft">
<a href="#" onclick="first_page(); return false;">{first}</a>
<a href="#" onclick="previous_page(); return false;">{previous}</a>
</div>
<div class="navmiddle">
<span class="start">0</span> to <span class="end">0</span> of {num}
{gp_start}
<span class="start">0</span> to <span class="end">0</span>
{gp_end}of {num}
</div>
<div class="navright">
<a href="#" onclick="next_page(); return false;">{next}</a>
<a href="#" onclick="last_page(); return false;">{last}</a>
</div>
'''.format(first=_('First'), last=_('Last'), previous=_('Previous'),
next=_('Next'), num=num)
next=_('Next'), num=num, gp_start=gp_start, gp_end=gp_end)
return templ.format(_('Browsing %d books')%num, suffix=suffix,
pages=rpages, navbar=navbar)
pages=rpages, navbar=navbar, pagelist=pagelist,
goto=xml(_('Go to'), True) + '&hellip;')
# }}}