liuch/dmarc-srg

Feature Request - Custom CSS

Closed this issue ยท 20 comments

Me again, sorry.

The ability to add custom CSS would be great.

This requires a new entry under Settings -> Advanced: e.g. ui.custom.css (text-field)

A list, separated by spaces can be used here, e.g. custom1.css customB.css.
These CSS files can be uploaded to /css and should be included in the header after the regular/system CSS files.

On the same topic, a dark mode would be cool
The chrome extension dark reader does it quite perfectly for most of the css code

liuch commented

Are you suggesting giving the user the ability to load CSS files using the browser? What to do with files that are no longer needed, give users the option to delete them? This needs thought.

liuch commented

@williamdes, The dark theme implemented a year ago. I use it every day. See here: 609cbbe.

@williamdes, The dark theme implemented a year ago. I use it every day. See here: 609cbbe.

That's probably why it's so perfect, the extension most probably enables it
How can it be enabled in the UI?

liuch commented

DmarcSrg does not have its own theme switcher. To implement this would have required duplicating large part of the CSS code (all the variables) and I gave up on that idea. Your browser itself knows which theme you prefer and makes the switch itself. You set it up with a plugin, and my browser uses my OS settings. By the way, in Firefox, for testing purposes, I can switch the current theme at any time in the developer tools.

Added: I don't use any plugin for that.

@liuch

Are you suggesting giving the user the ability to load CSS files using the browser?

I have expressed myself in a misleading way, please excuse me!

I didn't mean the users who query reports.
I meant administrators who install and run DMARC-SRG on their own servers and want to adapt the look and feel to their own needs (fonts, colors and so on...).

So I can upload my own CSS files to /css during installation or later on (no extra upload mechanism is needed).
An additional option like ui.custom.css is only intended to expand the <header> entries with the entered values and should allows me to use the CSS files without changing the source code and adding
<link rel="stylesheet" href="css/custom-1.css" type="text/css" /> lines.

Unfortunately I have only now noticed that the page is started with an HTML file (index.html), not with a PHP file (e.g. index.php). Of course, this makes adding lines (from a database record) more complex or impossible.

liuch commented

@williamdes It turns out that not all colors are picked up in Chromium with dark mode. Perhaps I should somehow reconsider the layout of css files. In Firefox the utility looks much better. This is my fault.

liuch commented

I understand your point of view. The feature looks logical, but I'm not sure I'll do it anytime soon. Alternatively, I would suggest replacing the index.html with a symbolic link.

Could we add a config statement to add additional scripts and stylesheets ?
this would allow people to add analytics scripts or like here css files to override stuff ?

liuch commented

This is not possible in the current version of DmarcSrg. The tool is not involved in the formation of the index.html file in any way. It is given directly by the web server. Alternatively, I could place an empty file like css/custom.css with a link to it in the index.html and a promise to never change it.

Anyway, I need to think it over.

This is not possible in the current version of DmarcSrg. The tool is not involved in the formation of the index.html file in any way. It is given directly by the web server. Alternatively, I could place an empty file like css/custom.css with a link to it in the index.html and a promise to never change it.

Anyway, I need to think it over.

Ah yes indeed
Could we switch to index.php and introduce a simple routing system?
index.php?route=/reports/list for example

liuch commented

This looks no better than simply using index.php as a template in order to insert a couple of lines with stylesheets and scripts.

liuch commented

Done. Just add something like this: $custom_css = 'css/your_file.css'; to your config/conf.php file.

@liuch with b7f360e I'm getting an PHP error:

dmarc-srg [error]: Error: Call to undefined func tion Liuch\DmarcSrg\str_ends_with() in /var/www/dmarc-srg/classes/Core.php:163 \nStack trace:\n#0 /var/www/dmarc-srg/index.php(28): Liuch\DmarcSrg\Core->send Html()\n#1 {main}

Seems, I have to update to PHP 8.* (using 7.3 now)
"The str_ends_with() function is a predefined function in PHP 8 that is used to perform case-sensitive searching on a given string. "

just upgraded to PHP 8.2 - works now

@liuch can you change the requirements for the PHP version of dmarc-srg
str_ends_with is not present in older PHP versions

liuch commented

It's my mistake. I'm sorry. I just fixed it with a5b508d.

It's my mistake. I'm sorry. I just fixed it with a5b508d.

Thanks
There is another occurrence some lines below

liuch commented

Thanks a lot. I'm definitely having a bad day today. Fixed.

Thanks a lot. I'm definitely having a bad day today. Fixed.

Get some rest ;)
Take care ๐Ÿ˜Š