Show More
@@ -39,8 +39,8 b' Back up your configuration' | |||||
39 |
|
39 | |||
40 | Make a copy of your Kallithea configuration (``.ini``) file. |
|
40 | Make a copy of your Kallithea configuration (``.ini``) file. | |
41 |
|
41 | |||
42 |
If you are using :ref:` |
|
42 | If you are using custom :ref:`extensions <customization>`, you should also | |
43 |
make a copy of the |
|
43 | make a copy of the ``extensions.py`` file. | |
44 |
|
44 | |||
45 | Back up your database |
|
45 | Back up your database | |
46 | ^^^^^^^^^^^^^^^^^^^^^ |
|
46 | ^^^^^^^^^^^^^^^^^^^^^ |
@@ -39,13 +39,14 b' running::' | |||||
39 | .. _less: http://lesscss.org/ |
|
39 | .. _less: http://lesscss.org/ | |
40 |
|
40 | |||
41 |
|
41 | |||
42 |
Behavioral customization: |
|
42 | Behavioral customization: Kallithea extensions | |
43 | -------------------------------------- |
|
43 | ---------------------------------------------- | |
44 |
|
44 | |||
45 |
Some behavioral customization can be done in Python using |
|
45 | Some behavioral customization can be done in Python using Kallithea | |
46 | custom Python package that can extend Kallithea functionality. |
|
46 | ``extensions``, a custom Python file you can create to extend Kallithea | |
|
47 | functionality. | |||
47 |
|
48 | |||
48 |
With `` |
|
49 | With ``extensions`` it's possible to add additional mappings for Whoosh | |
49 | indexing and statistics, to add additional code into the push/pull/create/delete |
|
50 | indexing and statistics, to add additional code into the push/pull/create/delete | |
50 | repository hooks (for example to send signals to build bots such as Jenkins) and |
|
51 | repository hooks (for example to send signals to build bots such as Jenkins) and | |
51 | even to monkey-patch certain parts of the Kallithea source code (for example |
|
52 | even to monkey-patch certain parts of the Kallithea source code (for example | |
@@ -55,9 +56,14 b' To generate a skeleton extensions packag' | |||||
55 |
|
56 | |||
56 | kallithea-cli extensions-create -c my.ini |
|
57 | kallithea-cli extensions-create -c my.ini | |
57 |
|
58 | |||
58 |
This will create an `` |
|
59 | This will create an ``extensions.py`` file next to the specified ``ini`` file. | |
59 | See the ``__init__.py`` file inside the generated ``rcextensions`` package |
|
60 | You can find more details inside this file. | |
60 | for more details. |
|
61 | ||
|
62 | For compatibility with previous releases of Kallithea, a directory named | |||
|
63 | ``rcextensions`` with a file ``__init__.py`` inside of it can also be used. If | |||
|
64 | both an ``extensions.py`` file and an ``rcextensions`` directory are found, only | |||
|
65 | ``extensions.py`` will be loaded. Note that the name ``rcextensions`` is | |||
|
66 | deprecated and support for it will be removed in a future release. | |||
61 |
|
67 | |||
62 |
|
68 | |||
63 | Behavioral customization: code changes |
|
69 | Behavioral customization: code changes |
@@ -33,15 +33,15 b' from kallithea.lib.utils2 import ask_ok' | |||||
33 | def extensions_create(): |
|
33 | def extensions_create(): | |
34 | """Write template file for extending Kallithea in Python. |
|
34 | """Write template file for extending Kallithea in Python. | |
35 |
|
35 | |||
36 | An rcextensions directory with a __init__.py file will be created next to |
|
36 | Create a template `extensions.py` file next to the ini file. Local | |
37 |
|
|
37 | customizations in that file will survive upgrades. The file contains | |
38 |
|
|
38 | instructions on how it can be customized. | |
39 | """ |
|
39 | """ | |
40 | here = kallithea.CONFIG['here'] |
|
40 | here = kallithea.CONFIG['here'] | |
41 | content = pkg_resources.resource_string( |
|
41 | content = pkg_resources.resource_string( | |
42 |
'kallithea', os.path.join('config', ' |
|
42 | 'kallithea', os.path.join('config', 'extensions', 'extensions.py') | |
43 | ) |
|
43 | ) | |
44 |
ext_file = os.path.join(here, ' |
|
44 | ext_file = os.path.join(here, 'extensions.py') | |
45 | if os.path.exists(ext_file): |
|
45 | if os.path.exists(ext_file): | |
46 | msg = ('Extension file %s already exists, do you want ' |
|
46 | msg = ('Extension file %s already exists, do you want ' | |
47 | 'to overwrite it ? [y/n] ') % ext_file |
|
47 | 'to overwrite it ? [y/n] ') % ext_file |
1 | NO CONTENT: file renamed from kallithea/config/rcextensions/__init__.py to kallithea/config/extensions/extensions.py |
|
NO CONTENT: file renamed from kallithea/config/rcextensions/__init__.py to kallithea/config/extensions/extensions.py |
@@ -69,7 +69,7 b' def get_index_filenames():' | |||||
69 |
|
69 | |||
70 | def get_custom_lexer(extension): |
|
70 | def get_custom_lexer(extension): | |
71 | """ |
|
71 | """ | |
72 |
returns a custom lexer if it's defined in |
|
72 | returns a custom lexer if it's defined in the extensions module, or None | |
73 | if there's no custom lexer defined |
|
73 | if there's no custom lexer defined | |
74 | """ |
|
74 | """ | |
75 | import kallithea |
|
75 | import kallithea |
@@ -522,11 +522,15 b' def repo2db_mapper(initial_repo_dict, re' | |||||
522 |
|
522 | |||
523 | def load_extensions(root_path): |
|
523 | def load_extensions(root_path): | |
524 | try: |
|
524 | try: | |
525 |
ext = create_module(' |
|
525 | ext = create_module('extensions', os.path.join(root_path, 'extensions.py')) | |
526 | except FileNotFoundError: |
|
526 | except FileNotFoundError: | |
527 |
|
|
527 | try: | |
|
528 | ext = create_module('rc', os.path.join(root_path, 'rcextensions', '__init__.py')) | |||
|
529 | log.warning('The name "rcextensions" is deprecated. Please use a file `extensions.py` instead of a directory `rcextensions`.') | |||
|
530 | except FileNotFoundError: | |||
|
531 | return | |||
528 |
|
532 | |||
529 |
log.info('Loaded |
|
533 | log.info('Loaded Kallithea extensions from %s', ext) | |
530 | kallithea.EXTENSIONS = ext |
|
534 | kallithea.EXTENSIONS = ext | |
531 |
|
535 | |||
532 | # Additional mappings that are not present in the pygments lexers |
|
536 | # Additional mappings that are not present in the pygments lexers |
General Comments 0
You need to be logged in to leave comments.
Login now