# HG changeset patch # User Takumi IINO # Date 2015-10-20 13:18:47 # Node ID 6ed126ef71afdb2cbf3d6f0419a8c02b70de4ce2 # Parent 130f8e170d3caf452383d87ede5572d1a770881e indexers: load additional indexers settings from ini diff --git a/development.ini b/development.ini --- a/development.ini +++ b/development.ini @@ -296,6 +296,18 @@ allow_repo_location_change = True ## allows to setup custom hooks in settings page allow_custom_hooks_settings = True +## extra extensions for indexing, space separated and without the leading '.'. +# index.extensions = +# gemfile +# lock + +## extra filenames for indexing, space separated +# index.filenames = +# .dockerignore +# .editorconfig +# INSTALL +# CHANGELOG + #################################### ### CELERY CONFIG #### #################################### diff --git a/kallithea/bin/template.ini.mako b/kallithea/bin/template.ini.mako --- a/kallithea/bin/template.ini.mako +++ b/kallithea/bin/template.ini.mako @@ -293,6 +293,18 @@ allow_repo_location_change = True <%text>## allows to setup custom hooks in settings page allow_custom_hooks_settings = True +<%text>## extra extensions for indexing, space separated and without the leading '.'. +# index.extensions = +# gemfile +# lock + +<%text>## extra filenames for indexing, space separated +# index.filenames = +# .dockerignore +# .editorconfig +# INSTALL +# CHANGELOG + <%text>#################################### <%text>### CELERY CONFIG #### <%text>#################################### diff --git a/kallithea/config/deployment.ini_tmpl b/kallithea/config/deployment.ini_tmpl --- a/kallithea/config/deployment.ini_tmpl +++ b/kallithea/config/deployment.ini_tmpl @@ -289,6 +289,18 @@ allow_repo_location_change = True ## allows to setup custom hooks in settings page allow_custom_hooks_settings = True +## extra extensions for indexing, space separated and without the leading '.'. +# index.extensions = +# gemfile +# lock + +## extra filenames for indexing, space separated +# index.filenames = +# .dockerignore +# .editorconfig +# INSTALL +# CHANGELOG + #################################### ### CELERY CONFIG #### #################################### diff --git a/kallithea/config/environment.py b/kallithea/config/environment.py --- a/kallithea/config/environment.py +++ b/kallithea/config/environment.py @@ -34,7 +34,7 @@ from kallithea.config.routing import mak from kallithea.lib import helpers from kallithea.lib.auth import set_available_permissions from kallithea.lib.utils import repo2db_mapper, make_ui, set_app_settings,\ - load_rcextensions, check_git_version, set_vcs_config + load_rcextensions, check_git_version, set_vcs_config, set_indexer_config from kallithea.lib.utils2 import engine_from_config, str2bool from kallithea.lib.db_manage import DbManage from kallithea.model import init_model @@ -130,6 +130,7 @@ def load_environment(global_conf, app_co # pylons kallithea.CONFIG.update(config) set_vcs_config(kallithea.CONFIG) + set_indexer_config(kallithea.CONFIG) #check git version check_git_version() diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -418,6 +418,21 @@ def set_vcs_config(config): 'utf8'), sep=',') +def set_indexer_config(config): + """ + Update Whoosh index mapping + + :param config: kallithea.CONFIG + """ + from kallithea.config import conf + + log.debug('adding extra into INDEX_EXTENSIONS') + conf.INDEX_EXTENSIONS.extend(re.split('\s+', config.get('index.extensions', ''))) + + log.debug('adding extra into INDEX_FILENAMES') + conf.INDEX_FILENAMES.extend(re.split('\s+', config.get('index.filenames', ''))) + + def map_groups(path): """ Given a full path to a repository, create all nested groups that this diff --git a/kallithea/tests/test.ini b/kallithea/tests/test.ini --- a/kallithea/tests/test.ini +++ b/kallithea/tests/test.ini @@ -297,6 +297,18 @@ allow_repo_location_change = True ## allows to setup custom hooks in settings page allow_custom_hooks_settings = True +## extra extensions for indexing, space separated and without the leading '.'. +# index.extensions = +# gemfile +# lock + +## extra filenames for indexing, space separated +# index.filenames = +# .dockerignore +# .editorconfig +# INSTALL +# CHANGELOG + #################################### ### CELERY CONFIG #### ####################################