Skip to content

Commit efb2d0c

Browse files
jnarebgitster
authored andcommitted
gitweb: Move generating page title to separate subroutine
get_page_title subroutine is currently used only in git_header_html. Nevertheless refactoring title generation allowed to reduce indent level. It would be used in more than one callsite in the patch adding caching activity indicator to gitweb. Signed-off-by: Jakub Narebski <[email protected]> Acked-by: Petr Baudis <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7a59745 commit efb2d0c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

gitweb/gitweb.perl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,24 +3179,30 @@ sub blob_contenttype {
31793179
## ======================================================================
31803180
## functions printing HTML: header, footer, error page
31813181

3182+
sub get_page_title {
3183+
my $title = to_utf8($site_name);
3184+
3185+
return $title unless (defined $project);
3186+
$title .= " - " . to_utf8($project);
3187+
3188+
return $title unless (defined $action);
3189+
$title .= "/$action"; # $action is US-ASCII (7bit ASCII)
3190+
3191+
return $title unless (defined $file_name);
3192+
$title .= " - " . esc_path($file_name);
3193+
if ($action eq "tree" && $file_name !~ m|/$|) {
3194+
$title .= "/";
3195+
}
3196+
3197+
return $title;
3198+
}
3199+
31823200
sub git_header_html {
31833201
my $status = shift || "200 OK";
31843202
my $expires = shift;
31853203
my %opts = @_;
31863204

3187-
my $title = "$site_name";
3188-
if (defined $project) {
3189-
$title .= " - " . to_utf8($project);
3190-
if (defined $action) {
3191-
$title .= "/$action";
3192-
if (defined $file_name) {
3193-
$title .= " - " . esc_path($file_name);
3194-
if ($action eq "tree" && $file_name !~ m|/$|) {
3195-
$title .= "/";
3196-
}
3197-
}
3198-
}
3199-
}
3205+
my $title = get_page_title();
32003206
my $content_type;
32013207
# require explicit support from the UA if we are to send the page as
32023208
# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.

0 commit comments

Comments
 (0)