@matheusbsbs / matheus-bagliano / commits / 4b9447f98e
Fork 0

gitweb: Mark matched 'ctag' / contents tag (?by_tag=foo)

It might have been hard to discover that current view is limited to projects with given content tag (ctag), as it was distinquished only in gitweb URL. Mark matched contents tag in the tag cloud using "match" class, for easier discovery. This commit introduces a bit of further code duplication in git_populate_project_tagcloud(). Signed-off-by: Jakub Narebski <jnareb@gmail.com> Acked-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jakub Narebski committed Apr 29, 2011 at 19:51 UTC 4b9447f98ef8699450fa0276d212167a25667d7f
1 file changed +9 -3
gitweb/gitweb.perl
+9 -3
@@ -2653,6 +2653,7 @@ sub git_populate_project_tagcloud {
2653 }
2654
2655 my $cloud;
2656 + my $matched = $cgi->param('by_tag');
2657 if (eval { require HTML::TagCloud; 1; }) {
2658 $cloud = HTML::TagCloud->new;
2659 foreach my $ctag (sort keys %ctags_lc) {
@@ -2662,17 +2663,22 @@ sub git_populate_project_tagcloud {
2663 $title =~ s/ /&nbsp;/g;
2664 $title =~ s/^/&nbsp;/g;
2665 $title =~ s/$/&nbsp;/g;
2666 + if (defined $matched && $matched eq $ctag) {
2667 + $title = qq(<span class="match">$title</span>);
2668 + }
2669 $cloud->add($title, href(project=>undef, ctag=>$ctag),
2670 $ctags_lc{$ctag}->{count});
2671 }
2672 } else {
2673 $cloud = {};
2674 foreach my $ctag (keys %ctags_lc) {
2671 - my $title = $ctags_lc{$ctag}->{topname};
2675 + my $title = esc_html($ctags_lc{$ctag}->{topname}, -nbsp=>1);
2676 + if (defined $matched && $matched eq $ctag) {
2677 + $title = qq(<span class="match">$title</span>);
2678 + }
2679 $cloud->{$ctag}{count} = $ctags_lc{$ctag}->{count};
2680 $cloud->{$ctag}{ctag} =
2674 - $cgi->a({-href=>href(project=>undef, ctag=>$ctag)},
2675 - esc_html($title, -nbsp=>1));
2681 + $cgi->a({-href=>href(project=>undef, ctag=>$ctag)}, $title);
2682 }
2683 }
2684 return $cloud;