Move logic for removing inline navbars out of the BasicNewsRecipe class

This commit is contained in:
Kovid Goyal 2010-02-23 10:12:10 -07:00
parent 78c4467960
commit 1a4caa3801
3 changed files with 15 additions and 12 deletions

View File

@ -101,5 +101,10 @@ class RecipeInput(InputFormatPlugin):
return os.path.abspath(f) return os.path.abspath(f)
def postprocess_book(self, oeb, opts, log): 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) self.recipe_object.postprocess_book(oeb, opts, log)

View File

@ -266,7 +266,7 @@ class BasicNewsRecipe(Recipe):
font-weight: bold; font-weight: bold;
} }
.navbar { .calibre_navbar {
font-family:monospace; font-family:monospace;
} }
''' '''
@ -525,7 +525,6 @@ class BasicNewsRecipe(Recipe):
self.username = options.username self.username = options.username
self.password = options.password self.password = options.password
self.lrf = options.lrf self.lrf = options.lrf
self.include_navbars = not options.no_inline_navbars
self.output_dir = os.path.abspath(self.output_dir) self.output_dir = os.path.abspath(self.output_dir)
if options.test: if options.test:
@ -597,7 +596,7 @@ class BasicNewsRecipe(Recipe):
if first_fetch and job_info: if first_fetch and job_info:
url, f, a, feed_len = job_info url, f, a, feed_len = job_info
body = soup.find('body') 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, templ = self.navbar.generate(False, f, a, feed_len,
not self.has_single_feed, not self.has_single_feed,
url, __appname__, url, __appname__,
@ -1149,7 +1148,6 @@ class BasicNewsRecipe(Recipe):
body = soup.find('body') body = soup.find('body')
if body is not None: if body is not None:
prefix = '/'.join('..'for i in range(2*len(re.findall(r'link\d+', last)))) 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), templ = self.navbar.generate(True, num, j, len(f),
not self.has_single_feed, not self.has_single_feed,
a.orig_url, __appname__, prefix=prefix, a.orig_url, __appname__, prefix=prefix,

View File

@ -38,7 +38,7 @@ class NavBarTemplate(Template):
</style> </style>
</head> </head>
<body> <body>
<div class="navbar calibre_rescale_70" style="text-align:${'center' if center else 'left'};"> <div class="calibre_navbar calibre_rescale_70" style="text-align:${'center' if center else 'left'};">
<hr py:if="bottom" /> <hr py:if="bottom" />
<p py:if="bottom" style="text-align:left"> <p py:if="bottom" style="text-align:left">
This article was downloaded by <b>${__appname__}</b> from <a href="${url}">${url}</a> This article was downloaded by <b>${__appname__}</b> from <a href="${url}">${url}</a>
@ -167,7 +167,7 @@ class FeedTemplate(Template):
</li> </li>
</py:for> </py:for>
</ul> </ul>
<div class="navbar calibre_rescale_70"> <div class="calibre_navbar calibre_rescale_70">
| <a href="../index.html">Up one level</a> | | <a href="../index.html">Up one level</a> |
</div> </div>
</div> </div>