Beispiel #1
0
def load_config(nbapp):
    """Load the JupyterLab configuration and defaults for a given application.
    """
    from jupyterlab_server import LabConfig
    from .commands import (get_app_dir, get_app_info, get_workspaces_dir,
                           get_user_settings_dir, pjoin)

    app_dir = getattr(nbapp, 'app_dir', get_app_dir())
    info = get_app_info(app_dir)
    public_url = info['publicUrl']
    user_settings_dir = getattr(nbapp, 'user_settings_dir',
                                get_user_settings_dir())
    workspaces_dir = getattr(nbapp, 'workspaces_dir', get_workspaces_dir())

    config = LabConfig()
    config.app_dir = app_dir
    config.app_name = 'JupyterLab'
    config.app_namespace = 'jupyterlab'
    config.app_settings_dir = pjoin(app_dir, 'settings')
    config.app_version = info['version']
    config.cache_files = True
    config.schemas_dir = pjoin(app_dir, 'schemas')
    config.templates_dir = pjoin(app_dir, 'static')
    config.themes_dir = pjoin(app_dir, 'themes')
    config.user_settings_dir = user_settings_dir
    config.workspaces_dir = workspaces_dir

    if public_url:
        config.public_url = public_url
    else:
        config.static_dir = pjoin(app_dir, 'static')

    return config
Beispiel #2
0
def load_config(nbapp):
    """Load the JupyterLab configuration and defaults for a given application.
    """
    from jupyterlab_server import LabConfig
    from .commands import (
        get_app_dir,
        get_app_info,
        get_workspaces_dir,
        get_user_settings_dir,
        pjoin,
        AppOptions,
    )

    app_dir = getattr(nbapp, 'app_dir', get_app_dir())
    info = get_app_info(app_options=AppOptions(app_dir=app_dir))
    static_url = info['staticUrl']
    user_settings_dir = getattr(
        nbapp, 'user_settings_dir', get_user_settings_dir()
    )
    workspaces_dir = getattr(nbapp, 'workspaces_dir', get_workspaces_dir())

    config = LabConfig()
    config.app_dir = app_dir
    config.app_name = 'JupyterLab'
    config.app_namespace = 'jupyterlab'
    config.app_settings_dir = pjoin(app_dir, 'settings')
    config.app_version = info['version']
    config.cache_files = True
    config.schemas_dir = pjoin(app_dir, 'schemas')
    config.listings_dir = pjoin(app_dir, 'listings')
    config.templates_dir = pjoin(app_dir, 'static')
    config.themes_dir = pjoin(app_dir, 'themes')
    config.user_settings_dir = user_settings_dir
    config.workspaces_dir = workspaces_dir

    if getattr(nbapp, 'override_static_url', ''):
        static_url = nbapp.override_static_url
    if getattr(nbapp, 'override_theme_url', ''):
        config.themes_url = nbapp.override_theme_url
        config.themes_dir = ''

    if static_url:
        config.static_url = static_url
    else:
        config.static_dir = pjoin(app_dir, 'static')

    return config
Beispiel #3
0
def load_config(nbapp):
    """Load the JupyterLab configuration and defaults for a given application.
    """
    from jupyterlab_server import LabConfig
    from .commands import (
        get_app_dir,
        get_app_info,
        get_workspaces_dir,
        get_user_settings_dir,
        pjoin
    )

    app_dir = getattr(nbapp, 'app_dir', get_app_dir())
    info = get_app_info(app_dir)
    public_url = info['publicUrl']
    user_settings_dir = getattr(
        nbapp, 'user_settings_dir', get_user_settings_dir()
    )
    workspaces_dir = getattr(nbapp, 'workspaces_dir', get_workspaces_dir())

    config = LabConfig()
    config.app_dir = app_dir
    config.app_name = 'JupyterLab'
    config.app_namespace = 'jupyterlab'
    config.app_settings_dir = pjoin(app_dir, 'settings')
    config.app_version = info['version']
    config.cache_files = True
    config.schemas_dir = pjoin(app_dir, 'schemas')
    config.templates_dir = pjoin(app_dir, 'static')
    config.themes_dir = pjoin(app_dir, 'themes')
    config.user_settings_dir = user_settings_dir
    config.workspaces_dir = workspaces_dir

    if getattr(nbapp, 'override_static_url', ''):
        public_url = nbapp.override_static_url
    if getattr(nbapp, 'override_theme_url', ''):
        config.themes_url = nbapp.override_theme_url
        config.themes_dir = ''

    if public_url:
        config.public_url = public_url
    else:
        config.static_dir = pjoin(app_dir, 'static')

    return config
Beispiel #4
0
def load_config(nbapp):
    """Load the JupyterLab configuration and defaults for a given application.
    """
    from jupyterlab_server import LabConfig
    from .commands import (get_app_dir, get_app_info, get_workspaces_dir,
                           get_user_settings_dir, pjoin)

    app_dir = getattr(nbapp, 'app_dir', get_app_dir())
    info = get_app_info(app_dir)
    static_url = info['staticUrl']
    user_settings_dir = getattr(nbapp, 'user_settings_dir',
                                get_user_settings_dir())
    workspaces_dir = getattr(nbapp, 'workspaces_dir', get_workspaces_dir())

    config = LabConfig()
    config.app_dir = app_dir
    config.app_name = 'JupyterLab'
    config.app_namespace = 'jupyterlab'
    config.app_settings_dir = pjoin(app_dir, 'settings')
    config.app_version = info['version']
    config.cache_files = True
    config.schemas_dir = pjoin(app_dir, 'schemas')
    config.templates_dir = pjoin(app_dir, 'static')
    config.themes_dir = pjoin(app_dir, 'themes')
    config.user_settings_dir = user_settings_dir
    config.workspaces_dir = workspaces_dir

    if getattr(nbapp, 'override_static_url', ''):
        static_url = nbapp.override_static_url
    if getattr(nbapp, 'override_theme_url', ''):
        config.themes_url = nbapp.override_theme_url
        config.themes_dir = ''

    # shim for jupyterlab_server 0.3
    # XXX remove after next JLab release (current is 1.0.0a6)
    if static_url:
        if hasattr(config, 'static_url'):
            config.static_url = static_url
        else:
            config.public_url = static_url
    else:
        config.static_dir = pjoin(app_dir, 'static')

    return config