]> Shamusworld >> Repos - ardour-manual/blobdiff - build.py
updated "Key Bindings" to new UI name "Keyboard Shortcuts"
[ardour-manual] / build.py
index 4424f76bea483d2cfa710ec23ce64d99bca40ad8..775e3f800f76b1966d3a43781ecc8eab34f78cc3 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -27,8 +27,8 @@ global_screen_template = 'page-template.html'
 global_onepage_template = 'onepage-template.html'
 global_pdf_template = 'pdf-template.html'
 global_master_doc = 'master-doc.txt'
+global_pdflink = '<button class="btn btn-default" type="button" onclick="window.location.href=\'/manual.pdf\'"><span class="glyphicon glyphicon-book" aria-hidden="true"></span></button>'
 from datetime import datetime
-global_today_iso = datetime.today().strftime('%Y-%m-%dT%H%M%S')
 global_today = datetime.today().strftime('%Y-%m-%d')
 
 # This matches all *non* letter/number, ' ', '.', '-', and '_' chars
@@ -456,6 +456,11 @@ template = temp.read()
 temp.close()
 template = template.replace('{{page.bootstrap_path}}', global_bootstrap_path)
 template = template.replace('{{page.page_title}}', global_page_title)
+if pdf:
+       template = template.replace('{{page.page_pdflink}}', global_pdflink)
+else:
+       template = template.replace('{{page.page_pdflink}}', '')
+
 
 # Same as above, but for the "One-Page" version
 temp = open(global_onepage_template)
@@ -691,12 +696,14 @@ onepageFile.close()
 if pdf:
        if noisy:
                print('Generating the PDF...')
+               import logging
+               logger = logging.getLogger('weasyprint')
+               logger.addHandler(logging.StreamHandler())
 
        # Create the PDF version of the documentation
        pdfpage = pdfpage.replace('{% tree %}', opsidebar) # create the TOC
        pdfpage = pdfpage.replace('{{ content }}', '') # cleans up the last spaceholder
        pdfpage = pdfpage.replace('{{ today }}', global_today)
-       pdfpage = pdfpage.replace('{{ today_iso }}', global_today_iso)
        pdfpage = pdfpage.replace('src="/images/', 'src="images/') # makes images links relative
        pdfpage = pdfpage.replace('url(\'/images/', 'url(\'images/') # CSS images links relative
        # Write it to disk (optional, can be removed)
@@ -707,6 +714,7 @@ if pdf:
        # Generating the actual PDF with weasyprint (https://weasyprint.org/)
        from weasyprint import HTML
        from weasyprint.fonts import FontConfiguration
+       
        html_font_config = FontConfiguration()
        doc = HTML(string = pdfpage, base_url = global_site_dir)
        doc.write_pdf(global_site_dir + 'manual.pdf', font_config = html_font_config)