diff --git a/src/calibre/web/feeds/input.py b/src/calibre/web/feeds/input.py index adb2f13a56..a2527a2a70 100644 --- a/src/calibre/web/feeds/input.py +++ b/src/calibre/web/feeds/input.py @@ -101,5 +101,10 @@ class RecipeInput(InputFormatPlugin): return os.path.abspath(f) def postprocess_book(self, oeb, opts, log): + if opts.no_inline_navbars: + from calibre.ebooks.oeb.base import XPath + for item in oeb.spine: + for div in XPath('//h:div[contains(@class, "calibre_navbar")]')(item.data): + div.getparent().remove(div) self.recipe_object.postprocess_book(oeb, opts, log) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 8b1757371d..d0c9d941e3 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -266,7 +266,7 @@ class BasicNewsRecipe(Recipe): font-weight: bold; } - .navbar { + .calibre_navbar { font-family:monospace; } ''' @@ -525,7 +525,6 @@ class BasicNewsRecipe(Recipe): self.username = options.username self.password = options.password self.lrf = options.lrf - self.include_navbars = not options.no_inline_navbars self.output_dir = os.path.abspath(self.output_dir) if options.test: @@ -597,7 +596,7 @@ class BasicNewsRecipe(Recipe): if first_fetch and job_info: url, f, a, feed_len = job_info body = soup.find('body') - if body is not None and self.include_navbars: + if body is not None: templ = self.navbar.generate(False, f, a, feed_len, not self.has_single_feed, url, __appname__, @@ -1149,13 +1148,12 @@ class BasicNewsRecipe(Recipe): body = soup.find('body') if body is not None: prefix = '/'.join('..'for i in range(2*len(re.findall(r'link\d+', last)))) - if self.include_navbars: - templ = self.navbar.generate(True, num, j, len(f), - not self.has_single_feed, - a.orig_url, __appname__, prefix=prefix, - center=self.center_navbar) - elem = BeautifulSoup(templ.render(doctype='xhtml').decode('utf-8')).find('div') - body.insert(len(body.contents), elem) + templ = self.navbar.generate(True, num, j, len(f), + not self.has_single_feed, + a.orig_url, __appname__, prefix=prefix, + center=self.center_navbar) + elem = BeautifulSoup(templ.render(doctype='xhtml').decode('utf-8')).find('div') + body.insert(len(body.contents), elem) with open(last, 'wb') as fi: fi.write(unicode(soup).encode('utf-8')) diff --git a/src/calibre/web/feeds/templates.py b/src/calibre/web/feeds/templates.py index e254b6eded..954677a90e 100644 --- a/src/calibre/web/feeds/templates.py +++ b/src/calibre/web/feeds/templates.py @@ -38,7 +38,7 @@ class NavBarTemplate(Template): -