-
-
Notifications
You must be signed in to change notification settings - Fork 566
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
Gravity update: Handle color escape sequences #3191
base: development
Are you sure you want to change the base?
Gravity update: Handle color escape sequences #3191
Conversation
Signed-off-by: catch-error <[email protected]>
Interesting, what browser do you use? |
I just checked and also don't see color codes. |
I tried it on Chrome & Safari on MacOS, Chrome & Firefox and Windows & Linux. Some subtle differences how the actual escape character is printed, but the rest looks pretty much the same on all systems. I have been working with 6.0 code a lot lately, so maybe screwed something up on my DEV VM. |
Did you change I was able to reproduce your issue only when I edit this file to force the use of colors even when the command is not executed from a terminal. |
No. But I have the WEBCALL always set for pihole. This dates back quite a bit and I simply forgot about it. When it was introduced, it had been a convenient way to always enable colors in a code independent way (with the side effect of also having them in the web interface). And since this is still in the 6.0 code, it just carried over. Is there a technical reason for not wanting gravity output colors in the web interface? Iirc WEBCALL has been introduced specifically for piholeDebug.sh (and is still in pihole code today, although the debug option has been removed from the 6.0 web interface), but never extended to cover also the gravity output. |
Actually, WEBCALL was introduced in 2017, to be used by At that time, the debug log in the web interface didn't had colors, because using them resulted in a broken output (like you are seeing). Later (in 2022), I changed the This was created to fix the Debug Logs uploaded via web interface. Before that, the debug logs generated via web interface didn't had colors and it was harder for us to identify certain issues. Now there is no web interface debug log in v6, so there is no need for this flag anymore. We just forgot to remove the unused code from Gravity Update was never showed in colors in v5 web interface (there was never a PHP function to translate them). |
I wrote my own PHP code for that, though never submitted it. Still I‘d like to see colors also being included in the web interface - it just helps. |
What does this PR aim to accomplish?:
Currently when running gravity update, the color escape sequences used by the shell script are printed literally on the web gui:
This should be the matching real colors instead.
How does this PR accomplish the above?:
The patch checks each line fragment for the existance of a pattern that represents an (ANSI) color code escape sequence and substitutes it with a fitting HTML code.
To preserve color coding also when removing line(s) because of OVER escape sequences, the code is changed from using .text() to .html().
Link documentation PRs if any are needed to support this PR:
N/A
By submitting this pull request, I confirm the following:
git rebase
)