Changeset - 19a9f02443c8
[Not reviewed]
default
1 3 1
Mads Kiilerich (mads) - 7 years ago 2018-12-04 12:16:20
mads@kiilerich.com
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.
4 files changed with 12 insertions and 9 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
@@ -8,7 +8,6 @@ syntax: glob
 
*.mo
 
.eggs/
 
tarballcache/
 
node_modules/
 

	
 
syntax: regexp
 
^rcextensions
 
@@ -22,6 +21,8 @@ syntax: regexp
 
^\.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$
MANIFEST.in
Show inline comments
 
@@ -12,12 +12,12 @@ include           development.ini
 
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 *
kallithea/bin/kallithea_cli_front_end.py
Show inline comments
 
@@ -35,22 +35,24 @@ def front_end_build(install_deps, genera
 
    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)
kallithea/front-end/package.json
Show inline comments
 
file renamed from package.json to kallithea/front-end/package.json
0 comments (0 inline, 0 general)