diff --git a/CoverPages.py b/CoverPages.py index f5f8ee2..efa5598 100644 --- a/CoverPages.py +++ b/CoverPages.py @@ -18,7 +18,7 @@ import cherrypy import six import textwrap from libgutenberg import GutenbergGlobals as gg - +import re import BaseSearcher class CoverPages (object): @@ -34,46 +34,33 @@ class CoverPages (object): cherrypy.response.headers['Content-Type'] = 'text/html; charset=utf-8' cherrypy.response.headers['Content-Language'] = 'en' - s = """ - - + s = """ + - -
-->""" +--> +""" for row in rows: url = '/' + row.filename href = '/ebooks/%d' % row.pk title = gg.xmlspecialchars (row.title) - title = title.replace ('"', '"') - title_len=len(title) - #title = re.sub (r'\s*\$[a-z].*', '', title) - title= title.splitlines()[0] + #Shortening long titles for latest covers + short_title = title + short_title = short_title.replace ('"', '"') + title_len = len(title) + short_title = re.sub(r"\-+"," ",short_title) + #title = re.sub (r"\-+"," ",title) + #new_title= re.sub(r'\-+',' ',title) + short_title = short_title.splitlines()[0] if(title_len>80): - title=textwrap.wrap(title,50)[0] + short_title = textwrap.wrap(short_title,80)[0] - - s += """
{title}
{title}\n
\n""".format ( - url = url, href = href, title = title, size = size) + s += """
+
{title} +
{short_title}
\n""".format ( + url = url, href = href, title = title, short_title = short_title, size = size) return (s + '\n').encode ('utf-8')