1
Fork 0

Build fonts under pelican

This commit is contained in:
Jake Howard 2017-01-13 19:38:29 +00:00
parent 1b7f3070fb
commit 51451e0638
3 changed files with 8 additions and 9 deletions

View File

@ -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": {

View File

@ -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', [

View File

@ -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)