Files @ 9948ed9916c4
Branch filter:

Location: kallithea/docs/usage/customization.rst

9948ed9916c4 2.5 KiB text/prs.fallenstein.rst Show Annotation Show as Raw Download as Raw
mads
py3: work around incompatibility between pytest, py3 inspect, and tg

Work around an issue that has been reported on
https://github.com/TurboGears/tg2/issues/118 :

.../site-packages/_pytest/doctest.py:381: in _mock_aware_unwrap
return real_unwrap(obj, stop=_is_mocked)
/usr/lib64/python3.7/inspect.py:511: in unwrap
while _is_wrapper(func):
/usr/lib64/python3.7/inspect.py:505: in _is_wrapper
return hasattr(f, '__wrapped__') and not stop(f)
.../site-packages/tg/support/objectproxy.py:19: in __getattr__
return getattr(self._current_obj(), attr)
.../site-packages/tg/request_local.py:240: in _current_obj
return getattr(context, self.name)
.../site-packages/tg/support/objectproxy.py:19: in __getattr__
return getattr(self._current_obj(), attr)
.../site-packages/tg/support/registry.py:72: in _current_obj
'thread' % self.____name__)
E TypeError: No object (name: context) has been registered for this thread

pytest's doctest support is (in _mock_aware_unwrap) using py3 inspect.

Inside inspect, _is_wrapper will do an innocent looking:
hasattr(f, '__wrapped__')

But if the code under test has un (unused) import of a tg context (such as
tg.request), it is no longer so innocent. tg will throw:
TypeError: No object (name: context) has been registered for this thread
(which in py2 would have caught by hasattr, but not in py3.)

pytest will thus fail already in the "collecting ..." phase.

To work around that, use the hack of pushing a tg context in the top level
pytest_configure.
.. _customization:

=============
Customization
=============

There are several ways to customize Kallithea to your needs depending on what
you want to achieve.


HTML/JavaScript/CSS customization
---------------------------------

To customize the look-and-feel of the web interface (for example to add a
company banner or some JavaScript widget or to tweak the CSS style definitions)
you can enter HTML code (possibly with JavaScript and/or CSS) directly via the
*Admin > Settings > Global > HTML/JavaScript customization
block*.


Style sheet customization with Less
-----------------------------------

Kallithea uses `Bootstrap 3`_ and Less_ for its style definitions. If you want
to make some customizations, we recommend to do so by creating a ``theme.less``
file. When you create a file named ``theme.less`` in directory
``kallithea/front-end/`` inside the Kallithea installation, you can use this
file to override the default style. For example, you can use this to override
``@kallithea-theme-main-color``, ``@kallithea-logo-url`` or other `Bootstrap
variables`_.

After creating the ``theme.less`` file, you need to regenerate the CSS files, by
running::

    kallithea-cli front-end-build --no-install-deps

.. _bootstrap 3: https://getbootstrap.com/docs/3.3/
.. _bootstrap variables: https://getbootstrap.com/docs/3.3/customize/#less-variables
.. _less: http://lesscss.org/


Behavioral customization: rcextensions
--------------------------------------

Some behavioral customization can be done in Python using ``rcextensions``, a
custom Python package that can extend Kallithea functionality.

With ``rcextensions`` it's possible to add additional mappings for Whoosh
indexing and statistics, to add additional code into the push/pull/create/delete
repository hooks (for example to send signals to build bots such as Jenkins) and
even to monkey-patch certain parts of the Kallithea source code (for example
overwrite an entire function, change a global variable, ...).

To generate a skeleton extensions package, run::

    kallithea-cli extensions-create -c my.ini

This will create an ``rcextensions`` package next to the specified ``ini`` file.
See the ``__init__.py`` file inside the generated ``rcextensions`` package
for more details.


Behavioral customization: code changes
--------------------------------------

As Kallithea is open-source software, you can make any changes you like directly
in the source code.

We encourage you to send generic improvements back to the
community so that Kallithea can become better. See :ref:`contributing` for more
details.