From 724701cde33fa107c9a3fcf3c8c1ebc89d679a96 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 4 Nov 2009 00:52:06 +0100 Subject: [PATCH] Content tags: Point links to proper action --- .topmsg | 8 +++++--- gitweb/gitweb.perl | 28 +++++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.topmsg b/.topmsg index 121b3b9c37..4ecd6b7bfe 100644 --- a/.topmsg +++ b/.topmsg @@ -1,12 +1,14 @@ From: Petr Baudis -Subject: [PATCH] gitweb: Clean-up some of the content tags support +Subject: [PATCH] gitweb: Polish the content tags support This patch integrates the tag filtering CGI parameter into the framework for parameter passing, dropping 'by_tag' and instead using query name 't' and symbolic name 'ctag_filter'. Compatibility support for 'by_tag' query name is retained. -Also, content tag links are now created using $cgi->a() and the href() -method. +This means that content tag links are now created using $cgi->a() and +the href() method, and that they now point to the proper action; +project_list in case of global content tags, forks in case of per-fork +content tags. Signed-off-by: Petr Baudis diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index e0fd5a6f48..7be7f3e053 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2263,7 +2263,7 @@ sub git_get_project_ctags { } sub git_populate_project_tagcloud { - my $ctags = shift; + my ($ctags, $action) = @_; # First, merge different-cased tags; tags vote on casing my %ctags_lc; @@ -2286,7 +2286,8 @@ sub git_populate_project_tagcloud { $title =~ s/ / /g; $title =~ s/^/ /g; $title =~ s/$/ /g; - $cloud->add($title, href(ctag_filter=>$_), $ctags_lc{$_}->{count}); + $cloud->add($title, href(action=>$action, ctag_filter=>$_), + $ctags_lc{$_}->{count}); } } else { $cloud = \%ctags_lc; @@ -2295,14 +2296,14 @@ sub git_populate_project_tagcloud { } sub git_show_project_tagcloud { - my ($cloud, $count) = @_; + my ($cloud, $count, $action) = @_; print STDERR ref($cloud)."..\n"; if (ref $cloud eq 'HTML::TagCloud') { return $cloud->html_and_css($count); } else { my @tags = sort { $cloud->{$a}->{count} <=> $cloud->{$b}->{count} } keys %$cloud; return '

' . join (', ', map { - $cgi->a({-href => href(ctag_filter=>$_)}, + $cgi->a({-href => href(action=>$action, ctag_filter=>$_)}, $cloud->{$_}->{topname}); } splice(@tags, 0, $count)) . '

'; } @@ -4261,7 +4262,8 @@ sub print_sort_th { } sub git_project_list_ctags { - my ($projects) = @_; + my ($projects, $action) = @_; + $action ||= 'project_list'; my %ctags; foreach my $p (@$projects) { @@ -4269,13 +4271,13 @@ sub git_project_list_ctags { $ctags{$ct} += $p->{'ctags'}->{$ct}; } } - my $cloud = git_populate_project_tagcloud(\%ctags); - print git_show_project_tagcloud($cloud, 64); + my $cloud = git_populate_project_tagcloud(\%ctags, $action); + print git_show_project_tagcloud($cloud, 64, $action); } sub git_project_list_body { # actually uses global variable $project - my ($projlist, $order, $from, $to, $extra, $no_header) = @_; + my ($projlist, $order, $from, $to, $extra, $no_header, $ctags_action) = @_; my $check_forks = gitweb_check_feature('forks'); my $show_ctags = gitweb_check_feature('ctags'); @@ -4299,7 +4301,7 @@ sub git_project_list_body { } if ($show_ctags) { - git_project_list_ctags(\@projects); + git_project_list_ctags(\@projects, $ctags_action); } print "\n"; @@ -4689,7 +4691,7 @@ sub git_forks { git_header_html(); git_print_page_nav('',''); git_print_header_div('summary', "$project forks"); - git_project_list_body(\@list, $order); + git_project_list_body(\@list, $order, undef, undef, undef, undef, 'forks'); git_footer_html(); } @@ -4763,12 +4765,12 @@ sub git_summary { my $show_ctags = gitweb_check_feature('ctags'); if ($show_ctags) { my $ctags = git_get_project_ctags($project); - my $cloud = git_populate_project_tagcloud($ctags); + my $cloud = git_populate_project_tagcloud($ctags, 'project_list'); print "\n\n"; } @@ -4812,7 +4814,7 @@ sub git_summary { git_project_list_body(\@forklist, 'age', 0, 15, $#forklist <= 15 ? undef : $cgi->a({-href => href(action=>"forks")}, "..."), - 'no_header'); + 'no_header', 'forks'); } git_footer_html(); -- 2.11.4.GIT
Content tags:
"; print "
" unless %$ctags; print "
Add:
"; print "
" if %$ctags; - print git_show_project_tagcloud($cloud, 48); + print git_show_project_tagcloud($cloud, 48, 'project_list'); print "