inveniosoftware / docs-invenio-rdm

InvenioRDM docs
https://inveniordm.docs.cern.ch/
MIT License
22 stars 64 forks source link

Develop: Topic Guides: Creating a theme #295

Open fwoerister opened 3 years ago

fwoerister commented 3 years ago

Problem Description

We currently have the requirement to modify following templates in our custom theme:

Unfortunately we couldn't figure out an easy way (without messing around with the order of the registered blueprints) to implement this request.

The main problem is, that the according templates are hard-coded in the corresponding view functions (e.g. in the view function of record_detail).

Suggested Solution

I would suggest to specify this templates via config variables, similar as it is done for the frontpage (like here).

Alternative Approach

As already mentioned, there is a way to customize templates by making sure that the blueprint of our custom theme extension is placed before the blueprints of invenio-app-rdm. Flask is sequentially searching for a fitting templates, therefore a template in our custom theme would be selected before the invenio-app-rdm templates are checked. We currently have a solution like that in place (but in my opinion this solution is too messy and should be avoided).

fenekku commented 3 years ago

What about the steps detailed here: https://inveniordm-qa.docs.cern.ch/customize/styling-templates/#change-the-record-landing-page ? Does that work for you? InvenioRDM should be supporting prioritized template loading by placing templates in a folder that jinja checks first.

If that doesn't work it's a bug to fix :)

fwoerister commented 3 years ago

Thanks for you reply :) Yes we already considered that (and it would work). But we are looking for a solution, where we can bundle all our customizations (templates, less and js files, etc.) in one extension.

But after taking a closer look on how the template lookup works, i think defining a new APP_THEME should do the trick.

fenekku commented 3 years ago

Yeah... I wanted this too originally (https://github.com/inveniosoftware/invenio-app-rdm/pull/638), but it wasn't kept I believe because we wanted to keep configuration low / revisit overall approach to configuration. :shrug:

The APP_THEME was something we created to manage the gradual move from bootstrap to semantic-ui in invenio modules. I highly suspect that creating another APP_THEME won't quite work/will need a lot of dupliation because the key e.g. semantic-ui is then used in the webpack.py of many invenio-modules (you would have to somehow be able to replicate it...).

We can keep the ticket open to raise this up again (it probably won't see traction soon though).

github-actions[bot] commented 2 years ago

This issue was automatically marked as stale.

lnielsen commented 2 years ago

The APP_THEME indeed does the job.

You would do something like:

APP_THEME = ['my-overlay', 'semantic-ui']

From the above example, templates and assets with the my-overlay prefix will be looked up first, and if not found the semantic-ui prefix will be used. If none of the lookups are successful, a non-prefixed lookup is done.

I'm moving this issue to the docs repository, since I think we just need to properly document how to do it.

I'd suggest: