diff --git a/imgsrc/rating.svg b/imgsrc/rating.svg new file mode 100644 index 0000000000..d289c71b99 --- /dev/null +++ b/imgsrc/rating.svg @@ -0,0 +1,589 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/rating.png b/resources/images/rating.png new file mode 100644 index 0000000000..81eba505b9 Binary files /dev/null and b/resources/images/rating.png differ diff --git a/resources/images/star.png b/resources/images/star.png deleted file mode 100644 index 6eb1fb890f..0000000000 Binary files a/resources/images/star.png and /dev/null differ diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index c55936be2d..4c14565c2d 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -36,15 +36,15 @@ class PRS505(USBMS): VENDOR_NAME = 'SONY' WINDOWS_MAIN_MEM = re.compile( r'(PRS-(505|300|500))|' - r'(PRS-((700[#/])|((6|9)00&)))' + r'(PRS-((700[#/])|((6|9|3)(0|5)0&)))' ) WINDOWS_CARD_A_MEM = re.compile( r'(PRS-(505|500)[#/]\S+:MS)|' - r'(PRS-((700[/#]\S+:)|((6|9)00[#_]))MS)' + r'(PRS-((700[/#]\S+:)|((6|9)(0|5)0[#_]))MS)' ) WINDOWS_CARD_B_MEM = re.compile( r'(PRS-(505|500)[#/]\S+:SD)|' - r'(PRS-((700[/#]\S+:)|((6|9)00[#_]))SD)' + r'(PRS-((700[/#]\S+:)|((6|9)(0|5)0[#_]))SD)' ) diff --git a/src/calibre/ebooks/oeb/transforms/jacket.py b/src/calibre/ebooks/oeb/transforms/jacket.py index ff192ca537..a44a18db95 100644 --- a/src/calibre/ebooks/oeb/transforms/jacket.py +++ b/src/calibre/ebooks/oeb/transforms/jacket.py @@ -8,16 +8,13 @@ __docformat__ = 'restructuredtext en' import sys from xml.sax.saxutils import escape -from itertools import repeat from lxml import etree from calibre import guess_type, strftime -from calibre.constants import __appname__, __version__ from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML from calibre.library.comments import comments_to_html -from calibre.utils.magick.draw import save_cover_data_to JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]' @@ -51,27 +48,24 @@ class Jacket(object): def insert_metadata(self, mi): self.log('Inserting metadata into book...') - fname = 'star.png' - img = I(fname, data=True) - - if self.opts.output_profile.short_name == 'kindle': - # Original star.png size: 24x23 - # Needs to be scaled by half - fname = 'star.jpg' - img = save_cover_data_to(img, fname, - return_data=True, resize_to=[12,12]) - - id, href = self.oeb.manifest.generate('calibre_jacket_star', fname) - self.oeb.manifest.add(id, href, guess_type(fname)[0], data=img) - try: tags = map(unicode, self.oeb.metadata.subject) except: tags = [] - root = render_jacket(mi, self.opts.output_profile, star_href=href, - alt_title=unicode(self.oeb.metadata.title[0]), alt_tags=tags, - alt_comments=unicode(self.oeb.metadata.description[0])) + try: + comments = unicode(self.oeb.metadata.description[0]) + except: + comments = '' + + try: + title = unicode(self.oeb.metadata.title[0]) + except: + title = _('Unknown') + + root = render_jacket(mi, self.opts.output_profile, + alt_title=title, alt_tags=tags, + alt_comments=comments) id, href = self.oeb.manifest.generate('calibre_jacket', 'jacket.xhtml') item = self.oeb.manifest.add(id, href, guess_type(href)[0], data=root) @@ -82,6 +76,7 @@ class Jacket(object): if XPath(JACKET_XPATH)(x.data): self.remove_images(x, limit=sys.maxint) self.oeb.manifest.remove(x) + self.log('Removed existing jacket') break def __call__(self, oeb, opts, metadata): @@ -98,7 +93,7 @@ class Jacket(object): # Render Jacket {{{ -def get_rating(rating, href, output_profile): +def get_rating(rating): ans = '' try: num = float(rating)/2 @@ -109,17 +104,11 @@ def get_rating(rating, href, output_profile): if num < 1: return ans - if href is not None: - ans = ' '.join(repeat( - 'star'% - href, int(num))) - else: - ans = u' '.join(u'\u2605') - + ans = u'\u2605' * int(num) return ans -def render_jacket(mi, output_profile, star_href=None, +def render_jacket(mi, output_profile, alt_title=_('Unknown'), alt_tags=[], alt_comments=''): css = P('jacket/stylesheet.css', data=True).decode('utf-8') @@ -140,7 +129,7 @@ def render_jacket(mi, output_profile, star_href=None, except: pubdate = '' - rating = get_rating(mi.rating, star_href, output_profile) + rating = get_rating(mi.rating) tags = mi.tags if mi.tags else alt_tags if tags: @@ -154,8 +143,6 @@ def render_jacket(mi, output_profile, star_href=None, if comments: comments = comments_to_html(comments) - footer = 'BOOK JACKET GENERATED BY %s %s' % (__appname__.upper(),__version__) - def generate_html(comments): args = dict(xmlns=XHTML_NS, title_str=title_str, @@ -166,7 +153,8 @@ def render_jacket(mi, output_profile, star_href=None, rating_label=_('Rating'), rating=rating, tags_label=_('Tags'), tags=tags, comments=comments, - footer = footer) + footer='' + ) generated_html = P('jacket/template.xhtml', data=True).decode('utf-8').format(**args) diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index 519d533ff6..6c50a71b92 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -376,7 +376,7 @@ class TagsModel(QAbstractItemModel): # {{{ 'series' : QIcon(I('series.png')), 'formats' : QIcon(I('book.png')), 'publisher' : QIcon(I('publisher.png')), - 'rating' : QIcon(I('star.png')), + 'rating' : QIcon(I('rating.png')), 'news' : QIcon(I('news.png')), 'tags' : QIcon(I('tags.png')), ':custom' : QIcon(I('column.png')), diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 8a5ab75c3c..2df6b3bdc4 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -597,7 +597,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): return identical_book_ids def has_cover(self, index, index_is_id=False): - id = index if index_is_id else self.id(index) + id = index if index_is_id else self.id(index) path = os.path.join(self.library_path, self.path(id, index_is_id=True), 'cover.jpg') return os.access(path, os.R_OK)