aboutsummaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorJakub Narebski <jnareb@gmail.com>2010-04-24 16:01:10 +0200
committerJunio C Hamano <gitster@pobox.com>2010-05-01 12:10:05 -0700
commitefb2d0c5dcea1069bae2d26c9534e2025ee63e66 (patch)
treed5d89d3f8fd368c349b377d22e0c6f683dc60573 /gitweb
parent7a59745710e964f9498f37a3184bf95b9b4a772b (diff)
downloadgit-efb2d0c5dcea1069bae2d26c9534e2025ee63e66.tar.gz
git-efb2d0c5dcea1069bae2d26c9534e2025ee63e66.tar.xz
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 <jnareb@gmail.com> Acked-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.perl32
1 files changed, 19 insertions, 13 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e579c14b4..7d75dc4c8 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3179,24 +3179,30 @@ sub blob_contenttype {
## ======================================================================
## functions printing HTML: header, footer, error page
+sub get_page_title {
+ my $title = to_utf8($site_name);
+
+ return $title unless (defined $project);
+ $title .= " - " . to_utf8($project);
+
+ return $title unless (defined $action);
+ $title .= "/$action"; # $action is US-ASCII (7bit ASCII)
+
+ return $title unless (defined $file_name);
+ $title .= " - " . esc_path($file_name);
+ if ($action eq "tree" && $file_name !~ m|/$|) {
+ $title .= "/";
+ }
+
+ return $title;
+}
+
sub git_header_html {
my $status = shift || "200 OK";
my $expires = shift;
my %opts = @_;
- my $title = "$site_name";
- if (defined $project) {
- $title .= " - " . to_utf8($project);
- if (defined $action) {
- $title .= "/$action";
- if (defined $file_name) {
- $title .= " - " . esc_path($file_name);
- if ($action eq "tree" && $file_name !~ m|/$|) {
- $title .= "/";
- }
- }
- }
- }
+ my $title = get_page_title();
my $content_type;
# require explicit support from the UA if we are to send the page as
# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.