Build fonts under pelican
This commit is contained in:
parent
1b7f3070fb
commit
51451e0638
3 changed files with 8 additions and 9 deletions
|
@ -3,9 +3,8 @@
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"description": " Source code for TheOrangeOne.net",
|
"description": " Source code for TheOrangeOne.net",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "npm run create-build-dirs && npm run copy-fonts",
|
"postinstall": "npm run create-build-dirs",
|
||||||
"create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img",
|
"create-build-dirs": "mkdir -p theme/static/build/js theme/static/build/fonts theme/static/build/css theme/static/build/img",
|
||||||
"copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/",
|
|
||||||
"start": "tstatic output/"
|
"start": "tstatic output/"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
from pelican import signals
|
from pelican import signals
|
||||||
import os
|
from plugins.utils import node_bin, run_command, NODE_PRODUCTION
|
||||||
from plugins.utils import node_bin, run_command
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__file__)
|
logger = logging.getLogger(__file__)
|
||||||
|
|
||||||
NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production'
|
|
||||||
|
|
||||||
|
|
||||||
def static_build(*args, **kwargs):
|
def static_build(*args, **kwargs):
|
||||||
if NODE_PRODUCTION:
|
if NODE_PRODUCTION:
|
||||||
|
@ -14,7 +11,7 @@ def static_build(*args, **kwargs):
|
||||||
UGLIFY_ARGS = ['--compress', '--screw-ie8', '--define', '--stats', '--keep-fnames']
|
UGLIFY_ARGS = ['--compress', '--screw-ie8', '--define', '--stats', '--keep-fnames']
|
||||||
else:
|
else:
|
||||||
UGLIFY_ARGS = []
|
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 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 jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js'])
|
||||||
run_command('Building Application', [
|
run_command('Building Application', [
|
||||||
|
|
|
@ -6,6 +6,9 @@ import os
|
||||||
logger = logging.getLogger(__file__)
|
logger = logging.getLogger(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production'
|
||||||
|
|
||||||
|
|
||||||
def flatten_list(array):
|
def flatten_list(array):
|
||||||
res = []
|
res = []
|
||||||
for el in array:
|
for el in array:
|
||||||
|
@ -18,7 +21,7 @@ def flatten_list(array):
|
||||||
|
|
||||||
def run_command(detail, args, wrap=False):
|
def run_command(detail, args, wrap=False):
|
||||||
if wrap:
|
if wrap:
|
||||||
run_command('', ['bash', '-c', ' '.join(flatten_list(args))])
|
run_command(detail, ['bash', '-c', ' '.join(flatten_list(args))])
|
||||||
else:
|
else:
|
||||||
logger.info(detail + '...')
|
logger.info(detail + '...')
|
||||||
subprocess.run(flatten_list(args), check=True)
|
subprocess.run(flatten_list(args), check=True)
|
||||||
|
|
Reference in a new issue