Include images in the automated PDF

This commit is contained in:
Ed Ward 2019-07-31 14:18:07 +02:00
parent cfb496c7d3
commit 498117584a
3 changed files with 12 additions and 7 deletions

View File

@ -126,3 +126,4 @@ The `build.py` script that builds the manual accepts the following options:
- '-q', or '--quiet', to suppress all output (overrides -v) - '-q', or '--quiet', to suppress all output (overrides -v)
- '-d', or '--devmode', to add content to pages to help developers debug them - '-d', or '--devmode', to add content to pages to help developers debug them
(link, file name, URL) (link, file name, URL)
- '-n', or '--nopdf', to prevent the build script from generate a PDF from the content

View File

@ -454,11 +454,12 @@ temp.close()
onepage = onepage.replace('{{page.bootstrap_path}}', global_bootstrap_path) onepage = onepage.replace('{{page.bootstrap_path}}', global_bootstrap_path)
onepage = onepage.replace('{{page.page_title}}', global_page_title) onepage = onepage.replace('{{page.page_title}}', global_page_title)
# Same as above, but for the PDF version if not nopdf:
temp = open(global_pdf_template) # Same as above, but for the PDF version
pdfpage = temp.read() temp = open(global_pdf_template)
temp.close() pdfpage = temp.read()
pdfpage = pdfpage.replace('{{page.page_title}}', global_page_title) temp.close()
pdfpage = pdfpage.replace('{{page.page_title}}', global_page_title)
# Parse out the master document's structure into a dictionary list # Parse out the master document's structure into a dictionary list
fileStruct = GetFileStructure() fileStruct = GetFileStructure()
@ -614,6 +615,7 @@ for header in fileStruct:
# Set up the actual page from the template # Set up the actual page from the template
onepage = onepage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}') onepage = onepage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}')
if not nopdf:
pdfpage = pdfpage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}') pdfpage = pdfpage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}')
# ----- Normal version ----- # ----- Normal version -----
@ -681,6 +683,8 @@ if not nopdf:
pdfpageFile = open(global_site_dir + 'pdf.html', 'w') pdfpageFile = open(global_site_dir + 'pdf.html', 'w')
pdfpage = pdfpage.replace('{% tree %}', opsidebar) # create the TOC pdfpage = pdfpage.replace('{% tree %}', opsidebar) # create the TOC
pdfpage = pdfpage.replace('{{ content }}', '') # cleans up the last spaceholder pdfpage = pdfpage.replace('{{ content }}', '') # cleans up the last spaceholder
pdfpage = pdfpage.replace('src="/images/', 'src="images/') # makes images links relative
pdfpage = pdfpage.replace('url(\'/images/', 'url(\'images/') # CSS images links relative
pdfpageFile.write(pdfpage) pdfpageFile.write(pdfpage)
pdfpageFile.close() pdfpageFile.close()

View File

@ -27,7 +27,7 @@
<input type="text" class="form-control" placeholder="Search &hellip;" name="q"> <input type="text" class="form-control" placeholder="Search &hellip;" name="q">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button> <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
<button class="btn btn-default" type="button" onclick="window.location.href='/ardourmanual.html'"><span class="glyphicon glyphicon-book" aria-hidden="true"></span></button> <button class="btn btn-default" type="button" onclick="window.location.href='/manual.pdf'"><span class="glyphicon glyphicon-book" aria-hidden="true"></span></button>
</span> </span>
</div> </div>
<input type="hidden" name="sites" value="manual.ardour.org"><!-- domain --> <input type="hidden" name="sites" value="manual.ardour.org"><!-- domain -->