Skip to content

Commit 4b9447f

Browse files
jnarebgitster
authored andcommitted
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 <[email protected]> Acked-by: Petr Baudis <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0368c49 commit 4b9447f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

gitweb/gitweb.perl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,7 @@ sub git_populate_project_tagcloud {
26532653
}
26542654

26552655
my $cloud;
2656+
my $matched = $cgi->param('by_tag');
26562657
if (eval { require HTML::TagCloud; 1; }) {
26572658
$cloud = HTML::TagCloud->new;
26582659
foreach my $ctag (sort keys %ctags_lc) {
@@ -2662,17 +2663,22 @@ sub git_populate_project_tagcloud {
26622663
$title =~ s/ /&nbsp;/g;
26632664
$title =~ s/^/&nbsp;/g;
26642665
$title =~ s/$/&nbsp;/g;
2666+
if (defined $matched && $matched eq $ctag) {
2667+
$title = qq(<span class="match">$title</span>);
2668+
}
26652669
$cloud->add($title, href(project=>undef, ctag=>$ctag),
26662670
$ctags_lc{$ctag}->{count});
26672671
}
26682672
} else {
26692673
$cloud = {};
26702674
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+
}
26722679
$cloud->{$ctag}{count} = $ctags_lc{$ctag}->{count};
26732680
$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);
26762682
}
26772683
}
26782684
return $cloud;

0 commit comments

Comments
 (0)