From 51451e06384b254f1d78498899fdcb03615d1311 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 Jan 2017 19:38:29 +0000 Subject: [PATCH] Build fonts under pelican --- package.json | 5 ++--- plugins/static_build.py | 7 ++----- plugins/utils.py | 5 ++++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 15e3a17..a81c7ca 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,8 @@ "version": "4.0.0", "description": " Source code for TheOrangeOne.net", "scripts": { - "postinstall": "npm run create-build-dirs && npm run copy-fonts", - "create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img", - "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/", + "postinstall": "npm run create-build-dirs", + "create-build-dirs": "mkdir -p theme/static/build/js theme/static/build/fonts theme/static/build/css theme/static/build/img", "start": "tstatic output/" }, "repository": { diff --git a/plugins/static_build.py b/plugins/static_build.py index 8606595..378dbb5 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -1,12 +1,9 @@ from pelican import signals -import os -from plugins.utils import node_bin, run_command +from plugins.utils import node_bin, run_command, NODE_PRODUCTION import logging logger = logging.getLogger(__file__) -NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production' - def static_build(*args, **kwargs): if NODE_PRODUCTION: @@ -14,7 +11,7 @@ def static_build(*args, **kwargs): UGLIFY_ARGS = ['--compress', '--screw-ie8', '--define', '--stats', '--keep-fnames'] else: UGLIFY_ARGS = [] - + run_command('Copying Fonts', ['cp', '-r', 'node_modules/font-awesome/fonts', 'theme/static/build/']) run_command('Building Bootstrap', [node_bin('uglifyjs'), 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/bootstrap.js']) run_command('Building jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js']) run_command('Building Application', [ diff --git a/plugins/utils.py b/plugins/utils.py index 01fc3fe..5817b1f 100644 --- a/plugins/utils.py +++ b/plugins/utils.py @@ -6,6 +6,9 @@ import os logger = logging.getLogger(__file__) +NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production' + + def flatten_list(array): res = [] for el in array: @@ -18,7 +21,7 @@ def flatten_list(array): def run_command(detail, args, wrap=False): if wrap: - run_command('', ['bash', '-c', ' '.join(flatten_list(args))]) + run_command(detail, ['bash', '-c', ' '.join(flatten_list(args))]) else: logger.info(detail + '...') subprocess.run(flatten_list(args), check=True)