summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e076a0e)
raw | patch | inline | side by side (parent: e076a0e)
author | David Symonds <dsymonds@gmail.com> | |
Tue, 23 Oct 2007 01:31:22 +0000 (11:31 +1000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 25 Oct 2007 05:06:57 +0000 (22:06 -0700) |
Signed-off-by: David Symonds <dsymonds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl | patch | blob | history |
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0d45769bc3b7c3789f54f475c9755274530ed1cb..818783eba4888ac6af57c847613ac69760e4390e 100755 (executable)
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
return "$body$tail";
}
+# takes the same arguments as chop_str, but also wraps a <span> around the
+# result with a title attribute if it does get chopped. Additionally, the
+# string is HTML-escaped.
+sub chop_and_escape_str {
+ my $str = shift;
+ my $len = shift;
+ my $add_len = shift || 10;
+
+ my $chopped = chop_str($str, $len, $add_len);
+ if ($chopped eq $str) {
+ return esc_html($chopped);
+ } else {
+ return qq{<span title="} . esc_html($str) . qq{">} .
+ esc_html($chopped) . qq{</span>};
+ }
+}
+
## ----------------------------------------------------------------------
## functions returning short strings
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- my $author = chop_str($co{'author_name'}, 10);
- if ($author ne $co{'author_name'}) {
- $author = "<span title=\"" . esc_html($co{'author_name'}) . "\">" . esc_html($author) . "</span>";
- } else {
- $author = esc_html($author);
- }
+ my $author = chop_and_escape_str($co{'author_name'}, 10);
# git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . $author . "</i></td>\n" .
}
$alternate ^= 1;
# shortlog uses chop_str($co{'author_name'}, 10)
- my $author = chop_str($co{'author_name'}, 15, 3);
- if ($author ne $co{'author_name'}) {
- "<span title=\"" . esc_html($co{'author_name'}) . "\">" . esc_html($author) . "</span>";
- } else {
- $author = esc_html($author);
- }
+ my $author = chop_and_escape_str($co{'author_name'}, 15, 3);
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . $author . "</i></td>\n" .
"<td>";
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- my $author = chop_str($co{'author_name'}, 15, 5);
- if ($author ne $co{'author_name'}) {
- $author = "<span title=\"" . esc_html($co{'author_name'}) . "\">" . esc_html($author) . "</span>";
- } else {
- $author = esc_html($author);
- }
+ my $author = chop_and_escape_str($co{'author_name'}, 15, 5);
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . $author . "</i></td>\n" .
"<td>" .
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
- my $author = chop_str($co{'author_name'}, 15, 5);
- if ($author ne $co{'author_name'}) {
- $author = "<span title=\"" . esc_html($co{'author_name'}) . "\">" . esc_html($author) . "</span>";
- } else {
- $author = esc_html($author);
- }
+ my $author = chop_and_escape_str($co{'author_name'}, 15, 5);
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . $author . "</i></td>\n" .
"<td>" .