{"thread":{"id":"43825","subject":"[PATCH] gitweb: Add support for extending the action bar with custom links","startedAt":"2008-10-02T14:36:52Z","lastAt":"2008-10-03T13:45:02Z","messageCount":2,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"299081","messageId":"1222958212-5896-1-git-send-email-pasky@suse.cz","threadId":"43825","inReplyTo":null,"subject":"[PATCH] gitweb: Add support for extending the action bar with custom links","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-10-02T14:36:52Z","receivedAt":"2008-10-02T14:36:52Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"This makes it possible to easily extend gitweb with custom functionality,\ne.g. git-browser or web-based repository administration system like\nthe repo.or.cz/Girocco duct tape.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n gitweb/gitweb.perl |   35 ++++++++++++++++++++++++++++++++++-\n 1 files changed, 34 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex da474d0..9fbc9f8 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -275,6 +275,26 @@ our %feature = (\n \t'forks' => {\n \t\t'override' => 0,\n \t\t'default' => [0]},\n+\n+\t# Insert custom links to the action bar of all project pages.\n+\t# This enables you mainly to link to third-party scripts integrating\n+\t# into gitweb; e.g. git-browser for graphical history representation\n+\t# or custom web-based repository administration interface.\n+\n+\t# The 'default' value consists of a list of triplets in the form\n+\t# (label, link, position) where position is the label after which\n+\t# to inster the link and link is a format string where %n expands\n+\t# to the project name, %f to the project path within the filesystem,\n+\t# %h to the current hash (h gitweb parameter) and %b to the current\n+\t# hash base (hb gitweb parameter).\n+\n+\t# To enable system wide have in $GITWEB_CONFIG e.g.\n+\t# $feature{'actions'}{'default'} = [('graphiclog',\n+\t# \t'/git-browser/by-commit.html?r=%n', 'summary')];\n+\t# Project specific override is not supported.\n+\t'actions' => {\n+\t\t'override' => 0,\n+\t\t'default' => []},\n );\n \n sub gitweb_check_feature {\n@@ -2757,13 +2777,26 @@ sub git_print_page_nav {\n \t\t\t}\n \t\t}\n \t}\n+\n \t$arg{'tree'}{'hash'} = $treehead if defined $treehead;\n \t$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;\n \n+\tmy @actions = gitweb_check_feature('actions');\n+\twhile (@actions) {\n+\t\tmy ($label, $link, $pos) = (shift(@actions), shift(@actions), shift(@actions));\n+\t\t@navs = map { $_ eq $pos ? ($_, $label) : $_ } @navs;\n+\t\t# munch munch\n+\t\t$link =~ s#%n#$project#g;\n+\t\t$link =~ s#%f#$git_dir#g;\n+\t\t$treehead ? $link =~ s#%h#$treehead#g : $link =~ s#%h##g;\n+\t\t$treebase ? $link =~ s#%b#$treebase#g : $link =~ s#%b##g;\n+\t\t$arg{$label}{'_href'} = $link;\n+\t}\n+\n \tprint \"<div class=\\\"page_nav\\\">\\n\" .\n \t\t(join \" | \",\n \t\t map { $_ eq $current ?\n-\t\t       $_ : $cgi->a({-href => href(%{$arg{$_}})}, \"$_\")\n+\t\t       $_ : $cgi->a({-href => ($arg{$_}{_href} ? $arg{$_}{_href} : href(%{$arg{$_}}))}, \"$_\")\n \t\t } @navs);\n \tprint \"<br/>\\n$extra<br/>\\n\" .\n \t      \"</div>\\n\";\n-- \ntg: (c427559..) t/extra-actions/extra-actions (depends on: vanilla/master)\n"},{"id":"299082","messageId":"1223041502-5204-1-git-send-email-pasky@suse.cz","threadId":"43825","inReplyTo":"1222958212-5896-1-git-send-email-pasky@suse.cz","subject":"[PATCH] gitweb: Unify shortlog/log links","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-10-03T13:45:02Z","receivedAt":"2008-10-03T13:45:02Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Instead of 'shortlog | log', we use only 'log' now, pointing to the shortlog\naction, since that is what most people are usually interested in first. In the\naction-specific navbar, you can then choose between short and full log view.\n\nThe aim of this patch is to reduce the overwhelming number of links by\nincluding only orthogonal links to most popular views.\n\nSigned-off-by: Petr Baudis <petr.baudis@novartis.com>\n\n---\n gitweb/gitweb.perl |   46 +++++++++++++++++++++++++++++++++-------------\n 1 files changed, 33 insertions(+), 13 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 9fbc9f8..58fc137 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2761,7 +2761,7 @@ sub git_print_page_nav {\n \tmy ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;\n \t$extra = '' if !defined $extra; # pager or formats\n \n-\tmy @navs = qw(summary shortlog log commit commitdiff tree);\n+\tmy @navs = qw(summary log commit commitdiff tree);\n \tif ($suppress) {\n \t\t@navs = grep { $_ ne $suppress } @navs;\n \t}\n@@ -2772,12 +2772,11 @@ sub git_print_page_nav {\n \t\t\t$arg{$_}{'hash'} = $head;\n \t\t}\n \t\tif ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {\n-\t\t\tfor (qw(shortlog log)) {\n-\t\t\t\t$arg{$_}{'hash'} = $head;\n-\t\t\t}\n+\t\t\t$arg{'log'}{'hash'} = $head;\n \t\t}\n \t}\n \n+\t$arg{'log'}{'action'} = 'shortlog';\n \t$arg{'tree'}{'hash'} = $treehead if defined $treehead;\n \t$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;\n \n@@ -2832,6 +2831,26 @@ sub format_paging_nav {\n \treturn $paging_nav;\n }\n \n+sub format_log_nav {\n+\tmy ($action, $hash, $head, $page, $has_next_link) = @_;\n+\tmy $paging_nav;\n+\n+\tif ($action eq 'shortlog') {\n+\t\t$paging_nav .= 'shortlog';\n+\t} else {\n+\t\t$paging_nav .= $cgi->a({-href => href(action=>'shortlog', -replay=>1)}, 'shortlog');\n+\t}\n+\t$paging_nav .= ' | ';\n+\tif ($action eq 'log') {\n+\t\t$paging_nav .= 'fulllog';\n+\t} else {\n+\t\t$paging_nav .= $cgi->a({-href => href(action=>'log', -replay=>1)}, 'fulllog');\n+\t}\n+\n+\t$paging_nav .= \" | \" . format_paging_nav($action, $hash, $head, $page, $has_next_link);\n+\treturn $paging_nav;\n+}\n+\n ## ......................................................................\n ## functions printing or outputting HTML: div\n \n@@ -3722,8 +3741,7 @@ sub git_project_list_body {\n \t\t      (defined $pr->{'age_string'} ? $pr->{'age_string'} : \"No commits\") . \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"summary\")}, \"summary\")   . \" | \" .\n-\t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"shortlog\")}, \"shortlog\") . \" | \" .\n-\t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"log\")}, \"log\") . \" | \" .\n+\t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"shortlog\")}, \"log\") . \" | \" .\n \t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"tree\")}, \"tree\") .\n \t\t      ($pr->{'forks'} ? \" | \" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"forks\")}, \"forks\") : '') .\n \t\t      \"</td>\\n\" .\n@@ -3894,8 +3912,7 @@ sub git_tags_body {\n \t\t      \"<td class=\\\"link\\\">\" . \" | \" .\n \t\t      $cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});\n \t\tif ($tag{'reftype'} eq \"commit\") {\n-\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'fullname'})}, \"shortlog\") .\n-\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"log\", hash=>$tag{'fullname'})}, \"log\");\n+\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'fullname'})}, \"log\");\n \t\t} elsif ($tag{'reftype'} eq \"blob\") {\n \t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"blob_plain\", hash=>$tag{'refid'})}, \"raw\");\n \t\t}\n@@ -3934,8 +3951,7 @@ sub git_heads_body {\n \t\t               -class => \"list name\"},esc_html($ref{'name'})) .\n \t\t      \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$ref{'fullname'})}, \"shortlog\") . \" | \" .\n-\t\t      $cgi->a({-href => href(action=>\"log\", hash=>$ref{'fullname'})}, \"log\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$ref{'fullname'})}, \"log\") . \" | \" .\n \t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$ref{'fullname'}, hash_base=>$ref{'name'})}, \"tree\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\";\n@@ -4628,9 +4644,12 @@ sub git_log {\n \n \tmy @commitlist = parse_commits($hash, 101, (100 * $page));\n \n-\tmy $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);\n+\tmy $paging_nav = format_log_nav('log', $hash, $head, $page, $#commitlist >= 100);\n \n-\tgit_header_html();\n+\t{\n+\t\tlocal $action = 'fulllog';\n+\t\tgit_header_html();\n+\t}\n \tgit_print_page_nav('log','', $hash,undef,undef, $paging_nav);\n \n \tif (!@commitlist) {\n@@ -5533,7 +5552,8 @@ sub git_shortlog {\n \n \tmy @commitlist = parse_commits($hash, 101, (100 * $page));\n \n-\tmy $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);\n+\tmy $paging_nav = format_log_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);\n+\n \tmy $next_link = '';\n \tif ($#commitlist >= 100) {\n \t\t$next_link =\n-- \ntg: (7fac06d..) t/extra-actions/log-consolidate (depends on: t/extra-actions/extra-actions)\n"}]}