I am trying to modify a specific CSS string in Snipe using the Custom CSS text-box. The string I am trying to modify is:
.skin-blue .sidebar-menu>li.active>a, .skin-blue .sidebar-menu>li:hover>a
Nothing.
The custom CSS text-box doesn't seem to interpret the direct descendant (Greater than symbol ">") correctly and my CSS is not applied. I assumed this was due to some markdown issue, although I'm not the most knowledgeable CSS user.
That content is escaped, so it's likely converting the > to the HTML special character. I'm not really comfortable outputting kinescoped user entered data though, so not sure there's a workaround.
Thanks for the prompt response, I appreciate it. Do you know if there's a way I can edit this from the server? We self-host our Snipe instance but after looking through the CSS files in the Public folder I don't see a great place to adjust this.
This probably falls outside your purview since I'm a self-hosted client. In any case, I appreciate the response. I can work around it if need be.
Well, the problem is that you're going to have to keep applying that update every time you upgrade Snipe-IT. :-/
We use Laravel mix + npm to generate CSS and javascript files, so your best bet will probably be to make the change directly in the resources/views/layout/default.blade.php, versus having to set up node/npm, and overwrite ALL of the CSS and JS files with your generated versions.
You can either hardcode that CSS in resources/views/layout/default.blade.php, or switch to un-escaped output for the custom CSS in resources/views/layout/default.blade.php:
Around line 54, change:
@if ($snipeSettings->custom_css)
{{ $snipeSettings->show_custom_css() }}
@endif
to:
@if ($snipeSettings->custom_css)
{!! $snipeSettings->show_custom_css() !!}
@endif
We could also maybe see about still escaping the CSS but, re-un-encoding just the greater-than symbol. That should still keep users safe from XSS attacks, but would make your setup work.
Huh. We're actually already doing that.
$custom_css = str_replace('>', '>', $custom_css);
Can you show me in the HTML source what your custom CSS output looks like?
Certainly. This screenshot shows the CSS i've placed into the Custom text field, and then the CSS the page displays after I save it. Normally when I do this my CSS will show up at the top of the Chrome Dev console and overwrite the default CSS, however in this instance (and every instance with a special character > ) it just never shows up in the chrome console as even being in the CSS.
Can I see the raw HTML, not the computed style?
Sorry for being thick, I've attached a screenshot of the HTML from the console. Is this what you are looking for?
Heh almost. It's okay, I reproduced it locally.
It looks like we're double-encoding those styles, that's why it's still converting the > to >. I've got almost ready for develop.
Okay, fix is on master and develop.
And documentation is updated :)
https://snipe-it.readme.io/v4.0/docs/branding
You're an MVP.