Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to inject custom HTML head tags (closes #1858) #5606

Closed
wants to merge 1 commit into from

Conversation

u1735067
Copy link
Contributor

@u1735067 u1735067 commented Apr 22, 2024

Closes #1858

What's Changed

Add the ability to inject custom HTML head tags (to customize the CSS style for example).

Unless a default value must be set for this change, the variable definition is left to the instance admin.

Config example

settings.py

if os.getenv('NAUTOBOT_CUSTOM_HEAD'):
    CUSTOM_HEAD = os.getenv('NAUTOBOT_CUSTOM_HEAD').strip()
elif os.getenv('NAUTOBOT_CUSTOM_HEAD_FILE'):
    with open(
        os.getenv('NAUTOBOT_CUSTOM_HEAD_FILE'),
        mode='r',
        encoding='utf-8'
    ) as fh:
        CUSTOM_HEAD = fh.read()

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Example App Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

@gsnider2195
Copy link
Contributor

Hi @u1735067 thanks for the submission! Can you provide an example of the html you'd like to inject with this setting?

@u1735067
Copy link
Contributor Author

u1735067 commented Apr 23, 2024

Of course, for example :

CUSTOM_HEAD = r"<style>.navbar-default, .footer { background: linear-gradient(to right, #f8f8f8, moccasin); }</style>"

The primary goal is to allow some style customisation to visually differentiate multiple instances, but one might want to do some more generic things.

Edit: and for another instance, you might want

CUSTOM_HEAD = r"<style>.navbar-default, .footer { background: linear-gradient(to right, #f8f8f8, pink); }</style>"

@glennmatthews
Copy link
Contributor

Thanks for the pull request! We're going to move forward at this time with a different approach to #1858, allowing for the provision of a custom CSS file via the BRANDING_FILEPATHS config setting rather than allowing injection of arbitrary HTML tags into <head>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to customize CSS to differentiate multiple instances
3 participants