From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 5/5] gitweb: Move generating page title to separate subroutine
Date: Sat, 24 Apr 2010 16:01:10 +0200 [thread overview]
Message-ID: <20100424140019.30511.55366.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100424132255.30511.98829.stgit@localhost.localdomain>
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>
---
Refactoring.
gitweb/gitweb.perl | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e579c14..7d75dc4 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'.
next prev parent reply other threads:[~2010-04-24 14:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-24 13:46 [PATCH 0/5] gitweb: Miscellaneous improvements, in preparation for caching support Jakub Narebski
2010-04-24 13:50 ` [PATCH 1/5] Export more test-related variables when running external tests Jakub Narebski
2010-04-25 11:47 ` Jakub Narebski
2010-04-24 13:53 ` [PATCH 2/5] gitweb: href(..., -path_info => 0|1) Jakub Narebski
2010-04-24 13:56 ` [PATCH 3/5] gitweb: Use nonlocal jump instead of 'exit' in die_error Jakub Narebski
2010-05-04 11:39 ` Jakub Narebski
2010-04-24 14:00 ` [PATCH 4/5] gitweb: Add custom error handler using die_error Jakub Narebski
2010-04-24 14:01 ` Jakub Narebski [this message]
2010-04-25 9:20 ` [PATCH 0/5] gitweb: Miscellaneous improvements, in preparation for caching support Petr Baudis
2010-04-25 11:45 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100424140019.30511.55366.stgit@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).