Indico Header and Footer customisation within a plugin


#1

Hi,
my goal is to customise the header and footer of Indico (extending or replacing blocks).
I already read Natalia’s nice HOW TO “Any colour you like”, but I would like to do it in a plugin, not with a separate DIR specified in indico.conf .
Adding my custom plugin should allow me to customise everything…
Is it possible? Do you have any example?
Thank you,

Giorgio


#2
    def init(self):
        super(YourPlugin, self).init()
        self.connect(signals.plugin.get_template_customization_paths, self._override_templates)

    def _override_templates(self, sender, **kwargs):
        return os.path.join(self.root_path, 'template_overrides')

Then that directory inside your plugin’s package can be used like the the template customization dir.


#3

Thank you!
I did it, but if in that dir (“templates_overrides”) I create a “header.html” with some “block logo” customisations, it is not loaded and still it goes to the default header.html template…
Any ideas?


#4

You need to use the same structure as you would use for other overrides, so template_overrides/core/header.html if you want to override indico/web/templates/header.html


#5

Thank you!
I was gettin crazy… It works like a charm now!


#6

Still related to the topic: I’m now trying to inject a UNOG.CSS file.
I tried adding inject_bundle in the class __init__, but I got a “manifest.json not found” error.
Than I found the topic: Theme plugin: How to integrate logos and I understood there are differences from 2.1 to 2.2/master in terms of plugin writing: after switching to 2.1 I got a “AttributeError: ‘module’ object has no attribute ‘get_template_customization_paths’” error.
So the question is: what is the “stable” version I should use? 2.1.8 or 2.2master (or something else)?


#7

Use master for any new development.

If you use a bundle in a plugin, you need to build the assets using the same script you also use to build the assets for indico itself - you just need to call it with different arguments:

$ python bin/maintenance/build-assets.py plugin --dev --watch ../plugins/yourplugin

#8

OK, I understand how to create the manifest.json and the bundle now :wink:
It worked, thank you!
It is a bit curious that to inject a CSS I need to create a JS and import the css, but… it’s ok.
Last “stupid” question: in the css I would like use and IMAGE as background.
How can I point at it?
To make it work I did: background-image: url(…/…/images/unog_bg.jpg);
…but It’s not very elegant (I placed the image in static/images).
Is there a better way?
Thank you,

Giorgio