From ef2239d58e6888ac8faec497424aa53ce3e80f12 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 17 Jul 2024 14:25:45 -0700 Subject: [PATCH] web: make buttons more legible The bootstrap 'btn-success' colors are white text on light green. This is hard to read. Change this to a darker green (seagreen). There are two cases: form submit buttons, and links. Lots of each; not sure I got them all. Each of these should be factored into a single function; maybe later. Also: - use sprintf() instead of "foo".tra("xxx")."blah" - fix sending HTML email with linux 'mail' command - fix display of friends --- html/inc/bootstrap.inc | 5 ++-- html/inc/email.inc | 12 ++++++--- html/inc/pm.inc | 16 ++++++++---- html/inc/prefs.inc | 8 +++++- html/inc/team.inc | 6 ++++- html/inc/user.inc | 12 ++++----- html/inc/util.inc | 34 ++++++++++++++++++++------ html/user/forum_forum.php | 13 ++++++---- html/user/forum_reply.php | 23 ++++++++++------- html/user/forum_search.php | 7 +++++- html/user/host_venue_action.php | 19 ++++++++++---- html/user/profile_menu.php | 16 +++++++----- html/user/sample_index.php | 10 +++++--- html/user/team_admins.php | 7 +++++- html/user/team_change_founder_form.php | 6 ++++- html/user/user_search.php | 8 +++++- 16 files changed, 144 insertions(+), 58 deletions(-) diff --git a/html/inc/bootstrap.inc b/html/inc/bootstrap.inc index cfef323e2e..3996a06915 100644 --- a/html/inc/bootstrap.inc +++ b/html/inc/bootstrap.inc @@ -490,8 +490,9 @@ function form_general($label, $item) { function form_submit($text, $attrs='') { form_general( "", - sprintf('', - $attrs, $text + sprintf( + '', + $attrs, button_style(), $text ) ); } diff --git a/html/inc/email.inc b/html/inc/email.inc index 8c9601cafc..a0f1d46312 100644 --- a/html/inc/email.inc +++ b/html/inc/email.inc @@ -31,9 +31,15 @@ function send_email($user, $subject, $body, $body_html=null, $email_addr=null) { $email_addr = $user->email_addr; } if (defined('EMAIL_USE_CMD')) { - $cmd = "mail -s \"$subject\" $email_addr"; - $pipe = popen($cmd, "w"); - fwrite($pipe, $body); + if ($body_html) { + $cmd = "mail -a \"Content-type: text/html\" -s \"$subject\" $email_addr"; + $pipe = popen($cmd, "w"); + fwrite($pipe, $body_html); + } else { + $cmd = "mail -s \"$subject\" $email_addr"; + $pipe = popen($cmd, "w"); + fwrite($pipe, $body); + } pclose($pipe); return true; } else if (function_exists("make_php_mailer")) { diff --git a/html/inc/pm.inc b/html/inc/pm.inc index 12d4651b05..9ad9cbc1f2 100644 --- a/html/inc/pm.inc +++ b/html/inc/pm.inc @@ -91,11 +91,17 @@ function pm_team_form($user, $teamid, $error=null) { echo ""; echo "\n"; end_table(); - echo " - - - \n - "; + echo sprintf( + ' + + + + ', + button_style('blue'), + tra("Preview"), + button_style(), + tra("Send message") + ); end_table(); page_tail(); } diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index c8ec2729c5..16d7c72e45 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -627,7 +627,13 @@ function print_prefs_form( prefs_form_project_specific($prefs->project_specific, $project_error); } - row2("", ""); + row2("", + sprintf( + '', + button_style(), + $submit_value + ) + ); end_table(); echo "\n"; } diff --git a/html/inc/team.inc b/html/inc/team.inc index 84eab9ed65..f44d4d4939 100644 --- a/html/inc/team.inc +++ b/html/inc/team.inc @@ -515,7 +515,11 @@ function team_edit_form($team, $label, $url) { ); } row2("", - "" + sprintf( + '', + button_style(), + $label + ) ); end_table(); echo "\n"; diff --git a/html/inc/user.inc b/html/inc/user.inc index 7087616333..71086e99c5 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -325,7 +325,8 @@ function show_preference_links() { } } -// return describing a friend: their name, and profile picture if it exists +// return string describing a friend: +// their name, and profile picture if it exists // function friend_links($user) { if (is_banished($user)) { @@ -348,7 +349,7 @@ function friend_links($user) { } $alt = tra("Profile"); $x .= sprintf( - '%s
', + '

%s
', url_base(), $user->id, tra("View the profile of %1", $user->name), @@ -359,7 +360,6 @@ function friend_links($user) { if (function_exists("project_user_links")) { $x .= project_user_links($user); } - $x .= ''; return $x; } @@ -470,14 +470,14 @@ function show_community_private($user) { } $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); - $x = ''; + $x = []; if ($friends) { foreach($friends as $friend) { $fuser = BoincUser::lookup_id($friend->user_dest); if (!$fuser) continue; - $x .= friend_links($fuser); + $x[] = friend_links($fuser); } - row2(tra("Friends"), $x); + row2(tra("Friends"), implode('
', $x)); } else { row2(tra("Friends"), '---'); } diff --git a/html/inc/util.inc b/html/inc/util.inc index 9a226f88fc..5f93d4906b 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -913,20 +913,38 @@ function current_url() { return $url; } -// Show a single link formatted to look like a button. -// @param url The destination URL of the button -// @param text The text to display on the button -// @param desc The title of the destination - typically used as a popup -// @param class The optional CSS class of the button. Defaults to a standard button -// @params extra Additional text in href tag +// style for a button +// the colors for bootstrap' btn-success are almost illegible; +// the green is too light. Use a darker green. +// +function button_style($color='green', $font_size=null) { + $fs = ''; + if ($font_size) { + $fs = sprintf('; font-size:%dpx', $font_size); + } + $c = 'seagreen'; + if ($color == 'blue') $c = 'steelblue'; + return sprintf( + 'style="background-color:%s; color:white; text-decoration:none%s"', + $c, $fs + ); +} +// Show a link formatted to look like a button. +// url: the destination of the lin +// text: The text to display on the button +// desc: tooltip text (show on hover) +// class: class of the button, e.g. btn +// extra: Additional text in href tag // - function button_text($url, $text, $desc=null, $class=null, $extra='') { if (!$desc) { $desc = $text; } + if (!$extra && !$class) { + $extra = button_style(); + } if (!$class) { - $class = "btn-success btn-sm"; + $class = "btn btn-sm"; } return sprintf(' %s', $url, $desc, $class, $extra, $text diff --git a/html/user/forum_forum.php b/html/user/forum_forum.php index 5d7b6d7e59..844e5662b3 100644 --- a/html/user/forum_forum.php +++ b/html/user/forum_forum.php @@ -97,7 +97,9 @@ echo ' if (user_can_create_thread($user, $forum)) { show_button( - "forum_post.php?id=$id", tra("New thread"), tra("Add a new thread to this forum") + "forum_post.php?id=$id", + tra("New thread"), + tra("Add a new thread to this forum") ); } @@ -106,15 +108,16 @@ echo '

'; echo select_from_array("sort", $forum_sort_styles, $sort_style); -echo ' - +echo sprintf(' +
-

-'; +

', + button_style() +); show_forum($forum, $start, $sort_style, $user); diff --git a/html/user/forum_reply.php b/html/user/forum_reply.php index 4193f43aa4..38ea75db54 100644 --- a/html/user/forum_reply.php +++ b/html/user/forum_reply.php @@ -165,19 +165,24 @@ function show_message_row($thread, $parent_post) { } } if (!$logged_in_user->prefs->no_signature_by_default) { - $enable_signature="checked=\"true\""; + $enable_signature='checked="true"'; } else { $enable_signature=""; } - $x2 .= "

- - + $x2 .= sprintf('

+ +     - - - - - "; + + + ', + button_style('blue'), + tra("Preview"), + button_style(), + tra("Post reply"), + $enable_signature, + tra("Add my signature to this reply") + ); row2($x1, $x2, false, "20%"); } diff --git a/html/user/forum_search.php b/html/user/forum_search.php index d70bbda935..0dd0186afc 100644 --- a/html/user/forum_search.php +++ b/html/user/forum_search.php @@ -87,7 +87,12 @@ row2(tra("Sort by"), '"; end_table(); diff --git a/html/user/host_venue_action.php b/html/user/host_venue_action.php index de3b85bd99..e4bf15f837 100644 --- a/html/user/host_venue_action.php +++ b/html/user/host_venue_action.php @@ -42,13 +42,22 @@ if ($retval) { if ($venue == '') { $venue = '('.tra("none").')'; } - echo " - ".tra("The venue of this computer has been set to %1.", "$venue")." + echo sprintf( + '%s

- ".tra("Preference changes will take effect when the computer communicates with this project.")." + %s

- ".tra("Return to computer page").". - "; + %s + ', + tra( + 'The venue of this computer has been set to %1.', + "$venue" + ), + tra('Preference changes will take effect when the computer communicates with this project.'), + button_style(), + HOME_PAGE, + tra('Continue to home page') + ); page_tail(); } else { db_error_page(); diff --git a/html/user/profile_menu.php b/html/user/profile_menu.php index 356ebe0566..4ee0c4b9e3 100644 --- a/html/user/profile_menu.php +++ b/html/user/profile_menu.php @@ -72,12 +72,16 @@ if (file_exists(PROFILE_PATH . "profile_alpha.html")) { echo ""; row1(tra("Search profile text")); -rowify(" -

- - -
-"); +rowify( + sprintf( + '
+ + +
', + button_style(), + tra("Search") + ) +); end_table(); page_tail(); diff --git a/html/user/sample_index.php b/html/user/sample_index.php index 37c19c5e73..89cc7ebb72 100644 --- a/html/user/sample_index.php +++ b/html/user/sample_index.php @@ -85,9 +85,13 @@ function left(){ } } echo "

"; - echo sprintf('

%s
- ', - tra('Continue to your home page') + echo sprintf('
%s
', + button_text('home.php', + tra('Continue to your home page'), + '', + '', + button_style('green', 16) + ) ); echo "

"; echo sprintf('%s diff --git a/html/user/team_admins.php b/html/user/team_admins.php index 93fde5caa4..39500b1dff 100644 --- a/html/user/team_admins.php +++ b/html/user/team_admins.php @@ -80,7 +80,12 @@ function show_admins($user, $teamid) { start_table(); row1(tra("Add Team Admin")); row2(tra("Email address of team member:"), ''); - row2("", ""); + row2("", + sprintf('', + button_style(), + tra("Add") + ) + ); end_table(); echo ""; diff --git a/html/user/team_change_founder_form.php b/html/user/team_change_founder_form.php index 3ffe68f1b6..0bf5344666 100644 --- a/html/user/team_change_founder_form.php +++ b/html/user/team_change_founder_form.php @@ -110,7 +110,11 @@ foreach ($users as $user) { if ($navailable_users > 0) { echo ""; end_table(); - echo ""; + echo sprintf( + '', + button_style(), + tra("Change founder") + ); } else { echo " ".tra("There are no users to transfer team to.")." diff --git a/html/user/user_search.php b/html/user/user_search.php index 2bd27fdd90..68b669aab7 100644 --- a/html/user/user_search.php +++ b/html/user/user_search.php @@ -89,7 +89,13 @@ function user_search_form() { row2(tra("Decreasing average credit"), ""); row2(tra("Decreasing total credit"), ""); } - row2("", ""); + row2("", + sprintf( + '', + button_style(), + tra("Search") + ) + ); end_table(); echo "