changeset 5560:6ed126ef71af

indexers: load additional indexers settings from ini
author Takumi IINO <trot.thunder@gmail.com>
date Tue, 20 Oct 2015 22:18:47 +0900
parents 130f8e170d3c
children 59edb20f88ad
files development.ini kallithea/bin/template.ini.mako kallithea/config/deployment.ini_tmpl kallithea/config/environment.py kallithea/lib/utils.py kallithea/tests/test.ini
diffstat 6 files changed, 65 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Fri Oct 23 13:36:56 2015 +0100
+++ b/development.ini	Tue Oct 20 22:18:47 2015 +0900
@@ -296,6 +296,18 @@
 ## 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        ####
 ####################################
--- a/kallithea/bin/template.ini.mako	Fri Oct 23 13:36:56 2015 +0100
+++ b/kallithea/bin/template.ini.mako	Tue Oct 20 22:18:47 2015 +0900
@@ -293,6 +293,18 @@
 <%text>## allows to setup custom hooks in settings page</%text>
 allow_custom_hooks_settings = True
 
+<%text>## extra extensions for indexing, space separated and without the leading '.'.</%text>
+# index.extensions =
+#    gemfile
+#    lock
+
+<%text>## extra filenames for indexing, space separated</%text>
+# index.filenames =
+#    .dockerignore
+#    .editorconfig
+#    INSTALL
+#    CHANGELOG
+
 <%text>####################################</%text>
 <%text>###        CELERY CONFIG        ####</%text>
 <%text>####################################</%text>
--- a/kallithea/config/deployment.ini_tmpl	Fri Oct 23 13:36:56 2015 +0100
+++ b/kallithea/config/deployment.ini_tmpl	Tue Oct 20 22:18:47 2015 +0900
@@ -289,6 +289,18 @@
 ## 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        ####
 ####################################
--- a/kallithea/config/environment.py	Fri Oct 23 13:36:56 2015 +0100
+++ b/kallithea/config/environment.py	Tue Oct 20 22:18:47 2015 +0900
@@ -34,7 +34,7 @@
 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 @@
     # pylons
     kallithea.CONFIG.update(config)
     set_vcs_config(kallithea.CONFIG)
+    set_indexer_config(kallithea.CONFIG)
 
     #check git version
     check_git_version()
--- a/kallithea/lib/utils.py	Fri Oct 23 13:36:56 2015 +0100
+++ b/kallithea/lib/utils.py	Tue Oct 20 22:18:47 2015 +0900
@@ -418,6 +418,21 @@
                                                         '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
--- a/kallithea/tests/test.ini	Fri Oct 23 13:36:56 2015 +0100
+++ b/kallithea/tests/test.ini	Tue Oct 20 22:18:47 2015 +0900
@@ -297,6 +297,18 @@
 ## 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        ####
 ####################################