git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 4/3] gitweb: Use here-doc
Date: Tue, 22 Aug 2006 23:42:53 +0200	[thread overview]
Message-ID: <200608222342.53861.jnareb@gmail.com> (raw)
In-Reply-To: <200608221651.19629.jnareb@gmail.com>

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This patch uses undocumented, at least in perlop(1), trick in
interpolation that allows calling function from interpolated string,
using ${\subroutine_name(parameters...)}, found in git_blame,
and used in git_rss here-doc in this patch.

This patch is part of "[PATCH 0/3] gitweb: Yet another cleanup series"
series.

 gitweb/gitweb.perl |   75 
+++++++++++++++++++++++++++++++---------------------
 1 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e09204d..5301213 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1185,11 +1185,13 @@ sub die_error {
 	my $error = shift || "Malformed query, file missing or permission 
denied";
 
 	git_header_html($status);
-	print "<div class=\"page_body\">\n" .
-	      "<br/><br/>\n" .
-	      "$status - $error\n" .
-	      "<br/>\n" .
-	      "</div>\n";
+	print <<EOF;
+<div class="page_body">
+<br /><br />
+$status - $error
+<br />
+</div>
+EOF
 	git_footer_html();
 	exit;
 }
@@ -2026,9 +2028,11 @@ sub git_blame2 {
 	my $num_colors = scalar(@rev_color);
 	my $current_color = 0;
 	my $last_rev;
-	print "<div class=\"page_body\">\n";
-	print "<table class=\"blame\">\n";
-	print "<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\n";
+	print <<HTML;
+<div class="page_body">
+<table class="blame">
+<tr><th>Commit</th><th>Line</th><th>Data</th></tr>
+HTML
 	while (<$fd>) {
 		/^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
 		my $full_rev = $1;
@@ -2570,9 +2574,10 @@ sub git_blobdiff {
 		git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, 
$formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
 	} else {
-		print "<div class=\"page_nav\">\n" .
-		      "<br/><br/></div>\n" .
-		      "<div class=\"title\">$hash vs $hash_parent</div>\n";
+		print <<HTML;
+<div class="page_nav"><br/><br/></div>
+<div class="title">$hash vs $hash_parent</div>
+HTML
 	}
 	git_print_page_path($file_name, "blob", $hash_base);
 	print "<div class=\"page_body\">\n" .
@@ -2708,9 +2713,11 @@ sub git_commitdiff_plain {
 	                   -content_disposition => "inline; 
filename=\"git-$hash.patch\"");
 	my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
 	my $comment = $co{'comment'};
-	print "From: $co{'author'}\n" .
-	      "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
-	      "Subject: $co{'title'}\n";
+	print <<TEXT;
+From: $co{'author'}
+Date: $ad{'rfc2822'} ($ad{'tz_local'})
+Subject: $co{'title'}
+TEXT
 	if (defined $tagname) {
 		print "X-Git-Tag: $tagname\n";
 	}
@@ -2995,13 +3002,15 @@ sub git_rss {
 	my @revlist = map { chomp; $_ } <$fd>;
 	close $fd or die_error(undef, "Reading git-rev-list failed");
 	print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
-	print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
-	      "<rss version=\"2.0\" 
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
-	print "<channel>\n";
-	print "<title>$project</title>\n".
-	      "<link>" . esc_html("$my_url?p=$project;a=summary") . 
"</link>\n".
-	      "<description>$project log</description>\n".
-	      "<language>en</language>\n";
+	print <<XML;
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0" 
xmlns:content="http://purl.org/rss/1.0/modules/content/">
+<channel>
+<title>$project $my_uri $my_url</title>
+<link>${\esc_html("$my_url?p=$project;a=summary")}</link>
+<description>$project log</description>
+<language>en</language>
+XML
 
 	for (my $i = 0; $i <= $#revlist; $i++) {
 		my $commit = $revlist[$i];
@@ -3050,13 +3059,15 @@ sub git_opml {
 	my @list = git_get_projects_list();
 
 	print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
-	print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
-	      "<opml version=\"1.0\">\n".
-	      "<head>".
-	      "  <title>$site_name Git OPML Export</title>\n".
-	      "</head>\n".
-	      "<body>\n".
-	      "<outline text=\"git RSS feeds\">\n";
+	print <<XML;
+<?xml version="1.0" encoding="utf-8"?>
+<opml version="1.0">
+<head>
+  <title>$site_name Git OPML Export</title>
+</head>
+<body>
+<outline text="git RSS feeds">
+XML
 
 	foreach my $pr (@list) {
 		my %proj = %$pr;
@@ -3075,7 +3086,9 @@ sub git_opml {
 		my $html = "$my_url?p=$proj{'path'};a=summary";
 		print "<outline type=\"rss\" text=\"$path\" title=\"$path\" 
xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
 	}
-	print "</outline>\n".
-	      "</body>\n".
-	      "</opml>\n";
+	print <<XML;
+</outline>
+</body>
+</opml>
+XML
 }
-- 
1.4.1.1

  parent reply	other threads:[~2006-08-22 21:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-22 14:51 [PATCH 0/3] gitweb: Yet another cleanup series Jakub Narebski
2006-08-22 14:52 ` [PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent Jakub Narebski
2006-08-23  1:34   ` Junio C Hamano
2006-08-23  8:55     ` Jakub Narebski
2006-08-23  9:07       ` Andreas Ericsson
2006-08-23  9:55       ` Junio C Hamano
2006-08-22 14:55 ` [PATCH 2/3] gitweb: Use underscore instead of hyphen to separate words in HTTP headers names Jakub Narebski
2006-08-22 14:59 ` [PATCH 3/3] gitweb: Route rest of action subroutines through %actions Jakub Narebski
2006-08-22 15:03 ` [PATCH 0/3] gitweb: Yet another cleanup series Jakub Narebski
2006-08-22 21:42 ` Jakub Narebski [this message]
2006-08-22 21:54   ` [PATCH 4/3] gitweb: Use here-doc Jakub Narebski
2006-08-23  1:34   ` Junio C Hamano

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=200608222342.53861.jnareb@gmail.com \
    --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).