From 80fe9dcb66c84f3020e9106228818a57b5ecd33b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 15:21:01 +0100 Subject: [PATCH 01/13] ry CSL update on CI --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index f321653..8b27df0 100644 --- a/circle.yml +++ b/circle.yml @@ -19,4 +19,4 @@ test: - flake8 md_pdf/ --ignore=E128,E501 - safety check - bandit -r md_pdf/ - - mdp --help + - mdp --update-csl From 8ce686150c5e50aa0b6ea65ef980fd8e26bb108b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 15:26:15 +0100 Subject: [PATCH 02/13] try running it instead --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 8b27df0..8a4afba 100644 --- a/circle.yml +++ b/circle.yml @@ -19,4 +19,4 @@ test: - flake8 md_pdf/ --ignore=E128,E501 - safety check - bandit -r md_pdf/ - - mdp --update-csl + - cd test-files/ && mdp -vvv From 4317b5f7184ccc464a1e288bcd027e117216c27e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 15:32:05 +0100 Subject: [PATCH 03/13] Add artifacts --- circle.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/circle.yml b/circle.yml index 8a4afba..3bcfb2b 100644 --- a/circle.yml +++ b/circle.yml @@ -4,6 +4,9 @@ machine: node: version: 6.10.2 +general: + artifacts: + - test-files/out/ dependencies: pre: From db3c98961c94ae6d8737869b2327d0a539f1bd3b Mon Sep 17 00:00:00 2001 From: James Seden Smith Date: Wed, 3 May 2017 15:33:42 +0100 Subject: [PATCH 04/13] Changed default styling to match university guidelines --- md_pdf/assets/static/style.scss | 10 ++++++++++ md_pdf/build/pdf.py | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/md_pdf/assets/static/style.scss b/md_pdf/assets/static/style.scss index 1212730..458b7d6 100644 --- a/md_pdf/assets/static/style.scss +++ b/md_pdf/assets/static/style.scss @@ -6,4 +6,14 @@ body.cover { padding-top: 400px; font-size: 48px; } + & h3 { + font-size: 36px; + } + & h4 { + font-size: 18px; + } +} +body, html { + font-size: 12px; + line-height: 1.5; } diff --git a/md_pdf/build/pdf.py b/md_pdf/build/pdf.py index 39c550d..60c6b4b 100644 --- a/md_pdf/build/pdf.py +++ b/md_pdf/build/pdf.py @@ -7,6 +7,9 @@ import logging logger = logging.getLogger(__file__) +DEFAULT_MARGIN_VERTICAL = '1.5cm' +DEFAULT_MARGIN_HORIZONTAL = '2.5cm' + STYLE_FILE = os.path.join(STATIC_DIR, 'style.css') HEADER_FILE = os.path.join(TEMPLATES_DIR, 'header.html') FOOTER_FILE = os.path.join(TEMPLATES_DIR, 'footer.html') @@ -14,11 +17,6 @@ PDF_OPTIONS = { "quiet": "", "no-pdf-compression": "", - "margin-top": '0.6in', - "margin-bottom": '0.6in', - "margin-left": '0.4in', - "margin-right": '0.4in', - "header-html": HEADER_FILE, "footer-html": FOOTER_FILE, "footer-spacing": 5, @@ -31,6 +29,12 @@ PDF_OPTIONS = { def export_pdf(content, config): PDF_OPTIONS['title'] = config.get('title', 'Output') PDF_OPTIONS['replace'] = [(key, str(value)) for key, value in config['context'].items()] + + PDF_OPTIONS['margin-top'] = config['context'].get('margin_vertical', DEFAULT_MARGIN_VERTICAL) + PDF_OPTIONS['margin-bottom'] = config['context'].get('margin_vertical', DEFAULT_MARGIN_VERTICAL) + PDF_OPTIONS['margin-left'] = config['context'].get('margin_horizontal', DEFAULT_MARGIN_HORIZONTAL) + PDF_OPTIONS['margin-right'] = config['context'].get('margin_horizontal', DEFAULT_MARGIN_HORIZONTAL) + logger.info("Rendering PDF...") return pdfkit.from_string( content, From 40abcb238c7e282e873a73cafb4e69c9a128e165 Mon Sep 17 00:00:00 2001 From: James Seden Smith Date: Wed, 3 May 2017 16:46:53 +0100 Subject: [PATCH 05/13] Fixed style sheet for linter --- md_pdf/assets/static/style.scss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/md_pdf/assets/static/style.scss b/md_pdf/assets/static/style.scss index 458b7d6..d158fa2 100644 --- a/md_pdf/assets/static/style.scss +++ b/md_pdf/assets/static/style.scss @@ -6,14 +6,17 @@ body.cover { padding-top: 400px; font-size: 48px; } + & h3 { font-size: 36px; } + & h4 { font-size: 18px; } } + body, html { - font-size: 12px; line-height: 1.5; + font-size: 12px; } From b8e515089f6d2202af10c53eefb819bacbc550da Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 17:06:35 +0100 Subject: [PATCH 06/13] Remove silent exit --- md_pdf/cli.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/md_pdf/cli.py b/md_pdf/cli.py index d7c7965..ccc136c 100644 --- a/md_pdf/cli.py +++ b/md_pdf/cli.py @@ -19,8 +19,6 @@ def cli(): config = load_config() validate_config(config) build(config) - except PrematureExit: - return 0 except BaseException as e: logging.error(str(e)) return 1 From 44bf3c962fda85d27130d6f76261394942b41e8f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 20:53:39 +0100 Subject: [PATCH 07/13] Try update csl --- circle.yml | 1 + md_pdf/csl.py | 1 + 2 files changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index 3bcfb2b..9ee76d2 100644 --- a/circle.yml +++ b/circle.yml @@ -22,4 +22,5 @@ test: - flake8 md_pdf/ --ignore=E128,E501 - safety check - bandit -r md_pdf/ + - mdp --update-csl - cd test-files/ && mdp -vvv diff --git a/md_pdf/csl.py b/md_pdf/csl.py index 3bf07c6..42ab5e5 100644 --- a/md_pdf/csl.py +++ b/md_pdf/csl.py @@ -26,6 +26,7 @@ def download_csl(): remove_dir(CSL_DIR) def download_handle(count, block_size, total_size): + print(count, block_size, total_size, int(count * block_size * 100 / total_size)) bar.update(int(count * block_size * 100 / total_size)) _, download_location = tempfile.mkstemp() From 9108301772261baa9b4fadb9af212817ce10bea2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 21:10:18 +0100 Subject: [PATCH 08/13] Create output dir if needed --- md_pdf/cli.py | 2 +- md_pdf/config/validate.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/md_pdf/cli.py b/md_pdf/cli.py index ccc136c..4b7dec6 100644 --- a/md_pdf/cli.py +++ b/md_pdf/cli.py @@ -1,6 +1,6 @@ import logging from md_pdf.args import parse_args -from md_pdf.exceptions import PrematureExit, BaseException +from md_pdf.exceptions import BaseException from md_pdf.logging import set_verbosity from md_pdf.build import build from md_pdf.config.read import load_config diff --git a/md_pdf/config/validate.py b/md_pdf/config/validate.py index 3a66882..a9d5623 100644 --- a/md_pdf/config/validate.py +++ b/md_pdf/config/validate.py @@ -24,7 +24,8 @@ def check_required_keys(config): def test_output(config): abs_output_dir = os.path.abspath(config['output_dir']) if not os.path.isdir(abs_output_dir): - raise ConfigValidationException("Can't find output directory '{}'".format(abs_output_dir)) + logger.debug("Creating output directory...") + os.mkdir(abs_output_dir) invalid_formats = [key for key in config['output_formats'] if key not in ['html', 'pdf']] if invalid_formats: raise ConfigValidationException("Invalid output formats provided: '{}'".format(", ".join(invalid_formats))) From 88ad1fd6a5a397605d76bb7f8c056144201434dc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 May 2017 08:39:38 +0100 Subject: [PATCH 09/13] Dont update the bar without size --- md_pdf/csl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/md_pdf/csl.py b/md_pdf/csl.py index 42ab5e5..1d45830 100644 --- a/md_pdf/csl.py +++ b/md_pdf/csl.py @@ -26,7 +26,8 @@ def download_csl(): remove_dir(CSL_DIR) def download_handle(count, block_size, total_size): - print(count, block_size, total_size, int(count * block_size * 100 / total_size)) + if total_size < 1: # only update the bar if we have a size + return bar.update(int(count * block_size * 100 / total_size)) _, download_location = tempfile.mkstemp() From 98d15ef0e6485e28fe2361577221bc0300da59f2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 May 2017 08:54:20 +0100 Subject: [PATCH 10/13] Add manifest --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..5aa6a42 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include md_pdf * From daf8a9ab3930c3f285f6c03fb9a886c73aaf4d0e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 May 2017 09:10:25 +0100 Subject: [PATCH 11/13] Specify package data --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index ec9d32c..4f224e9 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,10 @@ setup( ], packages=find_packages(), include_package_data=True, + zip_safe=False, + package_data={ + '': ['*.js', '*.css', '*.html'] + }, entry_points=""" [console_scripts] mdp=md_pdf.cli:cli From 4827a43faf762a0f7e9c0de80bded1fd04b50b91 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 May 2017 09:26:56 +0100 Subject: [PATCH 12/13] Use scm at setup --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 4f224e9..a099a3a 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ from setuptools import setup, find_packages setup( name="md-pdf", version="1.0", + use_scm_version=True, install_requires=[ "beautifulsoup4==4.5.3", "jinja2==2.9.5", @@ -13,12 +14,10 @@ setup( "pyscss==1.3.5", "PyYAML==3.12" ], + setup_requires=['setuptools_scm'], packages=find_packages(), include_package_data=True, zip_safe=False, - package_data={ - '': ['*.js', '*.css', '*.html'] - }, entry_points=""" [console_scripts] mdp=md_pdf.cli:cli From 1cdf2b09197a5965c50543093593f9ab2d06d358 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 May 2017 09:31:05 +0100 Subject: [PATCH 13/13] Try removing manifest --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 5aa6a42..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -recursive-include md_pdf *