{"thread":{"id":"27675","subject":"[PATCH] gitweb: Refactor git_header_html","startedAt":"2011-06-21T18:38:42Z","lastAt":"2011-06-22T11:50:46Z","messageCount":4,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"170407","messageId":"20110621183550.9315.21922.stgit@localhost.localdomain","threadId":"27675","inReplyTo":null,"subject":"[PATCH] gitweb: Refactor git_header_html","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-21T18:38:42Z","receivedAt":"2011-06-21T18:38:42Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Extract (factor out) the following parts into separate subroutines:\n* finding correct MIME content type for HTML pages (text/html or\n  application/xhtml+xml?) into get_content_type_html()\n* printing <link ...> elements in HTML head into print_header_links()\n* printing navigation \"breadcrumbs\" for given action into\n  print_nav_breadcrumbs()\n* printing search form into print_search_form()\n\nThis reduces git_header_html to two pages long (53 lines).\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis originally was a first part of patch series improving search in\ngitweb, but because it is independent improvement, it is sent as a\nseparate patch.\n\nNot a regression fix, not for 1.7.6\n\nP.S. I wonder if print_search_form() should also get passed %opts as\none of its parameters...\n\n gitweb/gitweb.perl |  173 +++++++++++++++++++++++++++++-----------------------\n 1 files changed, 96 insertions(+), 77 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f13b4b5..c9e6426 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3693,6 +3693,20 @@ sub get_page_title {\n \treturn $title;\n }\n \n+sub get_content_type_html {\n+\t# require explicit support from the UA if we are to send the page as\n+\t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n+\t# we have to do this because MSIE sometimes globs '*/*', pretending to\n+\t# support xhtml+xml but choking when it gets what it asked for.\n+\tif (defined $cgi->http('HTTP_ACCEPT') &&\n+\t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n+\t    $cgi->Accept('application/xhtml+xml') != 0) {\n+\t\treturn 'application/xhtml+xml';\n+\t} else {\n+\t\treturn 'text/html';\n+\t}\n+}\n+\n sub print_feed_meta {\n \tif (defined $project) {\n \t\tmy %href_params = get_feed_info();\n@@ -3738,24 +3752,91 @@ sub print_feed_meta {\n \t}\n }\n \n+sub print_header_links {\n+\tmy %opts = @_;\n+\n+\t# print out each stylesheet that exist, providing backwards capability\n+\t# for those people who defined $stylesheet in a config file\n+\tif (defined $stylesheet) {\n+\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n+\t} else {\n+\t\tforeach my $stylesheet (@stylesheets) {\n+\t\t\tnext unless $stylesheet;\n+\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n+\t\t}\n+\t}\n+\tif ($opts{'-feed'}) {\n+\t\tprint_feed_meta();\n+\t}\n+\tif (defined $favicon) {\n+\t\tprint qq(<link rel=\"shortcut icon\" href=\").esc_url($favicon).qq(\" type=\"image/png\" />\\n);\n+\t}\n+}\n+\n+sub print_nav_breadcrumbs {\n+\tmy %opts = @_;\n+\n+\tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n+\tif (defined $project) {\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tif (defined $action) {\n+\t\t\tmy $action_print = $action ;\n+\t\t\tif (defined $opts{-action_extra}) {\n+\t\t\t\t$action_print = $cgi->a({-href => href(action=>$action)},\n+\t\t\t\t\t$action);\n+\t\t\t}\n+\t\t\tprint \" / $action_print\";\n+\t\t}\n+\t\tif (defined $opts{-action_extra}) {\n+\t\t\tprint \" / $opts{-action_extra}\";\n+\t\t}\n+\t\tprint \"\\n\";\n+\t}\n+}\n+\n+sub print_search_form {\n+\tif (!defined $searchtext) {\n+\t\t$searchtext = \"\";\n+\t}\n+\tmy $search_hash;\n+\tif (defined $hash_base) {\n+\t\t$search_hash = $hash_base;\n+\t} elsif (defined $hash) {\n+\t\t$search_hash = $hash;\n+\t} else {\n+\t\t$search_hash = \"HEAD\";\n+\t}\n+\tmy $action = $my_uri;\n+\tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n+\tif ($use_pathinfo) {\n+\t\t$action .= \"/\".esc_url($project);\n+\t}\n+\tprint $cgi->startform(-method => \"get\", -action => $action) .\n+\t      \"<div class=\\\"search\\\">\\n\" .\n+\t      (!$use_pathinfo &&\n+\t      $cgi->input({-name=>\"p\", -value=>$project, -type=>\"hidden\"}) . \"\\n\") .\n+\t      $cgi->input({-name=>\"a\", -value=>\"search\", -type=>\"hidden\"}) . \"\\n\" .\n+\t      $cgi->input({-name=>\"h\", -value=>$search_hash, -type=>\"hidden\"}) . \"\\n\" .\n+\t      $cgi->popup_menu(-name => 'st', -default => 'commit',\n+\t                       -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .\n+\t      $cgi->sup($cgi->a({-href => href(action=>\"search_help\")}, \"?\")) .\n+\t      \" search:\\n\",\n+\t      $cgi->textfield(-name => \"s\", -value => $searchtext) . \"\\n\" .\n+\t      \"<span title=\\\"Extended regular expression\\\">\" .\n+\t      $cgi->checkbox(-name => 'sr', -value => 1, -label => 're',\n+\t                     -checked => $search_use_regexp) .\n+\t      \"</span>\" .\n+\t      \"</div>\" .\n+\t      $cgi->end_form() . \"\\n\";\n+}\n+\n sub git_header_html {\n \tmy $status = shift || \"200 OK\";\n \tmy $expires = shift;\n \tmy %opts = @_;\n \n \tmy $title = get_page_title();\n-\tmy $content_type;\n-\t# require explicit support from the UA if we are to send the page as\n-\t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n-\t# we have to do this because MSIE sometimes globs '*/*', pretending to\n-\t# support xhtml+xml but choking when it gets what it asked for.\n-\tif (defined $cgi->http('HTTP_ACCEPT') &&\n-\t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n-\t    $cgi->Accept('application/xhtml+xml') != 0) {\n-\t\t$content_type = 'application/xhtml+xml';\n-\t} else {\n-\t\t$content_type = 'text/html';\n-\t}\n+\tmy $content_type = get_content_type_html();\n \tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n \t                   -status=> $status, -expires => $expires)\n \t\tunless ($opts{'-no_http_header'});\n@@ -3777,22 +3858,7 @@ EOF\n \tif ($ENV{'PATH_INFO'}) {\n \t\tprint \"<base href=\\\"\".esc_url($base_url).\"\\\" />\\n\";\n \t}\n-\t# print out each stylesheet that exist, providing backwards capability\n-\t# for those people who defined $stylesheet in a config file\n-\tif (defined $stylesheet) {\n-\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n-\t} else {\n-\t\tforeach my $stylesheet (@stylesheets) {\n-\t\t\tnext unless $stylesheet;\n-\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n-\t\t}\n-\t}\n-\tprint_feed_meta()\n-\t\tif ($status eq '200 OK');\n-\tif (defined $favicon) {\n-\t\tprint qq(<link rel=\"shortcut icon\" href=\").esc_url($favicon).qq(\" type=\"image/png\" />\\n);\n-\t}\n-\n+\tprint_header_links(-feed => $status eq '200 OK');\n \tprint \"</head>\\n\" .\n \t      \"<body>\\n\";\n \n@@ -3809,59 +3875,12 @@ EOF\n \t\t                         -alt => \"git\",\n \t\t                         -class => \"logo\"}));\n \t}\n-\tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n-\tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n-\t\tif (defined $action) {\n-\t\t\tmy $action_print = $action ;\n-\t\t\tif (defined $opts{-action_extra}) {\n-\t\t\t\t$action_print = $cgi->a({-href => href(action=>$action)},\n-\t\t\t\t\t$action);\n-\t\t\t}\n-\t\t\tprint \" / $action_print\";\n-\t\t}\n-\t\tif (defined $opts{-action_extra}) {\n-\t\t\tprint \" / $opts{-action_extra}\";\n-\t\t}\n-\t\tprint \"\\n\";\n-\t}\n+\tprint_nav_breadcrumbs(%opts);\n \tprint \"</div>\\n\";\n \n \tmy $have_search = gitweb_check_feature('search');\n \tif (defined $project && $have_search) {\n-\t\tif (!defined $searchtext) {\n-\t\t\t$searchtext = \"\";\n-\t\t}\n-\t\tmy $search_hash;\n-\t\tif (defined $hash_base) {\n-\t\t\t$search_hash = $hash_base;\n-\t\t} elsif (defined $hash) {\n-\t\t\t$search_hash = $hash;\n-\t\t} else {\n-\t\t\t$search_hash = \"HEAD\";\n-\t\t}\n-\t\tmy $action = $my_uri;\n-\t\tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n-\t\tif ($use_pathinfo) {\n-\t\t\t$action .= \"/\".esc_url($project);\n-\t\t}\n-\t\tprint $cgi->startform(-method => \"get\", -action => $action) .\n-\t\t      \"<div class=\\\"search\\\">\\n\" .\n-\t\t      (!$use_pathinfo &&\n-\t\t      $cgi->input({-name=>\"p\", -value=>$project, -type=>\"hidden\"}) . \"\\n\") .\n-\t\t      $cgi->input({-name=>\"a\", -value=>\"search\", -type=>\"hidden\"}) . \"\\n\" .\n-\t\t      $cgi->input({-name=>\"h\", -value=>$search_hash, -type=>\"hidden\"}) . \"\\n\" .\n-\t\t      $cgi->popup_menu(-name => 'st', -default => 'commit',\n-\t\t                       -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .\n-\t\t      $cgi->sup($cgi->a({-href => href(action=>\"search_help\")}, \"?\")) .\n-\t\t      \" search:\\n\",\n-\t\t      $cgi->textfield(-name => \"s\", -value => $searchtext) . \"\\n\" .\n-\t\t      \"<span title=\\\"Extended regular expression\\\">\" .\n-\t\t      $cgi->checkbox(-name => 'sr', -value => 1, -label => 're',\n-\t\t                     -checked => $search_use_regexp) .\n-\t\t      \"</span>\" .\n-\t\t      \"</div>\" .\n-\t\t      $cgi->end_form() . \"\\n\";\n+\t\tprint_search_form();\n \t}\n }\n \n"},{"id":"170430","messageId":"7v4o3i7nkt.fsf@alter.siamese.dyndns.org","threadId":"27675","inReplyTo":"20110621183550.9315.21922.stgit@localhost.localdomain","subject":"Re: [PATCH] gitweb: Refactor git_header_html","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-06-21T23:48:50Z","receivedAt":"2011-06-21T23:48:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> P.S. I wonder if print_search_form() should also get passed %opts as\n> one of its parameters...\n\nI do not particularly care for this:\n\n\tsub foo {\n        \tmy %opts = @_;\n\n\t\tif ($opts{-option} eq 'bar') {\n                \t... do this ...\n\nstyle, which lets a caller pass any random typo to the callee, like so:\n\n\tfoo(-optoin => 'value');\n\nBut maybe it is just me.\n\n> +sub print_header_links {\n> +\tmy %opts = @_;\n> +\n> +\t# print out each stylesheet that exist, providing backwards capability\n> +\t# for those people who defined $stylesheet in a config file\n> +\tif (defined $stylesheet) {\n> +\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n> +\t} else {\n> +\t\tforeach my $stylesheet (@stylesheets) {\n> +\t\t\tnext unless $stylesheet;\n> +\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n> +\t\t}\n> +\t}\n> +\tif ($opts{'-feed'}) {\n> +\t\tprint_feed_meta();\n> +\t}\n\nHere, we refrain from showing the <link> elements that are related to the\nRSS/Atom feeds (if we know what $project we are talking about), or <link>\nelements that are related to the project list (html top page and opml) if\nwe are not showing a normal return, as $opts{'-feed'} is true only when we\nare returning '200 OK'.\n\nThe original implementation, even though it used statement modifiers after\nthis print_feed_meta(), was much easier to follow, at least for me. The\nassociation between \"feed-meta\" and \"200 OK\" was close together and more\ndirect.\n\n> ...\n> -\t\t}\n> -\t}\n> -\tprint_feed_meta()\n> -\t\tif ($status eq '200 OK');\n\nOther than that, this looks a correct no-op patch that makes the resulting\nsmaller functions easier to grok.\n"},{"id":"170448","messageId":"201106220844.35431.jnareb@gmail.com","threadId":"27675","inReplyTo":"7v4o3i7nkt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] gitweb: Refactor git_header_html","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-22T06:44:34Z","receivedAt":"2011-06-22T06:44:34Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 22 Jun 2011, Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > P.S. I wonder if print_search_form() should also get passed %opts as\n> > one of its parameters...\n> \n> I do not particularly care for this:\n> \n> \tsub foo {\n>         \tmy %opts = @_;\n> \n> \t\tif ($opts{-option} eq 'bar') {\n>                 \t... do this ...\n> \n> style, which lets a caller pass any random typo to the callee, like so:\n> \n> \tfoo(-optoin => 'value');\n> \n> But maybe it is just me.\n\nWell, originally this style was used mainly to pass some extra rarely\nset boolean flags; isn't\n\n        foo($bar, \"baz\", -quux => 1, -corge => 1);\n\nbetter than\n\n        foo($bar, \"baz\", 1, 0, 1);\n\nwhen it is ordinarily (most times) called as\n\n        foo($bar, \"baz\");\n\n\nWhen writing in C, one would probably use #defines for this:\n\n        foo(bar, \"baz\", FOO_QUUX | FOO_CORGE);\n\nbut it is not very Perl-ish, I would think.\n\n> > +sub print_header_links {\n> > +\tmy %opts = @_;\n> > +\n> > +\t# print out each stylesheet that exist, providing backwards capability\n> > +\t# for those people who defined $stylesheet in a config file\n> > +\tif (defined $stylesheet) {\n> > +\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n> > +\t} else {\n> > +\t\tforeach my $stylesheet (@stylesheets) {\n> > +\t\t\tnext unless $stylesheet;\n> > +\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n> > +\t\t}\n> > +\t}\n> > +\tif ($opts{'-feed'}) {\n> > +\t\tprint_feed_meta();\n> > +\t}\n> \n> Here, we refrain from showing the <link> elements that are related to the\n> RSS/Atom feeds (if we know what $project we are talking about), or <link>\n> elements that are related to the project list (html top page and opml) if\n> we are not showing a normal return, as $opts{'-feed'} is true only when we\n> are returning '200 OK'.\n> \n> The original implementation, even though it used statement modifiers after\n> this print_feed_meta(), was much easier to follow, at least for me. The\n> association between \"feed-meta\" and \"200 OK\" was close together and more\n> direct.\n\nHmmm... perhaps then I should have gone with my first thought, namely\npassing $status to print_header_links().  \n\nWill resend.\n\n\nNote that in case of print_nav_breadcrumbs() the code used %opts\noriginally, so it is only passed from git_header_html...\n\n> > ...\n> > -\t\t}\n> > -\t}\n> > -\tprint_feed_meta()\n> > -\t\tif ($status eq '200 OK');\n> \n> Other than that, this looks a correct no-op patch that makes the resulting\n> smaller functions easier to grok.\n\nThanks. \n\n-- \nJakub Narebski\nPoland\n"},{"id":"170461","messageId":"201106221350.47314.jnareb@gmail.com","threadId":"27675","inReplyTo":"201106220844.35431.jnareb@gmail.com","subject":"[PATCHv2] gitweb: Refactor git_header_html","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-22T11:50:46Z","receivedAt":"2011-06-22T11:50:46Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Extract (factor out) the following parts into separate subroutines:\n* finding correct MIME content type for HTML pages (text/html or\n  application/xhtml+xml?) into get_content_type_html()\n* printing <link ...> elements in HTML head into print_header_links()\n* printing navigation \"breadcrumbs\" for given action into\n  print_nav_breadcrumbs()\n* printing search form into print_search_form()\n\nThis reduces git_header_html to two pages long (53 lines), making\ngitweb code easier to read.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nJakub Narebski wrote:\n\n> Hmmm... perhaps then I should have gone with my first thought, namely\n> passing $status to print_header_links().  \n> \n> Will resend.\n\nAnd here it is...\n\nInterdiff:\n~~~~~~~~~~\n\n  diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n  index c9e6426..0221eb9 100755\n  --- a/gitweb/gitweb.perl\n  +++ b/gitweb/gitweb.perl\n  @@ -3753,7 +3753,7 @@ sub print_feed_meta {\n   }\n   \n   sub print_header_links {\n  -\tmy %opts = @_;\n  +\tmy $status = shift;\n   \n   \t# print out each stylesheet that exist, providing backwards capability\n   \t# for those people who defined $stylesheet in a config file\n  @@ -3765,9 +3765,8 @@ sub print_header_links {\n   \t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n   \t\t}\n   \t}\n  -\tif ($opts{'-feed'}) {\n  -\t\tprint_feed_meta();\n  -\t}\n  +\tprint_feed_meta()\n  +\t\tif ($status eq '200 OK');\n   \tif (defined $favicon) {\n   \t\tprint qq(<link rel=\"shortcut icon\" href=\").esc_url($favicon).qq(\" type=\"image/png\" />\\n);\n   \t}\n  @@ -3858,7 +3857,7 @@ EOF\n   \tif ($ENV{'PATH_INFO'}) {\n   \t\tprint \"<base href=\\\"\".esc_url($base_url).\"\\\" />\\n\";\n   \t}\n  -\tprint_header_links(-feed => $status eq '200 OK');\n  +\tprint_header_links($status);\n   \tprint \"</head>\\n\" .\n   \t      \"<body>\\n\";\n   \n\n\n gitweb/gitweb.perl |  172 +++++++++++++++++++++++++++++-----------------------\n 1 files changed, 95 insertions(+), 77 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f13b4b5..0221eb9 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3693,6 +3693,20 @@ sub get_page_title {\n \treturn $title;\n }\n \n+sub get_content_type_html {\n+\t# require explicit support from the UA if we are to send the page as\n+\t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n+\t# we have to do this because MSIE sometimes globs '*/*', pretending to\n+\t# support xhtml+xml but choking when it gets what it asked for.\n+\tif (defined $cgi->http('HTTP_ACCEPT') &&\n+\t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n+\t    $cgi->Accept('application/xhtml+xml') != 0) {\n+\t\treturn 'application/xhtml+xml';\n+\t} else {\n+\t\treturn 'text/html';\n+\t}\n+}\n+\n sub print_feed_meta {\n \tif (defined $project) {\n \t\tmy %href_params = get_feed_info();\n@@ -3738,24 +3752,90 @@ sub print_feed_meta {\n \t}\n }\n \n+sub print_header_links {\n+\tmy $status = shift;\n+\n+\t# print out each stylesheet that exist, providing backwards capability\n+\t# for those people who defined $stylesheet in a config file\n+\tif (defined $stylesheet) {\n+\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n+\t} else {\n+\t\tforeach my $stylesheet (@stylesheets) {\n+\t\t\tnext unless $stylesheet;\n+\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n+\t\t}\n+\t}\n+\tprint_feed_meta()\n+\t\tif ($status eq '200 OK');\n+\tif (defined $favicon) {\n+\t\tprint qq(<link rel=\"shortcut icon\" href=\").esc_url($favicon).qq(\" type=\"image/png\" />\\n);\n+\t}\n+}\n+\n+sub print_nav_breadcrumbs {\n+\tmy %opts = @_;\n+\n+\tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n+\tif (defined $project) {\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tif (defined $action) {\n+\t\t\tmy $action_print = $action ;\n+\t\t\tif (defined $opts{-action_extra}) {\n+\t\t\t\t$action_print = $cgi->a({-href => href(action=>$action)},\n+\t\t\t\t\t$action);\n+\t\t\t}\n+\t\t\tprint \" / $action_print\";\n+\t\t}\n+\t\tif (defined $opts{-action_extra}) {\n+\t\t\tprint \" / $opts{-action_extra}\";\n+\t\t}\n+\t\tprint \"\\n\";\n+\t}\n+}\n+\n+sub print_search_form {\n+\tif (!defined $searchtext) {\n+\t\t$searchtext = \"\";\n+\t}\n+\tmy $search_hash;\n+\tif (defined $hash_base) {\n+\t\t$search_hash = $hash_base;\n+\t} elsif (defined $hash) {\n+\t\t$search_hash = $hash;\n+\t} else {\n+\t\t$search_hash = \"HEAD\";\n+\t}\n+\tmy $action = $my_uri;\n+\tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n+\tif ($use_pathinfo) {\n+\t\t$action .= \"/\".esc_url($project);\n+\t}\n+\tprint $cgi->startform(-method => \"get\", -action => $action) .\n+\t      \"<div class=\\\"search\\\">\\n\" .\n+\t      (!$use_pathinfo &&\n+\t      $cgi->input({-name=>\"p\", -value=>$project, -type=>\"hidden\"}) . \"\\n\") .\n+\t      $cgi->input({-name=>\"a\", -value=>\"search\", -type=>\"hidden\"}) . \"\\n\" .\n+\t      $cgi->input({-name=>\"h\", -value=>$search_hash, -type=>\"hidden\"}) . \"\\n\" .\n+\t      $cgi->popup_menu(-name => 'st', -default => 'commit',\n+\t                       -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .\n+\t      $cgi->sup($cgi->a({-href => href(action=>\"search_help\")}, \"?\")) .\n+\t      \" search:\\n\",\n+\t      $cgi->textfield(-name => \"s\", -value => $searchtext) . \"\\n\" .\n+\t      \"<span title=\\\"Extended regular expression\\\">\" .\n+\t      $cgi->checkbox(-name => 'sr', -value => 1, -label => 're',\n+\t                     -checked => $search_use_regexp) .\n+\t      \"</span>\" .\n+\t      \"</div>\" .\n+\t      $cgi->end_form() . \"\\n\";\n+}\n+\n sub git_header_html {\n \tmy $status = shift || \"200 OK\";\n \tmy $expires = shift;\n \tmy %opts = @_;\n \n \tmy $title = get_page_title();\n-\tmy $content_type;\n-\t# require explicit support from the UA if we are to send the page as\n-\t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n-\t# we have to do this because MSIE sometimes globs '*/*', pretending to\n-\t# support xhtml+xml but choking when it gets what it asked for.\n-\tif (defined $cgi->http('HTTP_ACCEPT') &&\n-\t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n-\t    $cgi->Accept('application/xhtml+xml') != 0) {\n-\t\t$content_type = 'application/xhtml+xml';\n-\t} else {\n-\t\t$content_type = 'text/html';\n-\t}\n+\tmy $content_type = get_content_type_html();\n \tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n \t                   -status=> $status, -expires => $expires)\n \t\tunless ($opts{'-no_http_header'});\n@@ -3777,22 +3857,7 @@ EOF\n \tif ($ENV{'PATH_INFO'}) {\n \t\tprint \"<base href=\\\"\".esc_url($base_url).\"\\\" />\\n\";\n \t}\n-\t# print out each stylesheet that exist, providing backwards capability\n-\t# for those people who defined $stylesheet in a config file\n-\tif (defined $stylesheet) {\n-\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n-\t} else {\n-\t\tforeach my $stylesheet (@stylesheets) {\n-\t\t\tnext unless $stylesheet;\n-\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.esc_url($stylesheet).'\"/>'.\"\\n\";\n-\t\t}\n-\t}\n-\tprint_feed_meta()\n-\t\tif ($status eq '200 OK');\n-\tif (defined $favicon) {\n-\t\tprint qq(<link rel=\"shortcut icon\" href=\").esc_url($favicon).qq(\" type=\"image/png\" />\\n);\n-\t}\n-\n+\tprint_header_links($status);\n \tprint \"</head>\\n\" .\n \t      \"<body>\\n\";\n \n@@ -3809,59 +3874,12 @@ EOF\n \t\t                         -alt => \"git\",\n \t\t                         -class => \"logo\"}));\n \t}\n-\tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n-\tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n-\t\tif (defined $action) {\n-\t\t\tmy $action_print = $action ;\n-\t\t\tif (defined $opts{-action_extra}) {\n-\t\t\t\t$action_print = $cgi->a({-href => href(action=>$action)},\n-\t\t\t\t\t$action);\n-\t\t\t}\n-\t\t\tprint \" / $action_print\";\n-\t\t}\n-\t\tif (defined $opts{-action_extra}) {\n-\t\t\tprint \" / $opts{-action_extra}\";\n-\t\t}\n-\t\tprint \"\\n\";\n-\t}\n+\tprint_nav_breadcrumbs(%opts);\n \tprint \"</div>\\n\";\n \n \tmy $have_search = gitweb_check_feature('search');\n \tif (defined $project && $have_search) {\n-\t\tif (!defined $searchtext) {\n-\t\t\t$searchtext = \"\";\n-\t\t}\n-\t\tmy $search_hash;\n-\t\tif (defined $hash_base) {\n-\t\t\t$search_hash = $hash_base;\n-\t\t} elsif (defined $hash) {\n-\t\t\t$search_hash = $hash;\n-\t\t} else {\n-\t\t\t$search_hash = \"HEAD\";\n-\t\t}\n-\t\tmy $action = $my_uri;\n-\t\tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n-\t\tif ($use_pathinfo) {\n-\t\t\t$action .= \"/\".esc_url($project);\n-\t\t}\n-\t\tprint $cgi->startform(-method => \"get\", -action => $action) .\n-\t\t      \"<div class=\\\"search\\\">\\n\" .\n-\t\t      (!$use_pathinfo &&\n-\t\t      $cgi->input({-name=>\"p\", -value=>$project, -type=>\"hidden\"}) . \"\\n\") .\n-\t\t      $cgi->input({-name=>\"a\", -value=>\"search\", -type=>\"hidden\"}) . \"\\n\" .\n-\t\t      $cgi->input({-name=>\"h\", -value=>$search_hash, -type=>\"hidden\"}) . \"\\n\" .\n-\t\t      $cgi->popup_menu(-name => 'st', -default => 'commit',\n-\t\t                       -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .\n-\t\t      $cgi->sup($cgi->a({-href => href(action=>\"search_help\")}, \"?\")) .\n-\t\t      \" search:\\n\",\n-\t\t      $cgi->textfield(-name => \"s\", -value => $searchtext) . \"\\n\" .\n-\t\t      \"<span title=\\\"Extended regular expression\\\">\" .\n-\t\t      $cgi->checkbox(-name => 'sr', -value => 1, -label => 're',\n-\t\t                     -checked => $search_use_regexp) .\n-\t\t      \"</span>\" .\n-\t\t      \"</div>\" .\n-\t\t      $cgi->end_form() . \"\\n\";\n+\t\tprint_search_form();\n \t}\n }\n \n-- \n1.7.5\n"}]}