From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 4/7] gitweb: Expand href() function to use key as param name for no mapping
Date: Thu, 17 Aug 2006 11:21:25 +0200 [thread overview]
Message-ID: <11558064893139-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <11558064883957-git-send-email-jnareb@gmail.com>
Expand href() function to use key name of params hash as a query param
name, if there is no mapping for given key name.
It is now safer to use href(); no errors, but links might not work
correctly if caller didn't provide correct arguments.
Future proofing.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 143 +++++++++++++++++++++++++++-------------------------
1 files changed, 73 insertions(+), 70 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 86266da..d37e7f1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -204,8 +204,13 @@ sub href(%) {
my $href = "$my_uri?";
$href .= esc_param( join(";",
- map { "$mapping{$_}=$params{$_}" } keys %params
- ) );
+ map {
+ if (exists $mapping{$_}) {
+ "$mapping{$_}=$params{$_}";
+ } else {
+ "$_=$params{$_}";
+ }
+ } keys %params ) );
return $href;
}
@@ -1174,66 +1179,6 @@ sub git_print_page_path {
}
}
-sub git_print_log {
- my $log = shift;
-
- # remove leading empty lines
- while (defined $log->[0] && $log->[0] eq "") {
- shift @$log;
- }
-
- # print log
- my $signoff = 0;
- my $empty = 0;
- foreach my $line (@$log) {
- # print only one empty line
- # do not print empty line after signoff
- if ($line eq "") {
- next if ($empty || $signoff);
- $empty = 1;
- } else {
- $empty = 0;
- }
- if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
- $signoff = 1;
- print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
- } else {
- $signoff = 0;
- print format_log_line_html($line) . "<br/>\n";
- }
- }
-}
-
-sub git_print_simplified_log {
- my $log = shift;
- my $remove_title = shift;
-
- shift @$log if $remove_title;
- # remove leading empty lines
- while (defined $log->[0] && $log->[0] eq "") {
- shift @$log;
- }
-
- # simplify and print log
- my $empty = 0;
- foreach my $line (@$log) {
- # remove signoff lines
- if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
- next;
- }
- # print only one empty line
- if ($line eq "") {
- next if $empty;
- $empty = 1;
- } else {
- $empty = 0;
- }
- print format_log_line_html($line) . "<br/>\n";
- }
- # end with single empty line
- print "<br/>\n" unless $empty;
-}
-
## ......................................................................
## functions printing large fragments of HTML
@@ -1322,7 +1267,7 @@ sub git_difftree_body {
"<td class=\"link\">" .
$cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, "blob");
if ($to_id ne $from_id) { # modified
- print " | " . $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
+ print $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
}
print " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash, file_name=>$file)}, "history") . "\n";
print "</td>\n";
@@ -2215,10 +2160,27 @@ sub git_log {
"<br/>\n" .
"</div>\n" .
"<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
- "</div>\n";
-
- print "<div class=\"log_body\">\n";
- git_print_simplified_log($co{'comment'});
+ "</div>\n" .
+ "<div class=\"log_body\">\n";
+ my $comment = $co{'comment'};
+ my $empty = 0;
+ foreach my $line (@$comment) {
+ if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+ next;
+ }
+ if ($line eq "") {
+ if ($empty) {
+ next;
+ }
+ $empty = 1;
+ } else {
+ $empty = 0;
+ }
+ print format_log_line_html($line) . "<br/>\n";
+ }
+ if (!$empty) {
+ print "<br/>\n";
+ }
print "</div>\n";
}
git_footer_html();
@@ -2299,9 +2261,28 @@ sub git_commit {
}
print "</table>".
"</div>\n";
-
print "<div class=\"page_body\">\n";
- git_print_log($co{'comment'});
+ my $comment = $co{'comment'};
+ my $empty = 0;
+ my $signed = 0;
+ foreach my $line (@$comment) {
+ # print only one empty line
+ if ($line eq "") {
+ if ($empty || $signed) {
+ next;
+ }
+ $empty = 1;
+ } else {
+ $empty = 0;
+ }
+ if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+ $signed = 1;
+ print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
+ } else {
+ $signed = 0;
+ print format_log_line_html($line) . "<br/>\n";
+ }
+ }
print "</div>\n";
git_difftree_body(\@difftree, $parent);
@@ -2367,7 +2348,29 @@ sub git_commitdiff {
git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
print "<div class=\"page_body\">\n";
- git_print_simplified_log($co{'comment'}, 1); # skip title
+ my $comment = $co{'comment'};
+ my $empty = 0;
+ my $signed = 0;
+ my @log = @$comment;
+ # remove first and empty lines after that
+ shift @log;
+ while (defined $log[0] && $log[0] eq "") {
+ shift @log;
+ }
+ foreach my $line (@log) {
+ if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+ next;
+ }
+ if ($line eq "") {
+ if ($empty) {
+ next;
+ }
+ $empty = 1;
+ } else {
+ $empty = 0;
+ }
+ print format_log_line_html($line) . "<br/>\n";
+ }
print "<br/>\n";
foreach my $line (@difftree) {
# ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
--
1.4.1.1
next prev parent reply other threads:[~2006-08-17 9:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-17 9:21 [PATCH 0/7] A few gitweb cleanups and improvements Jakub Narebski
2006-08-17 9:21 ` [PATCH 1/7] gitweb: Add support for per project git URLs Jakub Narebski
2006-08-17 18:58 ` David Rientjes
2006-08-17 9:21 ` [PATCH 2/7] gitweb: Refactor printing commit message Jakub Narebski
2006-08-17 9:21 ` [PATCH 3/7] gitweb: Fix typo in separation of git_difftree_body Jakub Narebski
2006-08-17 9:21 ` Jakub Narebski [this message]
2006-08-17 9:58 ` [PATCH 4/7] gitweb: Expand href() function to use key as param name for no mapping Junio C Hamano
2006-08-17 10:08 ` Jakub Narebski
2006-08-17 9:21 ` [PATCH 5/7] gitweb: Added parse_difftree_raw_line function for later use Jakub Narebski
2006-08-17 9:55 ` Junio C Hamano
2006-08-17 9:21 ` [PATCH 6/7] gitweb: Sort query string parameters in href() function Jakub Narebski
2006-08-17 9:21 ` [PATCH 7/7] gitweb: Uniquify version info output, add meta generator in page header 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=11558064893139-git-send-email-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).