##// END OF EJS Templates
i18n: updated translation for Polish...
i18n: updated translation for Polish Currently translated at 56.5% (614 of 1087 strings)

File last commit:

r7718:0a277465 default
r8092:7fef5132 default
Show More
kallithea_cli_front_end.py
109 lines | 6.3 KiB | text/x-python | PythonLexer
/ kallithea / bin / kallithea_cli_front_end.py
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358 # -*- coding: utf-8 -*-
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 import json
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358 import os
Mads Kiilerich
front-end: Use the existing bootstrap.js from node_modules and stop bundling Bootstrap
r7382 import shutil
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358 import subprocess
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718
import click
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358
import kallithea
Mads Kiilerich
scripts: initial run of import cleanup using isort
r7718 import kallithea.bin.kallithea_cli_base as cli_base
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358
@cli_base.register_command()
@click.option('--install-deps/--no-install-deps', default=True,
help='Skip installation of dependencies, via "npm".')
@click.option('--generate/--no-generate', default=True,
help='Skip generation of front-end files.')
def front_end_build(install_deps, generate):
"""Build the front-end.
Install required dependencies for the front-end and generate the necessary
files. This step is complementary to any 'pip install' step which only
covers Python dependencies.
The installation of front-end dependencies happens via the tool 'npm' which
is expected to be installed already.
"""
Mads Kiilerich
front-end: Introduce 'front-end' directory with source files for building the front-end...
r7379 front_end_dir = os.path.abspath(os.path.join(kallithea.__file__, '..', 'front-end'))
public_dir = os.path.abspath(os.path.join(kallithea.__file__, '..', 'public'))
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358
if install_deps:
click.echo("Running 'npm install' to install front-end dependencies from package.json")
Thomas De Schampheleire
cli: fix 'front-end-build' on Windows (Issue #332)...
r7502 subprocess.check_call(['npm', 'install'], cwd=front_end_dir, shell=kallithea.is_windows)
Thomas De Schampheleire
cli: add command 'kallithea-cli front-end-build'...
r7358
if generate:
Mads Kiilerich
front-end: Store temporary files in a tmp directory...
r7380 tmp_dir = os.path.join(front_end_dir, 'tmp')
if not os.path.isdir(tmp_dir):
os.mkdir(tmp_dir)
Mads Kiilerich
front-end: Use the existing bootstrap.js from node_modules and stop bundling Bootstrap
r7382 click.echo("Building CSS styling based on Bootstrap")
Mads Kiilerich
front-end: Store temporary files in a tmp directory...
r7380 with open(os.path.join(tmp_dir, 'pygments.css'), 'w') as f:
Thomas De Schampheleire
cli: front-end-build: generate pygments.css dynamically...
r7359 subprocess.check_call(['pygmentize',
'-S', 'default',
'-f', 'html',
'-a', '.code-highlight'],
stdout=f)
Mads Kiilerich
front-end: Introduce 'front-end' directory with source files for building the front-end...
r7379 lesscpath = os.path.join(front_end_dir, 'node_modules', '.bin', 'lessc')
Mads Kiilerich
front-end: Move .less files to the front-end folder...
r7392 lesspath = os.path.join(front_end_dir, 'main.less')
Mads Kiilerich
front-end: Introduce 'front-end' directory with source files for building the front-end...
r7379 csspath = os.path.join(public_dir, 'css', 'style.css')
Mads Kiilerich
front-end: Drop lessc --relative-urls...
r7391 subprocess.check_call([lesscpath, '--source-map',
Mads Kiilerich
front-end: Introduce 'front-end' directory with source files for building the front-end...
r7379 '--source-map-less-inline', lesspath, csspath],
Thomas De Schampheleire
cli: fix 'front-end-build' on Windows (Issue #332)...
r7502 cwd=front_end_dir, shell=kallithea.is_windows)
Mads Kiilerich
front-end: use license-checker to generate information about code used to build the front-end
r7381
Mads Kiilerich
front-end: Use the existing bootstrap.js from node_modules and stop bundling Bootstrap
r7382 click.echo("Preparing Bootstrap JS")
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'bootstrap', 'dist', 'js', 'bootstrap.js'), os.path.join(public_dir, 'js', 'bootstrap.js'))
domruf
front-end: use At.js for MentionsAutoComplete...
r7387 click.echo("Preparing jQuery JS with Flot, Caret and Atwho")
Mads Kiilerich
front-end: Use jQuery and Flot from node_modules and stop bundling them...
r7383 shutil.copy(os.path.join(front_end_dir, 'node_modules', 'jquery', 'dist', 'jquery.min.js'), os.path.join(public_dir, 'js', 'jquery.min.js'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'jquery.flot', 'jquery.flot.js'), os.path.join(public_dir, 'js', 'jquery.flot.js'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'jquery.flot', 'jquery.flot.selection.js'), os.path.join(public_dir, 'js', 'jquery.flot.selection.js'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'jquery.flot', 'jquery.flot.time.js'), os.path.join(public_dir, 'js', 'jquery.flot.time.js'))
domruf
front-end: use At.js for MentionsAutoComplete...
r7387 shutil.copy(os.path.join(front_end_dir, 'node_modules', 'jquery.caret', 'dist', 'jquery.caret.min.js'), os.path.join(public_dir, 'js', 'jquery.caret.min.js'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'at.js', 'dist', 'js', 'jquery.atwho.min.js'), os.path.join(public_dir, 'js', 'jquery.atwho.min.js'))
Mads Kiilerich
front-end: Use jQuery and Flot from node_modules and stop bundling them...
r7383
Mads Kiilerich
front-end: Use DataTables from node_modules and stop bundling it...
r7385 click.echo("Preparing DataTables JS")
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'datatables.net', 'js', 'jquery.dataTables.js'), os.path.join(public_dir, 'js', 'jquery.dataTables.js'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'datatables.net-bs', 'js', 'dataTables.bootstrap.js'), os.path.join(public_dir, 'js', 'dataTables.bootstrap.js'))
Mads Kiilerich
front-end: Use select2 from node_modules and stop bundling it...
r7384 click.echo("Preparing Select2 JS")
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'select2', 'select2.js'), os.path.join(public_dir, 'js', 'select2.js'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'select2', 'select2.png'), os.path.join(public_dir, 'css', 'select2.png'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'select2', 'select2x2.png'), os.path.join(public_dir, 'css', 'select2x2.png'))
shutil.copy(os.path.join(front_end_dir, 'node_modules', 'select2', 'select2-spinner.gif'), os.path.join(public_dir, 'css', 'select2-spinner.gif'))
Mads Kiilerich
front-end: Use codemirror from node_modules and stop bundling it
r7386 click.echo("Preparing CodeMirror JS")
if os.path.isdir(os.path.join(public_dir, 'codemirror')):
shutil.rmtree(os.path.join(public_dir, 'codemirror'))
shutil.copytree(os.path.join(front_end_dir, 'node_modules', 'codemirror'), os.path.join(public_dir, 'codemirror'))
Mads Kiilerich
front-end: use license-checker to generate information about code used to build the front-end
r7381 click.echo("Generating LICENSES.txt")
Thomas De Schampheleire
cli: fix 'front-end-build' on Windows (Issue #332)...
r7502 license_checker_path = os.path.join(front_end_dir, 'node_modules', '.bin', 'license-checker')
Mads Kiilerich
front-end: use license-checker to generate information about code used to build the front-end
r7381 check_licensing_json_path = os.path.join(tmp_dir, 'licensing.json')
licensing_txt_path = os.path.join(public_dir, 'LICENSES.txt')
Thomas De Schampheleire
cli: fix 'front-end-build' on Windows (Issue #332)...
r7502 subprocess.check_call([license_checker_path, '--json', '--out', check_licensing_json_path],
cwd=front_end_dir, shell=kallithea.is_windows)
Mads Kiilerich
front-end: use license-checker to generate information about code used to build the front-end
r7381 with open(check_licensing_json_path) as jsonfile:
rows = json.loads(jsonfile.read())
with open(licensing_txt_path, 'w') as out:
out.write("The Kallithea front-end was built using the following Node modules:\n\n")
for name_version, values in sorted(rows.items()):
name, version = name_version.rsplit('@', 1)
line = "%s from https://www.npmjs.com/package/%s/v/%s\n License: %s\n Repository: %s\n" % (
name_version, name, version, values['licenses'], values.get('repository', '-'))
if values.get('copyright'):
line += " Copyright: %s\n" % (values['copyright'])
out.write(line + '\n')