git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/9] gitweb: Refactor printing shortened title in git_shortlog_body and git_tags_body

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 14, 2006, 00:08 UTC
Message-ID
<200608140208.27246.jnareb@gmail.com>
In-Reply-To
<200608140202.46160.jnareb@gmail.com>

Separate printing of perhaps shortened title (subject) in git_shortlog_body and git_tags_body into format_subject_html.

While at it, remove presentation element <b>...</b> used to format title (subject) and move formatting to CSS.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
CSS is used in such a way as to not change output
 gitweb/gitweb.css  |    5 +++++
 gitweb/gitweb.perl |   34 ++++++++++++++++++----------------
 2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 47c1ade..f58a418 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -117,9 +117,14 @@ div.list_head {
 
 a.list {
 	text-decoration: none;
+	font-weight: bold;
 	color: #000000;
 }
 
+table.tags a.list {
+	font-weight: normal;
+}
+
 a.list:hover {
 	text-decoration: underline;
 	color: #880000;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0c4ec92..c4d6eab 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -372,6 +372,22 @@ sub format_ref_marker {
 	}
 }
 
+# format, perhaps shortened and with markers, title line
+sub format_subject_html {
+	my ($long, $short, $query, $extra) = @_;
+	$extra = '' unless defined($extra);
+
+	if (length($short) < length($long)) {
+		return $cgi->a({-href => "$my_uri?" . esc_param($query),
+		               -class => "list", -title => $long},
+		       esc_html($short) . $extra);
+	} else {
+		return $cgi->a({-href => "$my_uri?" . esc_param($query),
+		               -class => "list"},
+		       esc_html($long)  . $extra);
+	}
+}
+
 ## ----------------------------------------------------------------------
 ## git utility subroutines, invoking git commands
 
@@ -1085,15 +1101,7 @@ sub git_shortlog_body {
 		print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
 		      "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
 		      "<td>";
-		if (length($co{'title_short'}) < length($co{'title'})) {
-			print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"),
-			               -class => "list", -title => "$co{'title'}"},
-			      "<b>" . esc_html($co{'title_short'}) . "$ref</b>");
-		} else {
-			print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"),
-			               -class => "list"},
-			      "<b>" . esc_html($co{'title'}) . "$ref</b>");
-		}
+		print format_subject_html($co{'title'}, $co{'title_short'}, "p=$project;a=commit;h=$commit", $ref);
 		print "</td>\n" .
 		      "<td class=\"link\">" .
 		      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " .
@@ -1139,13 +1147,7 @@ sub git_tags_body {
 		      "</td>\n" .
 		      "<td>";
 		if (defined $comment) {
-			if (length($comment_short) < length($comment)) {
-				print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}"),
-				               -class => "list", -title => $comment}, $comment_short);
-			} else {
-				print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}"),
-				               -class => "list"}, $comment);
-			}
+			print format_subject_html($comment, $comment_short, "p=$project;a=tag;h=$tag{'id'}");
 		}
 		print "</td>\n" .
 		      "<td class=\"selflink\">";
-- 
1.4.1.1
Previous: Jakub NarebskiNext: Junio C Hamano
Message 7 of 23 in “gitweb: Great subroutine renaming + task separation into subroutines + improvements”
  1. 0/9 gitweb: Great subroutine renaming + task separation into subroutines + improvementsJakub Narebski, Aug 14, 2006
  2. 1/9 gitweb: Great subroutines renamingJakub Narebski, Aug 14, 2006
  3. Junio C HamanoAug 14, 2006
  4. 2/9 gitweb: Separate ref parsing in git_get_refs_list into parse_refJakub Narebski, Aug 14, 2006
  5. Junio C HamanoAug 15, 2006
  6. Jakub NarebskiAug 15, 2006
  7. 3/9 gitweb: Refactor printing shortened title in git_shortlog_body and git_tags_bodyJakub Narebski, Aug 14, 2006
  8. Junio C HamanoAug 15, 2006
  9. 4/9 gitweb: Separate main part of git_history into git_history_bodyJakub Narebski, Aug 14, 2006
  10. 5/9 gitweb: Separate finding project owner into git_get_project_ownerJakub Narebski, Aug 14, 2006
  11. 6/9 gitweb: Change appereance of marker of refs pointing to given objectJakub Narebski, Aug 14, 2006
  12. Jakub NarebskiAug 14, 2006
  13. Junio C HamanoAug 15, 2006
  14. Jakub NarebskiAug 15, 2006
  15. 7/9 gitweb: Skip comments in mime.types like fileJakub Narebski, Aug 14, 2006
  16. 8/9 gitweb: True fix: Support for the standard mime.types map in gitwebJakub Narebski, Aug 14, 2006
  17. Junio C HamanoAug 15, 2006
  18. Jakub NarebskiAug 15, 2006
  19. 9/9 gitweb: Separate printing difftree in git_commit into git_difftree_bodyJakub Narebski, Aug 14, 2006
  20. Junio C HamanoAug 15, 2006
  21. Jakub NarebskiAug 15, 2006
  22. Jakub NarebskiAug 14, 2006
  23. Junio C HamanoAug 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.