From c79032285c48943e01de23104fca3e74123e837c Mon Sep 17 00:00:00 2001 From: GRiker Date: Tue, 7 Sep 2010 14:11:07 -0700 Subject: [PATCH] GwR revisions supporting Series Section --- resources/catalog/stylesheet.css | 24 +++++++----- src/calibre/library/catalog.py | 66 ++++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/resources/catalog/stylesheet.css b/resources/catalog/stylesheet.css index 4f9ca9ac41..ff338fb130 100644 --- a/resources/catalog/stylesheet.css +++ b/resources/catalog/stylesheet.css @@ -6,7 +6,7 @@ p.title { text-align:center; font-style:italic; font-size:xx-large; - border-bottom: solid black 4px; + border-bottom: solid black 2px; } p.author { @@ -17,6 +17,15 @@ p.author { font-size:large; } +p.author_index { + font-size:large; + font-weight:bold; + text-align:left; + margin-top:0px; + margin-bottom:0px; + text-indent: 0em; + } + p.tags { margin-top:0em; margin-bottom:0em; @@ -47,19 +56,12 @@ p.letter_index { margin-bottom:0px; } -p.author_index { - font-size:large; - text-align:left; - margin-top:0px; - margin-bottom:0px; - text-indent: 0em; - } - p.series { - text-align: left; + font-style:italic; margin-top:0px; margin-bottom:0px; margin-left:2em; + text-align: left; text-indent:-2em; } @@ -88,6 +90,8 @@ p.date_read { } hr.series_divider { + border-style:solid; + border-width:thin; width:50%; margin-left:1em; margin-top:0em; diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 05e596d3fb..fb6dd08705 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -1760,12 +1760,13 @@ class EPUB_MOBI(CatalogPlugin): if not self.__generateForKindle: # We don't need this because the Kindle shows section titles #

By Title

- h2Tag = Tag(soup, "h2") + pTag = Tag(soup, "p") + pTag['class'] = 'title' aTag = Tag(soup, "a") aTag['name'] = "bytitle" - h2Tag.insert(0,aTag) - h2Tag.insert(1,NavigableString('By Title (%d)' % len(self.booksByTitle))) - body.insert(btc,h2Tag) + pTag.insert(0,aTag) + pTag.insert(1,NavigableString('By Title')) + body.insert(btc,pTag) btc += 1 #

@@ -1938,12 +1939,10 @@ class EPUB_MOBI(CatalogPlugin): current_series = None pAuthorTag = Tag(soup, "p") pAuthorTag['class'] = "author_index" - emTag = Tag(soup, "em") aTag = Tag(soup, "a") aTag['name'] = "%s" % self.generateAuthorAnchor(current_author) aTag.insert(0,NavigableString(current_author)) - emTag.insert(0,aTag) - pAuthorTag.insert(0,emTag) + pAuthorTag.insert(0,aTag) divTag.insert(dtc,pAuthorTag) dtc += 1 @@ -1961,7 +1960,17 @@ class EPUB_MOBI(CatalogPlugin): current_series = book['series'] pSeriesTag = Tag(soup,'p') pSeriesTag['class'] = "series" - pSeriesTag.insert(0,NavigableString(self.NOT_READ_SYMBOL + '%s' % book['series'])) + + if self.opts.generate_series: + aTag = Tag(soup,'a') + aTag['href'] = "%s.html#%s_series" % ('BySeries', + re.sub('\W','',book['series']).lower()) + aTag.insert(0, book['series']) + pSeriesTag.insert(0, NavigableString(self.NOT_READ_SYMBOL)) + pSeriesTag.insert(1, aTag) + else: + pSeriesTag.insert(0,NavigableString(self.NOT_READ_SYMBOL + '%s' % book['series'])) + divTag.insert(dtc,pSeriesTag) dtc += 1 if current_series and not book['series']: @@ -2004,13 +2013,15 @@ class EPUB_MOBI(CatalogPlugin): if not self.__generateForKindle: # Insert the

tag with book_count at the head #

By Author

- h2Tag = Tag(soup, "h2") + pTag = Tag(soup, "p") + pTag['class'] = 'title' aTag = Tag(soup, "a") anchor_name = friendly_name.lower() aTag['name'] = anchor_name.replace(" ","") - h2Tag.insert(0,aTag) - h2Tag.insert(1,NavigableString('%s (%d)' % (friendly_name, book_count))) - body.insert(btc,h2Tag) + pTag.insert(0,aTag) + #h2Tag.insert(1,NavigableString('%s (%d)' % (friendly_name, book_count))) + pTag.insert(1,NavigableString('%s' % (friendly_name))) + body.insert(btc,pTag) btc += 1 # Add the divTag to the body @@ -2590,7 +2601,22 @@ class EPUB_MOBI(CatalogPlugin): aTag = Tag(soup, "a") aTag['href'] = "book_%d.html" % (int(float(book['id']))) # Use series, series index if avail else just title - aTag.insert(0,'%d. %s · %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors']))) + #aTag.insert(0,'%d. %s · %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors']))) + + # Link to book + aTag.insert(0,'%d. %s' % (book['series_index'],escape(book['title']))) + pBookTag.insert(ptc, aTag) + ptc += 1 + + # · + pBookTag.insert(ptc, NavigableString(' · ')) + ptc += 1 + + # Link to author + aTag = Tag(soup, "a") + aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", + self.generateAuthorAnchor(' & '.join(book['authors']))) + aTag.insert(0, NavigableString(' & '.join(book['authors']))) pBookTag.insert(ptc, aTag) ptc += 1 @@ -2600,13 +2626,15 @@ class EPUB_MOBI(CatalogPlugin): if not self.__generateForKindle: # Insert the

tag with book_count at the head #

By Series

- h2Tag = Tag(soup, "h2") + pTag = Tag(soup, "p") + pTag['class'] = 'title' aTag = Tag(soup, "a") anchor_name = friendly_name.lower() aTag['name'] = anchor_name.replace(" ","") - h2Tag.insert(0,aTag) - h2Tag.insert(1,NavigableString('%s (%d)' % (friendly_name, series_count))) - body.insert(btc,h2Tag) + pTag.insert(0,aTag) + #h2Tag.insert(1,NavigableString('%s (%d)' % (friendly_name, series_count))) + pTag.insert(1,NavigableString('%s' % friendly_name)) + body.insert(btc,pTag) btc += 1 # Add the divTag to the body @@ -4003,12 +4031,10 @@ class EPUB_MOBI(CatalogPlugin): current_series = None pAuthorTag = Tag(soup, "p") pAuthorTag['class'] = "author_index" - emTag = Tag(soup, "em") aTag = Tag(soup, "a") aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(book['author'])) aTag.insert(0, book['author']) - emTag.insert(0,aTag) - pAuthorTag.insert(0,emTag) + pAuthorTag.insert(0,aTag) divTag.insert(dtc,pAuthorTag) dtc += 1