From 1107fe3646591e3a89905167c4765dc871cf89cc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 14:31:08 +0100 Subject: [PATCH 01/21] Try application on CI --- .travis.yml | 18 ++++++++++++++++++ scripts/before_script.sh | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 .travis.yml create mode 100644 scripts/before_script.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ee8a0b6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +sudo: false +language: python +python: "3.6" + +addons: + apt: + packages: + - pandoc + - pandoc-citeproc + +before_install: + - bash scripts/before_script.sh + +install: + - python3 setup.py install + +script: + - cd test-files && mdp -vvv diff --git a/scripts/before_script.sh b/scripts/before_script.sh new file mode 100644 index 0000000..961302b --- /dev/null +++ b/scripts/before_script.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +sudo apt-get install -y openssl build-essential xorg libssl-dev +wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz +tar -xJf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz +cd wkhtmltox +sudo chown root:root bin/wkhtmltopdf +sudo cp -r * /usr/ From 0e963d6f642fff4c3dfc1ca8f6b98550f365ff20 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 14:38:11 +0100 Subject: [PATCH 02/21] Use apt-get instead --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee8a0b6..327015e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,8 @@ sudo: false language: python python: "3.6" -addons: - apt: - packages: - - pandoc - - pandoc-citeproc - before_install: + - sudo apt-get install pandoc pandoc-citeproc - bash scripts/before_script.sh install: From 345f8194164b4c81809a085f738439b3acebb199 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 14:42:43 +0100 Subject: [PATCH 03/21] Require sudo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 327015e..2086c9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: false +sudo: required language: python python: "3.6" From fee06def44082a2d21100a23a6ce0f7262296c87 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 14:50:17 +0100 Subject: [PATCH 04/21] Try on circle --- .travis.yml | 13 ------------- circle.yml | 4 ++++ 2 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2086c9e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -sudo: required -language: python -python: "3.6" - -before_install: - - sudo apt-get install pandoc pandoc-citeproc - - bash scripts/before_script.sh - -install: - - python3 setup.py install - -script: - - cd test-files && mdp -vvv diff --git a/circle.yml b/circle.yml index c0e9715..eb99db8 100644 --- a/circle.yml +++ b/circle.yml @@ -6,6 +6,10 @@ machine: dependencies: + pre: + - sudo apt update && sudo apt install pandoc pandoc-citeproc + - bash scripts/before_script.sh + post: - pip install -r dev-requirements.txt From 13006922d70acea80316497563e3fc3bfd055d6e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 14:54:20 +0100 Subject: [PATCH 05/21] Actually run the application --- circle.yml | 1 + scripts/before_script.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/circle.yml b/circle.yml index eb99db8..be33e7e 100644 --- a/circle.yml +++ b/circle.yml @@ -19,3 +19,4 @@ test: - flake8 md_pdf/ --ignore=E128,E501 - safety check - bandit -r md_pdf/ + - cd test-files && mdp -vvv diff --git a/scripts/before_script.sh b/scripts/before_script.sh index 961302b..6c08cfa 100644 --- a/scripts/before_script.sh +++ b/scripts/before_script.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e + sudo apt-get install -y openssl build-essential xorg libssl-dev wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz tar -xJf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz From 48108295d854f04c09dd799007fda6cb892e23df Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 14:58:04 +0100 Subject: [PATCH 06/21] Actually install project globally --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index be33e7e..57d1486 100644 --- a/circle.yml +++ b/circle.yml @@ -12,6 +12,7 @@ dependencies: post: - pip install -r dev-requirements.txt + - pip install -e . test: From 2d16066cb29405589aa96bcbc512a1654f43e267 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 15:01:51 +0100 Subject: [PATCH 07/21] if in doubt, sudo --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 57d1486..9eece2e 100644 --- a/circle.yml +++ b/circle.yml @@ -12,7 +12,7 @@ dependencies: post: - pip install -r dev-requirements.txt - - pip install -e . + - sudo pip install -e . test: From 1dd401ad63096cc9d48dd17efdd1717ccbf568a8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 15:14:55 +0100 Subject: [PATCH 08/21] install python dev stuff --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 9eece2e..816a7b2 100644 --- a/circle.yml +++ b/circle.yml @@ -7,7 +7,7 @@ machine: dependencies: pre: - - sudo apt update && sudo apt install pandoc pandoc-citeproc + - sudo apt update && sudo apt install pandoc pandoc-citeproc python-dev python3 - bash scripts/before_script.sh post: From e0b12530a4092b06b68337abc064da7c37d2a5c0 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Apr 2017 15:17:53 +0100 Subject: [PATCH 09/21] Actually i meant dev --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 816a7b2..a6da124 100644 --- a/circle.yml +++ b/circle.yml @@ -7,7 +7,7 @@ machine: dependencies: pre: - - sudo apt update && sudo apt install pandoc pandoc-citeproc python-dev python3 + - sudo apt update && sudo apt install pandoc pandoc-citeproc python-dev python3-dev - bash scripts/before_script.sh post: From b273b893c079a6435357fee63afa2774b41fbb13 Mon Sep 17 00:00:00 2001 From: James Seden Smith Date: Thu, 27 Apr 2017 12:06:53 +0100 Subject: [PATCH 10/21] Fixed download_csl to work on windows --- md_pdf/csl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/md_pdf/csl.py b/md_pdf/csl.py index bd8f08e..7a18123 100644 --- a/md_pdf/csl.py +++ b/md_pdf/csl.py @@ -24,7 +24,6 @@ def download_csl(): bar = ProgressBar() remove_dir(CSL_DIR) - remove_dir(CSL_DOWNLOAD_LINK) def download_handle(count, block_size, total_size): bar.update(int(count * block_size * 100 / total_size)) @@ -47,6 +46,7 @@ def download_csl(): bar.finish() + os.close(_) logger.info("Cleaning Up...") shutil.copytree(CSL_TEMP_DIR, CSL_DIR) os.remove(download_location) From 477dd5e693f869c0d11f205186ffd68b844baac8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 13:18:32 +0100 Subject: [PATCH 11/21] Specify packages --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a357cdc..a350150 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, find_packages setup( @@ -13,6 +13,7 @@ setup( "pyscss==1.3.5", "PyYAML==3.12" ], + packages=find_packages(), entry_points=""" [console_scripts] mdp=md_pdf.cli:cli From 4e80c75085dfe0e0c982170d96a811775959503a Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 13:27:37 +0100 Subject: [PATCH 12/21] Give config an init.py --- md_pdf/config/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 md_pdf/config/__init__.py diff --git a/md_pdf/config/__init__.py b/md_pdf/config/__init__.py new file mode 100644 index 0000000..e69de29 From 3e4e47c0b1bd9d15e433865738ebabdbce3ed05e Mon Sep 17 00:00:00 2001 From: James Seden Smith Date: Thu, 27 Apr 2017 13:39:59 +0100 Subject: [PATCH 13/21] Moved line into correct section --- md_pdf/csl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/md_pdf/csl.py b/md_pdf/csl.py index 7a18123..3bf07c6 100644 --- a/md_pdf/csl.py +++ b/md_pdf/csl.py @@ -46,8 +46,8 @@ def download_csl(): bar.finish() - os.close(_) logger.info("Cleaning Up...") + os.close(_) shutil.copytree(CSL_TEMP_DIR, CSL_DIR) os.remove(download_location) remove_dir(CSL_TEMP_DIR) From 994c6175099a9591e9293be4fbb9a7ef7bad33c2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 19:15:24 +0100 Subject: [PATCH 14/21] include package data --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index a350150..ec9d32c 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ setup( "PyYAML==3.12" ], packages=find_packages(), + include_package_data=True, entry_points=""" [console_scripts] mdp=md_pdf.cli:cli From 844ba479f061c28e5cc777062c47271c2bd220b8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 19:16:20 +0100 Subject: [PATCH 15/21] Test the program is executable on install --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index c0e9715..64638e0 100644 --- a/circle.yml +++ b/circle.yml @@ -15,3 +15,4 @@ test: - flake8 md_pdf/ --ignore=E128,E501 - safety check - bandit -r md_pdf/ + - mdp --help From 7b44ec5718588fc522a33ea41b1d2444956ad33e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 19:30:05 +0100 Subject: [PATCH 16/21] No need for second install --- circle.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 9a12d11..ee32115 100644 --- a/circle.yml +++ b/circle.yml @@ -7,12 +7,11 @@ machine: dependencies: pre: - - sudo apt update && sudo apt install pandoc pandoc-citeproc python-dev python3-dev + - sudo apt update && sudo apt install pandoc pandoc-citeproc - bash scripts/before_script.sh post: - pip install -r dev-requirements.txt - - sudo pip install -e . test: From be58629611ab0cb8bc6247fa93575500e6f13928 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 19:30:20 +0100 Subject: [PATCH 17/21] dont waste time updating --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index ee32115..f321653 100644 --- a/circle.yml +++ b/circle.yml @@ -7,7 +7,7 @@ machine: dependencies: pre: - - sudo apt update && sudo apt install pandoc pandoc-citeproc + - sudo apt install pandoc pandoc-citeproc - bash scripts/before_script.sh post: From c6b387be686f2621e01612da4da0dae68ca7b73b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 27 Apr 2017 19:36:46 +0100 Subject: [PATCH 18/21] Add helper script source --- scripts/before_script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/before_script.sh b/scripts/before_script.sh index 6c08cfa..1d1adaa 100644 --- a/scripts/before_script.sh +++ b/scripts/before_script.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# 'stolen' from https://github.com/JazzCore/python-pdfkit/blob/master/travis/before-script.sh + set -e sudo apt-get install -y openssl build-essential xorg libssl-dev From 4975b4938092c339697297230a7e930ff8590a37 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 13:30:38 +0100 Subject: [PATCH 19/21] Specify css location correctly --- md_pdf/build/pdf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/md_pdf/build/pdf.py b/md_pdf/build/pdf.py index 334af73..39c550d 100644 --- a/md_pdf/build/pdf.py +++ b/md_pdf/build/pdf.py @@ -23,6 +23,8 @@ PDF_OPTIONS = { "footer-html": FOOTER_FILE, "footer-spacing": 5, "header-spacing": 5, + + "user-style-sheet": STYLE_FILE } @@ -34,6 +36,5 @@ def export_pdf(content, config): content, os.path.join(os.path.abspath(config['output_dir']), 'output.pdf'), options=PDF_OPTIONS, - css=STYLE_FILE, cover=OUTPUT_COVER_FILE ) From d56d8a2f1eb7751af456acaa9420c46a9abca896 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 14:10:11 +0100 Subject: [PATCH 20/21] Fix script location and run handle --- md_pdf/assets/static/context.js | 3 ++- md_pdf/assets/templates/cover-template.html | 2 +- md_pdf/assets/templates/footer.html | 6 +++--- md_pdf/assets/templates/header.html | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/md_pdf/assets/static/context.js b/md_pdf/assets/static/context.js index 90adc1b..8675777 100644 --- a/md_pdf/assets/static/context.js +++ b/md_pdf/assets/static/context.js @@ -21,4 +21,5 @@ function subst() { } } -window.subst = subst(); + +subst(); diff --git a/md_pdf/assets/templates/cover-template.html b/md_pdf/assets/templates/cover-template.html index 8675240..53f95a4 100644 --- a/md_pdf/assets/templates/cover-template.html +++ b/md_pdf/assets/templates/cover-template.html @@ -1,7 +1,7 @@ - +

{{ title }}

diff --git a/md_pdf/assets/templates/footer.html b/md_pdf/assets/templates/footer.html index 8765260..9b988e4 100644 --- a/md_pdf/assets/templates/footer.html +++ b/md_pdf/assets/templates/footer.html @@ -1,10 +1,9 @@ - - + - +
@@ -12,5 +11,6 @@
+ diff --git a/md_pdf/assets/templates/header.html b/md_pdf/assets/templates/header.html index e8b7db6..91e760b 100644 --- a/md_pdf/assets/templates/header.html +++ b/md_pdf/assets/templates/header.html @@ -1,9 +1,9 @@ - - + - + + From a07e57137cab7db762fd2573c094323193d85cdb Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 3 May 2017 14:13:14 +0100 Subject: [PATCH 21/21] Fix scss linting --- .sass-lint.yml | 60 +++++++++++++++++++++++++++++++++ md_pdf/assets/static/style.scss | 3 +- package.json | 2 +- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .sass-lint.yml diff --git a/.sass-lint.yml b/.sass-lint.yml new file mode 100644 index 0000000..45bbe42 --- /dev/null +++ b/.sass-lint.yml @@ -0,0 +1,60 @@ +rules: + clean-import-paths: 0 + extends-before-mixins: 2 + extends-before-declarations: 2 + force-attribute-nesting: 0 + no-css-comments: 0 + no-debug: 1 + no-duplicate-properties: + - 2 + - + exclude: + - src + - transform + no-ids: 0 + no-important: 0 + no-transition-all: 0 + no-vendor-prefixes: 2 + no-qualifying-elements: 0 + no-url-protocols: 0 + no-warn: 1 + hex-notation: + - 2 + - + style: uppercase + indentation: + - 2 + - + size: 2 + variable-name-format: + - 2 + - + allow-leading-underscore: false + convention: hyphenatedlowercase + quotes: + - 2 + - + style: double + property-sort-order: + - 2 + - + order: 'concentric' + empty-line-between-blocks: 2 + space-after-bang: 2 + space-after-colon: 2 + space-after-comma: 2 + space-before-bang: 2 + space-before-brace: 2 + space-before-colon: 2 + space-between-parens: 2 + trailing-semicolon: 2 + leading-zero: 0 + single-line-per-selector: 0 + force-pseudo-nesting: 0 + force-element-nesting: 0 + placeholder-in-extend: 0 + no-url-domains: 0 + nesting-depth: + - 2 + - + max-depth: 5 diff --git a/md_pdf/assets/static/style.scss b/md_pdf/assets/static/style.scss index 5025637..1212730 100644 --- a/md_pdf/assets/static/style.scss +++ b/md_pdf/assets/static/style.scss @@ -3,8 +3,7 @@ body.cover { text-align: center; & h1 { - font-size: 48px; padding-top: 400px; - + font-size: 48px; } } diff --git a/package.json b/package.json index 33e2150..3062185 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "", "scripts": { "test": "npm run lint-scss && npm run lint-js", - "lint-scss": "sass-lint -vq md_pdf/assets/static/**/*.scss", + "lint-scss": "sass-lint -vqc .sass-lint.yml md_pdf/assets/static/**/*.scss", "lint-js": "eslint -c eslint-config-dabapps/base/.eslintrc md_pdf/assets/static/**/*.js" }, "repository": {