{"thread":{"id":"21503","subject":"[PATCH] gitweb: Polish the content tags support","startedAt":"2009-11-06T15:10:55Z","lastAt":"2009-11-06T15:22:54Z","messageCount":2,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"126984","messageId":"1257520255-12698-1-git-send-email-pasky@suse.cz","threadId":"21503","inReplyTo":null,"subject":"[PATCH] gitweb: Polish the content tags support","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-11-06T15:10:55Z","receivedAt":"2009-11-06T15:10:55Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"This patch integrates the tag filtering CGI parameter into the framework\nfor parameter passing, dropping 'by_tag' and instead using query name 't'\nand symbolic name 'ctag_filter'. Compatibility support for 'by_tag' query\nname is retained.\n\nThis means that content tag links are now created using $cgi->a() and\nthe href() method, and that they now point to the proper action;\nproject_list in case of global content tags, forks in case of per-fork\ncontent tags. Also any other arguments like sorting order of projects\nare replayed within the links.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n gitweb/gitweb.perl |   37 +++++++++++++++++++++++--------------\n 1 files changed, 23 insertions(+), 14 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex e82ca45..97e88b4 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -566,6 +566,7 @@ our @cgi_param_mapping = (\n \tsearchtext => \"s\",\n \tsearchtype => \"st\",\n \tsnapshot_format => \"sf\",\n+\tctag_filter => 't',\n \textra_options => \"opt\",\n \tsearch_use_regexp => \"sr\",\n );\n@@ -622,6 +623,11 @@ while (my ($name, $symbol) = each %cgi_param_mapping) {\n \t}\n }\n \n+# Backwards compatibility - by_tag= <=> t=\n+if ($cgi->param('by_tag')) {\n+\t$input_params{'ctag_filter'} = $cgi->param('by_tag');\n+}\n+\n # now read PATH_INFO and update the parameter list for missing parameters\n sub evaluate_path_info {\n \treturn if defined $input_params{'project'};\n@@ -2257,7 +2263,7 @@ sub git_get_project_ctags {\n }\n \n sub git_populate_project_tagcloud {\n-\tmy $ctags = shift;\n+\tmy ($ctags, $action) = @_;\n \n \t# First, merge different-cased tags; tags vote on casing\n \tmy %ctags_lc;\n@@ -2280,7 +2286,8 @@ sub git_populate_project_tagcloud {\n \t\t\t$title =~ s/ /&nbsp;/g;\n \t\t\t$title =~ s/^/&nbsp;/g;\n \t\t\t$title =~ s/$/&nbsp;/g;\n-\t\t\t$cloud->add($title, $home_link.\"?by_tag=\".$_, $ctags_lc{$_}->{count});\n+\t\t\t$cloud->add($title, href(-replay=>1, action=>$action, ctag_filter=>$_),\n+\t\t\t            $ctags_lc{$_}->{count});\n \t\t}\n \t} else {\n \t\t$cloud = \\%ctags_lc;\n@@ -2289,14 +2296,15 @@ sub git_populate_project_tagcloud {\n }\n \n sub git_show_project_tagcloud {\n-\tmy ($cloud, $count) = @_;\n+\tmy ($cloud, $count, $action) = @_;\n \tprint STDERR ref($cloud).\"..\\n\";\n \tif (ref $cloud eq 'HTML::TagCloud') {\n \t\treturn $cloud->html_and_css($count);\n \t} else {\n \t\tmy @tags = sort { $cloud->{$a}->{count} <=> $cloud->{$b}->{count} } keys %$cloud;\n \t\treturn '<p align=\"center\">' . join (', ', map {\n-\t\t\t\"<a href=\\\"$home_link?by_tag=$_\\\">$cloud->{$_}->{topname}</a>\"\n+\t\t\t$cgi->a({-href => href(-replay=>1, action=>$action, ctag_filter=>$_)},\n+\t\t\t\t$cloud->{$_}->{topname});\n \t\t} splice(@tags, 0, $count)) . '</p>';\n \t}\n }\n@@ -4254,7 +4262,8 @@ sub print_sort_th {\n }\n \n sub git_project_list_ctags {\n-\tmy ($projects) = @_;\n+\tmy ($projects, $action) = @_;\n+\t$action ||= 'project_list';\n \n \tmy %ctags;\n \tforeach my $p (@$projects) {\n@@ -4262,13 +4271,13 @@ sub git_project_list_ctags {\n \t\t\t$ctags{$ct} += $p->{'ctags'}->{$ct};\n \t\t}\n \t}\n-\tmy $cloud = git_populate_project_tagcloud(\\%ctags);\n-\tprint git_show_project_tagcloud($cloud, 64);\n+\tmy $cloud = git_populate_project_tagcloud(\\%ctags, $action);\n+\tprint git_show_project_tagcloud($cloud, 64, $action);\n }\n \n sub git_project_list_body {\n \t# actually uses global variable $project\n-\tmy ($projlist, $order, $from, $to, $extra, $no_header) = @_;\n+\tmy ($projlist, $order, $from, $to, $extra, $no_header, $ctags_action) = @_;\n \n \tmy $check_forks = gitweb_check_feature('forks');\n \tmy $show_ctags = gitweb_check_feature('ctags');\n@@ -4292,7 +4301,7 @@ sub git_project_list_body {\n \t}\n \n \tif ($show_ctags) {\n-\t\tgit_project_list_ctags(\\@projects);\n+\t\tgit_project_list_ctags(\\@projects, $ctags_action);\n \t}\n \n \tprint \"<table class=\\\"project_list\\\">\\n\";\n@@ -4309,7 +4318,7 @@ sub git_project_list_body {\n \t\t      \"</tr>\\n\";\n \t}\n \tmy $alternate = 1;\n-\tmy $tagfilter = $cgi->param('by_tag');\n+\tmy $tagfilter = $input_params{'ctag_filter'};\n \tfor (my $i = $from; $i <= $to; $i++) {\n \t\tmy $pr = $projects[$i];\n \n@@ -4682,7 +4691,7 @@ sub git_forks {\n \tgit_header_html();\n \tgit_print_page_nav('','');\n \tgit_print_header_div('summary', \"$project forks\");\n-\tgit_project_list_body(\\@list, $order);\n+\tgit_project_list_body(\\@list, $order, undef, undef, undef, undef, 'forks');\n \tgit_footer_html();\n }\n \n@@ -4756,12 +4765,12 @@ sub git_summary {\n \tmy $show_ctags = gitweb_check_feature('ctags');\n \tif ($show_ctags) {\n \t\tmy $ctags = git_get_project_ctags($project);\n-\t\tmy $cloud = git_populate_project_tagcloud($ctags);\n+\t\tmy $cloud = git_populate_project_tagcloud($ctags, 'project_list');\n \t\tprint \"<tr id=\\\"metadata_ctags\\\"><td>Content tags:<br />\";\n \t\tprint \"</td>\\n<td>\" unless %$ctags;\n \t\tprint \"<form action=\\\"$show_ctags\\\" method=\\\"post\\\"><input type=\\\"hidden\\\" name=\\\"p\\\" value=\\\"$project\\\" />Add: <input type=\\\"text\\\" name=\\\"t\\\" size=\\\"8\\\" /></form>\";\n \t\tprint \"</td>\\n<td>\" if %$ctags;\n-\t\tprint git_show_project_tagcloud($cloud, 48);\n+\t\tprint git_show_project_tagcloud($cloud, 48, 'project_list');\n \t\tprint \"</td></tr>\";\n \t}\n \n@@ -4805,7 +4814,7 @@ sub git_summary {\n \t\tgit_project_list_body(\\@forklist, 'age', 0, 15,\n \t\t                      $#forklist <= 15 ? undef :\n \t\t                      $cgi->a({-href => href(action=>\"forks\")}, \"...\"),\n-\t\t                      'no_header');\n+\t\t                      'no_header', 'forks');\n \t}\n \n \tgit_footer_html();\n-- \ntg: (73bafe5..) t/frontpage/ctags (depends on: t/frontpage/refactor)\n"},{"id":"126986","messageId":"20091106152254.GH17748@machine.or.cz","threadId":"21503","inReplyTo":"1257520255-12698-1-git-send-email-pasky@suse.cz","subject":"Re: [PATCH] gitweb: Refactor project list routines","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-11-06T15:22:54Z","receivedAt":"2009-11-06T15:22:54Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Oops, I'm sorry, I expected tg mail to submit the mails in series...\nThe correct order is:\n\n\t[PATCH] gitweb: Refactor project list routines\n\t[PATCH] gitweb: Support for no project list on gitweb front page\n\t[PATCH] gitweb: Polish the content tags support\n\n(The blob linenr patch is independent.)\n\n\t\t\t\tPetr \"Pasky\" Baudis\n"}]}