Mercurial > kallithea
changeset 7459:19a9f02443c8
front-end: Introduce 'front-end' directory with source files for building the front-end
The top level with package.json is not included when installing with pip, and
'kallithea-cli front-end-build' and npm would thus fail.
Instead, introduce 'kallithea/front-end/'. It is under 'kallithea/' and is thus
included when doing pip install, but it is just a source directory and not
under "public". Most of the "less" stuff should probably move there. And
probably also most things that now are checked in under "public", so a fully
populated public front-end directory can be built anywhere, without write
access to the Python installation directory.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 04 Dec 2018 12:16:20 +0100 |
parents | b70ad5c7e706 |
children | 7ec976c8c198 |
files | .hgignore MANIFEST.in kallithea/bin/kallithea_cli_front_end.py kallithea/front-end/package.json package.json |
diffstat | 5 files changed, 23 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Dec 23 21:16:07 2018 +0100 +++ b/.hgignore Tue Dec 04 12:16:20 2018 +0100 @@ -8,7 +8,6 @@ *.mo .eggs/ tarballcache/ -node_modules/ syntax: regexp ^rcextensions @@ -22,6 +21,8 @@ ^\.project$ ^\.pydevproject$ ^\.coverage$ +^kallithea/front-end/node_modules$ +^kallithea/front-end/package-lock\.json$ ^kallithea/public/css/style\.css(\.map)?$ ^kallithea/public/css/pygments.css$ ^theme\.less$
--- a/MANIFEST.in Sun Dec 23 21:16:07 2018 +0100 +++ b/MANIFEST.in Tue Dec 04 12:16:20 2018 +0100 @@ -12,12 +12,12 @@ include pytest.ini include requirements.txt include tox.ini -include package.json recursive-include docs * recursive-include init.d * recursive-include kallithea/alembic * include kallithea/bin/ldap_sync.conf include kallithea/lib/paster_commands/template.ini.mako +recursive-include kallithea/front-end * recursive-include kallithea/i18n * recursive-include kallithea/public * recursive-include kallithea/templates *
--- a/kallithea/bin/kallithea_cli_front_end.py Sun Dec 23 21:16:07 2018 +0100 +++ b/kallithea/bin/kallithea_cli_front_end.py Tue Dec 04 12:16:20 2018 +0100 @@ -35,22 +35,24 @@ The installation of front-end dependencies happens via the tool 'npm' which is expected to be installed already. """ - rootdir = os.path.dirname(os.path.dirname(os.path.abspath(kallithea.__file__))) + front_end_dir = os.path.abspath(os.path.join(kallithea.__file__, '..', 'front-end')) + public_dir = os.path.abspath(os.path.join(kallithea.__file__, '..', 'public')) if install_deps: click.echo("Running 'npm install' to install front-end dependencies from package.json") - subprocess.check_call(['npm', 'install'], cwd=rootdir) + subprocess.check_call(['npm', 'install'], cwd=front_end_dir) if generate: click.echo("Generating CSS") - with open(os.path.join(rootdir, 'kallithea', 'public', 'css', 'pygments.css'), 'w') as f: + with open(os.path.join(public_dir, 'pygments.css'), 'w') as f: subprocess.check_call(['pygmentize', '-S', 'default', '-f', 'html', '-a', '.code-highlight'], stdout=f) - lesscpath = os.path.join(rootdir, 'node_modules', '.bin', 'lessc') - lesspath = os.path.join(rootdir, 'kallithea', 'public', 'less', 'main.less') - csspath = os.path.join(rootdir, 'kallithea', 'public', 'css', 'style.css') + lesscpath = os.path.join(front_end_dir, 'node_modules', '.bin', 'lessc') + lesspath = os.path.join(public_dir, 'less', 'main.less') + csspath = os.path.join(public_dir, 'css', 'style.css') subprocess.check_call([lesscpath, '--relative-urls', '--source-map', - '--source-map-less-inline', lesspath, csspath]) + '--source-map-less-inline', lesspath, csspath], + cwd=front_end_dir)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kallithea/front-end/package.json Tue Dec 04 12:16:20 2018 +0100 @@ -0,0 +1,11 @@ +{ + "name": "kallithea", + "private": true, + "dependencies": { + "bootstrap": "3.3.7" + }, + "devDependencies": { + "less": "~2.7", + "less-plugin-clean-css": "~1.5" + } +}