From 8f600c292e43e1749e7defe4754ad75b10a94427 Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Sun, 17 Jan 2021 22:28:50 +0300 Subject: [PATCH] Add better styling for error messages in UI, and correspond with minserv https://github.com/webmin/webmin/commit/5a53f18b8c7497820953af1c5fd427471008e189 --- miniserv.pl | 15 +++++++++------ web-lib-funcs.pl | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/miniserv.pl b/miniserv.pl index 92a3e0945..df7b35c66 100755 --- a/miniserv.pl +++ b/miniserv.pl @@ -2808,7 +2808,7 @@ else { &reset_byte_count(); &write_data("\n"); &write_data("$code — $msg\n"); - &write_data("

Error — $msg

\n"); + &write_data("

Error — $msg

\n"); if ($body) { &write_data("

$body

\n"); } @@ -6473,14 +6473,17 @@ return $ENV{ uc($key) } || $ENV{ lc($key) }; # Returns a style for error messages sub get_error_style { -my ($type) = @_; -my $style = ' style="font-family:Lucida Console,Courier,monospace;white-space:pre-wrap;'; +my ($type, $extra_style) = @_; +my $style = ' style="font-family:Lucida Console,Courier,monospace;'; if ($type eq 'heading') { - $style .= 'color:#f12b2b;font-size:14px;padding:5px 2.5px 0;transform:scale(1,1.5);text-transform:uppercase;'; + $style .= 'color:#f12b2b;font-size:14px;padding:5px 2.5px 0;transform:scale(1,1.5);text-transform:uppercase;white-space:pre-wrap;font-weight:500;'; } if ($type eq 'content') { - $style .= 'font-size:12.5px;padding-left:2.5px;transform:scale(1,1.2);'; + $style .= 'font-size:12.5px;padding-left:2.5px;white-space:pre-wrap;'; } -$style .= '"'; +if ($type eq 'body') { + $style .= 'font-size:12.5px;'; + } +$style .= "$extra_style\""; return $style; } diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 12d1b573e..7c7d24a9f 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -1621,20 +1621,31 @@ else { @_,"\n"; } else { - print "$text{'error'}: ",($main::whatfailed ? "$main::whatfailed : " : ""), - @_,"

\n"; + my $error_what = ($main::whatfailed ? "$main::whatfailed: " : ""); + my $error_html = join(",", @_); + my $error_text; + if ($error_html !~ //) { + $error_text = " — $error_html"; + $error_html = undef; + } + print "$text{'error'}

$text{'error'}$error_text

$error_html
\n"; } if ($gconfig{'error_stack'}) { # Show call stack print "\n"; - print "\n"; + my $caption_no_header_style = + &miniserv::get_error_style('heading', "padding:0 0 10px 0;" . ($hh ? "color: #222;font-size:98%;" : "") . ""); + print "
\n" if ($hh); + print "
$text{'error_stack'}
$text{'error_stack'}\n"; print " ", " ", "\n"; @@ -3777,7 +3788,7 @@ else { delete($ENV{'FOREIGN_ROOT_DIRECTORY'}); } @INC = @OLDINC; -if ($@) { &error("Require $mod/$files[0] failed :
$@
"); } +if ($@) { &error("
Require $mod/$files[0] failed : $@
"); } return 1; }
$text{'error_file'}$text{'error_line'}$text{'error_sub'}