diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.ui b/src/calibre/gui2/catalog/catalog_epub_mobi.ui
index 6e057a6481..5136f86fae 100644
--- a/src/calibre/gui2/catalog/catalog_epub_mobi.ui
+++ b/src/calibre/gui2/catalog/catalog_epub_mobi.ui
@@ -35,7 +35,7 @@
- Sections to include in catalog. All catalogs include 'Books by Author'.
+ Sections to include in catalog.
Included sections
@@ -79,13 +79,13 @@
-
- false
+ true
Books by Author
- true
+ false
diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py
index ae600a29f9..6b607b7c1f 100644
--- a/src/calibre/library/catalog.py
+++ b/src/calibre/library/catalog.py
@@ -29,7 +29,6 @@ FIELDS = ['all', 'author_sort', 'authors', 'comments',
'series_index', 'series', 'size', 'tags', 'timestamp', 'title',
'uuid']
-
#Allowed fields for template
TEMPLATE_ALLOWED_FIELDS = [ 'author_sort', 'authors', 'id', 'isbn', 'pubdate',
'publisher', 'series_index', 'series', 'tags', 'timestamp', 'title', 'uuid' ]
@@ -605,43 +604,42 @@ class EPUB_MOBI(CatalogPlugin):
"Default: '%default'\n"
"Applies to: ePub, MOBI output formats")),
Option('--generate-authors',
- default=True,
+ default=False,
dest='generate_authors',
action = 'store_true',
- help=_("Include 'Authors' section in catalog."
- "This switch is ignored - Books By Author section is always generated."
+ help=_("Include 'Authors' section in catalog.\n"
"Default: '%default'\n"
"Applies to: ePub, MOBI output formats")),
Option('--generate-descriptions',
- default=True,
+ default=False,
dest='generate_descriptions',
action = 'store_true',
- help=_("Include book descriptions in catalog.\n"
+ help=_("Include 'Descriptions' section in catalog.\n"
"Default: '%default'\n"
"Applies to: ePub, MOBI output formats")),
Option('--generate-genres',
- default=True,
+ default=False,
dest='generate_genres',
action = 'store_true',
help=_("Include 'Genres' section in catalog.\n"
"Default: '%default'\n"
"Applies to: ePub, MOBI output formats")),
Option('--generate-titles',
- default=True,
+ default=False,
dest='generate_titles',
action = 'store_true',
help=_("Include 'Titles' section in catalog.\n"
"Default: '%default'\n"
"Applies to: ePub, MOBI output formats")),
Option('--generate-series',
- default=True,
+ default=False,
dest='generate_series',
action = 'store_true',
help=_("Include 'Series' section in catalog.\n"
"Default: '%default'\n"
"Applies to: ePub, MOBI output formats")),
Option('--generate-recently-added',
- default=True,
+ default=False,
dest='generate_recently_added',
action = 'store_true',
help=_("Include 'Recently Added' section in catalog.\n"
@@ -976,7 +974,7 @@ class EPUB_MOBI(CatalogPlugin):
self.__thumbWidth = 0
self.__thumbHeight = 0
self.__title = opts.catalog_title
- self.__totalSteps = 8.0
+ self.__totalSteps = 6.0
self.__useSeriesPrefixInTitlesSection = False
self.__verbose = opts.verbose
@@ -1014,17 +1012,21 @@ class EPUB_MOBI(CatalogPlugin):
(self.__archive_path, float(cached_thumb_width)))
# Tweak build steps based on optional sections: 1 call for HTML, 1 for NCX
+ incremental_jobs = 0
+ if self.opts.generate_authors:
+ incremental_jobs += 2
if self.opts.generate_titles:
- self.__totalSteps += 2
+ incremental_jobs += 2
if self.opts.generate_recently_added:
- self.__totalSteps += 2
+ incremental_jobs += 2
if self.generateRecentlyRead:
- self.__totalSteps += 2
+ incremental_jobs += 2
if self.opts.generate_series:
- self.__totalSteps += 2
+ incremental_jobs += 2
if self.opts.generate_descriptions:
# +1 thumbs
- self.__totalSteps += 3
+ incremental_jobs += 3
+ self.__totalSteps += incremental_jobs
# Load section list templates
templates = []
@@ -1358,13 +1360,21 @@ class EPUB_MOBI(CatalogPlugin):
if self.opts.generate_descriptions:
self.generateThumbnails()
self.generateHTMLDescriptions()
- self.generateHTMLByAuthor()
+ if self.opts.generate_authors:
+ self.generateHTMLByAuthor()
if self.opts.generate_titles:
self.generateHTMLByTitle()
if self.opts.generate_series:
self.generateHTMLBySeries()
if self.opts.generate_genres:
self.generateHTMLByTags()
+ # If this is the only Section, and there are no genres, bail
+ if self.opts.section_list == ['Genres'] and not self.genres:
+ error_msg = _("No Genres found to catalog.\nCheck 'Excluded genres'\nin E-book options.\n")
+ self.opts.log.error(error_msg)
+ self.error.append(_('No books available to catalog'))
+ self.error.append(error_msg)
+ return False
if self.opts.generate_recently_added:
self.generateHTMLByDateAdded()
if self.generateRecentlyRead:
@@ -1372,7 +1382,8 @@ class EPUB_MOBI(CatalogPlugin):
self.generateOPF()
self.generateNCXHeader()
- self.generateNCXByAuthor("Authors")
+ if self.opts.generate_authors:
+ self.generateNCXByAuthor("Authors")
if self.opts.generate_titles:
self.generateNCXByTitle("Titles")
if self.opts.generate_series:
@@ -1879,7 +1890,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Link to author
emTag = Tag(soup, "em")
aTag = Tag(soup, "a")
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(book['author']))
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(book['author']))
aTag.insert(0, NavigableString(book['author']))
emTag.insert(0,aTag)
pBookTag.insert(ptc, emTag)
@@ -2149,7 +2161,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
pAuthorTag = Tag(soup, "p")
pAuthorTag['class'] = "author_index"
aTag = Tag(soup, "a")
- aTag['name'] = "%s" % self.generateAuthorAnchor(current_author)
+ if self.opts.generate_authors:
+ aTag['name'] = "%s" % self.generateAuthorAnchor(current_author)
aTag.insert(0,NavigableString(current_author))
pAuthorTag.insert(0,aTag)
divTag.insert(dtc,pAuthorTag)
@@ -2276,7 +2289,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Link to author
emTag = Tag(soup, "em")
aTag = Tag(soup, "a")
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(new_entry['author']))
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(new_entry['author']))
aTag.insert(0, NavigableString(new_entry['author']))
emTag.insert(0,aTag)
pBookTag.insert(ptc, emTag)
@@ -2425,7 +2439,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Link to author
emTag = Tag(soup, "em")
aTag = Tag(soup, "a")
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(new_entry['author']))
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(new_entry['author']))
aTag.insert(0, NavigableString(new_entry['author']))
emTag.insert(0,aTag)
pBookTag.insert(ptc, emTag)
@@ -2473,7 +2488,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Link to author
emTag = Tag(soup, "em")
aTag = Tag(soup, "a")
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(new_entry['author']))
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(new_entry['author']))
aTag.insert(0, NavigableString(new_entry['author']))
emTag.insert(0,aTag)
pBookTag.insert(ptc, emTag)
@@ -2692,7 +2708,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Link to author
aTag = Tag(soup, "a")
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor",
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor",
self.generateAuthorAnchor(escape(' & '.join(book['authors']))))
aTag.insert(0, NavigableString(' & '.join(book['authors'])))
pBookTag.insert(ptc, aTag)
@@ -3074,10 +3091,34 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
textTag.insert(0, NavigableString(self.title))
navLabelTag.insert(0, textTag)
navPointTag.insert(0, navLabelTag)
- contentTag = Tag(soup, 'content')
- #contentTag['src'] = "content/book_%d.html" % int(self.booksByTitle[0]['id'])
- contentTag['src'] = "content/ByAlphaAuthor.html"
- navPointTag.insert(1, contentTag)
+
+ if self.opts.generate_authors:
+ contentTag = Tag(soup, 'content')
+ contentTag['src'] = "content/ByAlphaAuthor.html"
+ navPointTag.insert(1, contentTag)
+ elif self.opts.generate_titles:
+ contentTag = Tag(soup, 'content')
+ contentTag['src'] = "content/ByAlphaTitle.html"
+ navPointTag.insert(1, contentTag)
+ elif self.opts.generate_series:
+ contentTag = Tag(soup, 'content')
+ contentTag['src'] = "content/BySeries.html"
+ navPointTag.insert(1, contentTag)
+ elif self.opts.generate_genres:
+ contentTag = Tag(soup, 'content')
+ contentTag['src'] = "content/ByGenres.html"
+ navPointTag.insert(1, contentTag)
+ elif self.opts.generate_recently_added:
+ contentTag = Tag(soup, 'content')
+ contentTag['src'] = "content/ByDateAdded.html"
+ navPointTag.insert(1, contentTag)
+ else:
+ sort_descriptions_by = self.booksByAuthor if self.opts.sort_descriptions_by_author \
+ else self.booksByTitle
+ contentTag = Tag(soup, 'content')
+ contentTag['src'] = "content/book_%d.html" % int(sort_descriptions_by[0]['id'])
+ navPointTag.insert(1, contentTag)
+
cmiTag = Tag(soup, '%s' % 'calibre:meta-img')
cmiTag['name'] = "mastheadImage"
cmiTag['src'] = "images/mastheadImage.gif"
@@ -4140,7 +4181,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
pAuthorTag = Tag(soup, "p")
pAuthorTag['class'] = "author_index"
aTag = Tag(soup, "a")
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(book['author']))
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor", self.generateAuthorAnchor(book['author']))
aTag.insert(0, book['author'])
pAuthorTag.insert(0,aTag)
divTag.insert(dtc,pAuthorTag)
@@ -4371,7 +4413,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Insert the author link (always)
aTag = body.find('a', attrs={'class':'author'})
- aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor",
+ if self.opts.generate_authors:
+ aTag['href'] = "%s.html#%s" % ("ByAlphaAuthor",
self.generateAuthorAnchor(book['author']))
if publisher == ' ':
@@ -4860,6 +4903,8 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
opts.basename = "Catalog"
opts.cli_environment = not hasattr(opts,'sync')
+
+ # Hard-wired to always sort descriptions by author, with series after non-series
opts.sort_descriptions_by_author = True
build_log = []
@@ -4898,14 +4943,13 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
if opts_dict['ids']:
build_log.append(" book count: %d" % len(opts_dict['ids']))
- '''
sections_list = []
if opts.generate_authors:
sections_list.append('Authors')
- '''
- sections_list = ['Authors']
if opts.generate_titles:
sections_list.append('Titles')
+ if opts.generate_series:
+ sections_list.append('Series')
if opts.generate_genres:
sections_list.append('Genres')
if opts.generate_recently_added:
@@ -4913,7 +4957,18 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
if opts.generate_descriptions:
sections_list.append('Descriptions')
+ if not sections_list:
+ opts.log.warn('\n*** No enabled Sections, terminating catalog generation ***')
+ opts.log.warn('When invoking from the CLI, add one or more of the Section switches:\n'
+ ' --generate-authors\n'
+ ' --generate-titles\n'
+ ' --generate-series\n'
+ ' --generate-genres\n'
+ ' --generate-recently-added\n'
+ ' --generate-descriptions')
+ return ["No Included Sections","No enabled Sections.\nCheck E-book options tab\n'Included sections'\n"]
build_log.append(u" Sections: %s" % ', '.join(sections_list))
+ opts.section_list = sections_list
# Limit thumb_width to 1.0" - 2.0"
try:
@@ -4948,6 +5003,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
# Launch the Catalog builder
catalog = self.CatalogBuilder(db, opts, self, report_progress=notification)
+
if opts.verbose:
log.info(" Begin catalog source generation")
catalog.createDirectoryStructure()