Skip to content

Commit

Permalink
Fix for replacing |filename| with static url
Browse files Browse the repository at this point in the history
  • Loading branch information
Kura committed Aug 1, 2013
1 parent 51dc02f commit 77c6c6f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pelican/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,11 @@ def _create_pdf(self, obj, output_path):
if obj.source_path.endswith('.rst'):
filename = obj.slug + ".pdf"
output_pdf = os.path.join(output_path, filename)
# print('Generating pdf for', obj.source_path, 'in', output_pdf)
with open(obj.source_path) as f:
self.pdfcreator.createPdf(text=f.read(), output=output_pdf)
with open(obj.source_path, encoding='utf-8') as f:
pdf_content = f.read()
siteurl = "/".join((self.settings['SITEURL'], 'static', ''))[:-1]

This comment has been minimized.

Copy link
@kylewm

kylewm Aug 3, 2013

'static' is going away in 3.3 (see getpelican#795), it will not be necessary to append it to the URL anymore. Also, is the published URL the right place to link an image in a PDF to? I would have expected rst2pdf to want a local path, no?

pdf_content = pdf_content.replace("|filename|", siteurl)
self.pdfcreator.createPdf(text=pdf_content, output=output_pdf)
logger.info(' [ok] writing %s' % output_pdf)

def generate_context(self):
Expand Down

0 comments on commit 77c6c6f

Please sign in to comment.