From aedd9425ce211d132f8671bc3d94623ab9595f02 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 17 Jun 2006 11:23:56 +0200 Subject: [PATCH 01/16] Move gitweb style to gitweb.css Move gitweb style from embedded EOF diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css new file mode 100644 index 0000000000..6b1fd23370 --- /dev/null +++ b/gitweb/gitweb.css @@ -0,0 +1,54 @@ +a { color:#0000cc; } +a:hover, a:visited, a:active { color:#880000; } +div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } +div.page_header a:visited, a.header { color:#0000cc; } +div.page_header a:hover { color:#880000; } +div.page_nav { padding:8px; } +div.page_nav a:visited { color:#0000cc; } +div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} +div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; } +div.page_footer_text { float:left; color:#555555; font-style:italic; } +div.page_body { padding:8px; } +div.title, a.title { + display:block; padding:6px 8px; + font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; +} +a.title:hover { background-color: #d9d8d1; } +div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; } +div.log_body { padding:8px 8px 8px 150px; } +span.age { position:relative; float:left; width:142px; font-style:italic; } +div.log_link { + padding:0px 8px; + font-size:10px; font-family:sans-serif; font-style:normal; + position:relative; float:left; width:136px; +} +div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } +a.list { text-decoration:none; color:#000000; } +a.list:hover { text-decoration:underline; color:#880000; } +a.text { text-decoration:none; color:#0000cc; } +a.text:visited { text-decoration:none; color:#880000; } +a.text:hover { text-decoration:underline; color:#880000; } +table { padding:8px 4px; } +th { padding:2px 5px; font-size:12px; text-align:left; } +tr.light:hover { background-color:#edece6; } +tr.dark { background-color:#f6f6f0; } +tr.dark:hover { background-color:#edece6; } +td { padding:2px 5px; font-size:12px; vertical-align:top; } +td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } +div.pre { font-family:monospace; font-size:12px; white-space:pre; } +div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } +div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } +div.search { margin:4px 8px; position:absolute; top:56px; right:12px } +a.linenr { color:#999999; text-decoration:none } +a.rss_logo { + float:right; padding:3px 0px; width:35px; line-height:10px; + border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; + color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; font-size:10px; + text-align:center; text-decoration:none; +} +a.rss_logo:hover { background-color:#ee5500; } +span.tag { + padding:0px 4px; font-size:10px; font-weight:normal; + background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc; +} From f5aa79d909f8c4838bf500c22fa5f7967d219925 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 17 Jun 2006 13:32:15 +0200 Subject: [PATCH 02/16] gitweb: safely output binary files for 'blob_plain' action gitweb tries now to output correct Content-Type header for 'blob_plain' action; for now text/plain for text files, appropriate image MIME type for *.png, *.gif and *.jpg/*.jpeg files, and application/octet-stream for other binary files. Introduced new configuration variables: $default_blob_plain_mimetype and $default_text_plain_charset (only 'utf-8' is guaranteed to work for the latter). binmode changed to ':raw' in git_blob_plain for output of non-text files. Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 736d1068d2..b61b6ccbe6 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -39,12 +39,16 @@ my $home_link = $my_uri; my $home_text = "indextext.html"; # URI of default stylesheet -my $stylesheet = "gitweb.css"; +my $stylesheet = "gitweb.css"; # source of projects list #my $projects_list = $projectroot; my $projects_list = "index/index.aux"; +# default blob_plain mimetype and default charset for text/plain blob +my $default_blob_plain_mimetype = 'text/plain'; +my $default_text_plain_charset = 'utf-8'; # can be undefined + # input validation and dispatch my $action = $cgi->param('a'); if (defined $action) { @@ -1482,15 +1486,46 @@ sub git_blob { git_footer_html(); } +sub git_blob_plain_mimetype { + my $fd = shift; + my $filename = shift; + + # just in case + return $default_blob_plain_mimetype unless $fd; + + if (-T $fd) { + return 'text/plain' . + ($default_text_plain_charset ? '; charset='.$default_text_plain_charset : ''); + } elsif (! $filename) { + return 'application/octet-stream'; + } elsif ($filename =~ m/\.png$/i) { + return 'image/png'; + } elsif ($filename =~ m/\.gif$/i) { + return 'image/gif'; + } elsif ($filename =~ m/\.jpe?g$/i) { + return 'image/jpeg'; + } else { + return 'application/octet-stream'; + } +} + sub git_blob_plain { - my $save_as = "$hash.txt"; + open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return; + my $type = git_blob_plain_mimetype($fd, $file_name); + + # save as filename, even when no $file_name is given + my $save_as = "$hash"; if (defined $file_name) { $save_as = $file_name; + } elsif ($type =~ m/^text\//) { + $save_as .= '.txt'; } - print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"$save_as\""); - open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return; + + print $cgi->header(-type => "$type", '-content-disposition' => "inline; filename=\"$save_as\""); undef $/; + binmode STDOUT, ':raw' unless $type =~ m/^text\//; print <$fd>; + binmode STDOUT, ':utf8' unless $type =~ m/^text\//; $/ = "\n"; close $fd; } From ad14e9317513f132293406e570f0b9360704371e Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 17 Jun 2006 18:07:24 +0200 Subject: [PATCH 03/16] gitweb: text files for 'blob_plain' action without charset by default $default_text_plain_charset is undefined (no specified charset) by default. Additionally ':raw' layer for binmode is used for outputting file content. Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index b61b6ccbe6..8fde1c8833 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -47,7 +47,7 @@ my $projects_list = "index/index.aux"; # default blob_plain mimetype and default charset for text/plain blob my $default_blob_plain_mimetype = 'text/plain'; -my $default_text_plain_charset = 'utf-8'; # can be undefined +my $default_text_plain_charset = undef; # input validation and dispatch my $action = $cgi->param('a'); @@ -1523,9 +1523,9 @@ sub git_blob_plain { print $cgi->header(-type => "$type", '-content-disposition' => "inline; filename=\"$save_as\""); undef $/; - binmode STDOUT, ':raw' unless $type =~ m/^text\//; + binmode STDOUT, ':raw'; print <$fd>; - binmode STDOUT, ':utf8' unless $type =~ m/^text\//; + binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi $/ = "\n"; close $fd; } From 2d00737489b8c61ed616b261c7c9bd314e2b0b41 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 18 Jun 2006 00:01:06 +0200 Subject: [PATCH 04/16] Support for the standard mime.types map in gitweb gitweb will try to look up the filename mimetype in /etc/mime.types and optionally a user-configured mime.types map as well. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 8fde1c8833..fa90c51a4d 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -49,6 +49,11 @@ my $projects_list = "index/index.aux"; my $default_blob_plain_mimetype = 'text/plain'; my $default_text_plain_charset = undef; +# file to use for guessing MIME types before trying /etc/mime.types +# (relative to the current git repository) +my $mimetypes_file = undef; + + # input validation and dispatch my $action = $cgi->param('a'); if (defined $action) { @@ -1486,6 +1491,40 @@ sub git_blob { git_footer_html(); } +sub mimetype_guess_file { + my $filename = shift; + my $mimemap = shift; + -r $mimemap or return undef; + + my %mimemap; + open(MIME, $mimemap) or return undef; + while () { + my ($mime, $exts) = split(/\t+/); + my @exts = split(/\s+/, $exts); + foreach my $ext (@exts) { + $mimemap{$ext} = $mime; + } + } + close(MIME); + + $filename =~ /\.(.*?)$/; + return $mimemap{$1}; +} + +sub mimetype_guess { + my $filename = shift; + my $mime; + $filename =~ /\./ or return undef; + + if ($mimetypes_file) { + my $file = $mimetypes_file; + $file =~ m#^/# or $file = "$projectroot/$path/$file"; + $mime = mimetype_guess_file($filename, $file); + } + $mime ||= mimetype_guess_file($filename, '/etc/mime.types'); + return $mime; +} + sub git_blob_plain_mimetype { my $fd = shift; my $filename = shift; @@ -1493,6 +1532,11 @@ sub git_blob_plain_mimetype { # just in case return $default_blob_plain_mimetype unless $fd; + if ($filename) { + my $mime = mimetype_guess($filename); + $mime and return $mime; + } + if (-T $fd) { return 'text/plain' . ($default_text_plain_charset ? '; charset='.$default_text_plain_charset : ''); From c729127ca745d25df1e6bddb265d03166931f49a Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 17 Jun 2006 23:45:03 -0700 Subject: [PATCH 05/16] Fix gitweb stylesheet An earlier commit forgot to move some piece from the CGI script to the external stylesheet. Signed-off-by: Junio C Hamano --- gitweb/gitweb.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index 6b1fd23370..bf95e38496 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -1,3 +1,7 @@ +body { + font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; + margin:10px; background-color:#ffffff; color:#000000; +} a { color:#0000cc; } a:hover, a:visited, a:active { color:#880000; } div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } From 75c84ddb468a87006eaaa894cccf1a279a579406 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 19 Jun 2006 20:27:59 +0200 Subject: [PATCH 06/16] Make CSS file gitweb/gitweb.css more readable Taken from git://git.xmms.se/xmms2/gitweb-xmms2.git commit 561262030d58a6325f500b36d836dbe02a5abc68 "Make CSS readable" by Daniel Svensson, with extra parts removed and consistent whitespace usage. [jc: tabified the results to cleaning things up, and removed an added item that was commented out. ] Signed-off-by: Junio C Hamano --- gitweb/gitweb.css | 272 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 222 insertions(+), 50 deletions(-) diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index bf95e38496..4378067d3c 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -1,58 +1,230 @@ body { - font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; - margin:10px; background-color:#ffffff; color:#000000; -} -a { color:#0000cc; } -a:hover, a:visited, a:active { color:#880000; } -div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } -div.page_header a:visited, a.header { color:#0000cc; } -div.page_header a:hover { color:#880000; } -div.page_nav { padding:8px; } -div.page_nav a:visited { color:#0000cc; } -div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} -div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; } -div.page_footer_text { float:left; color:#555555; font-style:italic; } -div.page_body { padding:8px; } + font-family: sans-serif; + font-size: 12px; + border:solid #d9d8d1; + border-width: 1px; + margin: 10px; + background-color: #ffffff; + color: #000000; +} + +a { + color: #0000cc; +} + +a:hover, a:visited, a:active { + color: #880000; +} + +div.page_header { + height: 25px; + padding: 8px; + font-size: 18px; + font-weight: bold; + background-color: #d9d8d1; +} + +div.page_header a:visited, a.header { + color: #0000cc; +} + +div.page_header a:hover { + color: #880000; +} + +div.page_nav { + padding:8px; +} + +div.page_nav a:visited { + color: #0000cc; +} + +div.page_path { + padding: 8px; + border: solid #d9d8d1; + border-width: 0px 0px 1px; +} + +div.page_footer { + height: 17px; + padding: 4px 8px; + background-color: #d9d8d1; +} + +div.page_footer_text { + float: left; + color: #555555; + font-style: italic; +} + +div.page_body { + padding: 8px; +} + div.title, a.title { - display:block; padding:6px 8px; - font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; + display: block; + padding: 6px 8px; + font-weight: bold; + background-color: #edece6; + text-decoration: none; + color: #000000; +} + +a.title:hover { + background-color: #d9d8d1; +} + +div.title_text { + padding: 6px 0px; + border: solid #d9d8d1; + border-width: 0px 0px 1px; } -a.title:hover { background-color: #d9d8d1; } -div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; } -div.log_body { padding:8px 8px 8px 150px; } -span.age { position:relative; float:left; width:142px; font-style:italic; } + +div.log_body { + padding: 8px 8px 8px 150px; +} + +span.age { + position: relative; + float: left; + width: 142px; + font-style:italic; +} + div.log_link { - padding:0px 8px; - font-size:10px; font-family:sans-serif; font-style:normal; - position:relative; float:left; width:136px; -} -div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } -a.list { text-decoration:none; color:#000000; } -a.list:hover { text-decoration:underline; color:#880000; } -a.text { text-decoration:none; color:#0000cc; } -a.text:visited { text-decoration:none; color:#880000; } -a.text:hover { text-decoration:underline; color:#880000; } -table { padding:8px 4px; } -th { padding:2px 5px; font-size:12px; text-align:left; } -tr.light:hover { background-color:#edece6; } -tr.dark { background-color:#f6f6f0; } -tr.dark:hover { background-color:#edece6; } -td { padding:2px 5px; font-size:12px; vertical-align:top; } -td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } -div.pre { font-family:monospace; font-size:12px; white-space:pre; } -div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } -div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } -div.search { margin:4px 8px; position:absolute; top:56px; right:12px } -a.linenr { color:#999999; text-decoration:none } + padding: 0px 8px; + font-size: 10px; + font-family: sans-serif; + font-style:normal; + position: relative; + float: left; + width: 136px; +} + +div.list_head { + padding: 6px 8px 4px; + border: solid #d9d8d1; + border-width: 1px 0px 0px; + font-style: italic; +} + +a.list { + text-decoration: none; + color: #000000; +} + +a.list:hover { + text-decoration: underline; + color: #880000; +} + +a.text { + text-decoration: none; + color: #0000cc; +} + +a.text:visited { + text-decoration: none; + color: #880000; +} + +a.text:hover { + text-decoration: underline; + color: #880000; +} + +table { + padding: 8px 4px; +} + +th { + padding: 2px 5px; + font-size: 12px; + text-align: left; +} + +tr.light:hover { + background-color: #edece6; +} + +tr.dark { + background-color: #f6f6f0; +} + +tr.dark:hover { + background-color: #edece6; +} + + +td { + padding: 2px 5px; + font-size: 12px; + vertical-align:top; +} + +td.link { + padding: 2px 5px; + font-family: sans-serif; + font-size: 10px; +} + +div.pre { + font-family: monospace; + font-size: 12px; + white-space: pre; +} + +div.diff_info { + font-family: monospace; + color: #000099; + background-color: #edece6; + font-style: italic; +} + +div.index_include { + border: solid #d9d8d1; + border-width: 0px 0px 1px; + padding: 12px 8px; +} + +div.search { + margin: 4px 8px; + position: absolute; + top: 56px; + right: 12px +} + +a.linenr { + color: #999999; + text-decoration: none +} + a.rss_logo { - float:right; padding:3px 0px; width:35px; line-height:10px; - border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; - color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; font-size:10px; - text-align:center; text-decoration:none; + float: right; + padding: 3px 0px; + width: 35px; + line-height: 10px; + border: 1px solid; + border-color: #fcc7a5 #7d3302 #3e1a01 #ff954e; + color: #ffffff; + background-color: #ff6600; + font-weight: bold; + font-family: sans-serif; + font-size: 10px; + text-align: center; + text-decoration: none; +} + +a.rss_logo:hover { + background-color: #ee5500; } -a.rss_logo:hover { background-color:#ee5500; } + span.tag { - padding:0px 4px; font-size:10px; font-weight:normal; - background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc; + padding: 0px 4px; + font-size: 10px; + font-weight: normal; + background-color: #ffffaa; + border: 1px solid; + border-color: #ffffcc #ffee00 #ffee00 #ffffcc; } From 7b6511a13f9913a7a54e76b18e21c2b2bfae18cf Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Tue, 20 Jun 2006 04:11:32 +0000 Subject: [PATCH 07/16] gitweb: add type="text/css" to stylesheet link Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index fa90c51a4d..d7da6368ce 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -39,7 +39,7 @@ my $home_link = $my_uri; my $home_text = "indextext.html"; # URI of default stylesheet -my $stylesheet = "gitweb.css"; +my $stylesheet = "gitweb.css"; # source of projects list #my $projects_list = $projectroot; @@ -272,7 +272,7 @@ sub git_header_html { - + $title $rss_link From 57bd4d3523efecf60197040cad34154aff4ddf80 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Tue, 20 Jun 2006 06:19:31 +0000 Subject: [PATCH 08/16] Fix: Support for the standard mime.types map in gitweb Temporary fix: commented out offending line in mimetype_guess. Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index d7da6368ce..78e6dd0346 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -1518,7 +1518,7 @@ sub mimetype_guess { if ($mimetypes_file) { my $file = $mimetypes_file; - $file =~ m#^/# or $file = "$projectroot/$path/$file"; + #$file =~ m#^/# or $file = "$projectroot/$path/$file"; $mime = mimetype_guess_file($filename, $file); } $mime ||= mimetype_guess_file($filename, '/etc/mime.types'); From 7bedd9fc811df1fd865cebdae016f2f278501cc5 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Tue, 20 Jun 2006 06:17:03 +0000 Subject: [PATCH 09/16] gitweb: A couple of page title tweaking [jc: the e-mailed patch did not apply, so I had to guess but I think I got the result right.] --- gitweb/gitweb.cgi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 78e6dd0346..dd228bab4c 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -261,6 +261,12 @@ sub git_header_html { $title .= " - $project"; if (defined $action) { $title .= "/$action"; + if (defined $file_name) { + $title .= " - $file_name"; + if ($action eq "tree" && $file_name !~ m|/$|) { + $title .= "/"; + } + } } } print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status, -expires => $expires); From 1f1ab5f05b8e8b45545d8a406d64887f772a69da Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Tue, 20 Jun 2006 14:58:12 +0000 Subject: [PATCH 10/16] gitweb: style done with stylesheet Replace (almost) all 'style' attributes with 'class' attribute and adding rule to CSS file. Some tables use CSS for styling instead of legacy styling attributes. [jc: too many rejects -- hand fixed and reindented] --- gitweb/gitweb.cgi | 80 ++++++------ gitweb/gitweb.css | 320 +++++++++++++++++++++++++++++----------------- 2 files changed, 246 insertions(+), 154 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index dd228bab4c..44896bb300 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -252,6 +252,19 @@ sub unquote { return $str; } +# CSS class for given age value (in seconds) +sub age_class { + my $age = shift; + + if ($age < 60*60*2) { + return "age0"; + } elsif ($age < 60*60*24*2) { + return "age1"; + } else { + return "age2"; + } +} + sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; @@ -600,13 +613,13 @@ sub git_diff_print { while (my $line = <$fd>) { chomp($line); my $char = substr($line, 0, 1); - my $color = ""; + my $diff_class = ""; if ($char eq '+') { - $color = " style=\"color:#008800;\""; + $diff_class = " add"; } elsif ($char eq "-") { - $color = " style=\"color:#cc0000;\""; + $diff_class = " rem"; } elsif ($char eq "@") { - $color = " style=\"color:#990099;\""; + $diff_class = " chunk_header"; } elsif ($char eq "\\") { # skip errors next; @@ -617,7 +630,7 @@ sub git_diff_print { $line =~ s/\t/$spaces/; } } - print "
" . esc_html($line) . "
\n"; + print "
" . esc_html($line) . "
\n"; } } close $fd; @@ -849,7 +862,7 @@ sub git_project_list { close $fd; print "\n"; } - print "\n" . + print "
\n" . "\n"; if (!defined($order) || (defined($order) && ($order eq "project"))) { @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects; @@ -888,15 +901,7 @@ sub git_project_list { print "\n" . "\n" . "\n"; - my $colored_age; - if ($pr->{'commit'}{'age'} < 60*60*2) { - $colored_age = "$pr->{'commit'}{'age_string'}"; - } elsif ($pr->{'commit'}{'age'} < 60*60*24*2) { - $colored_age = "$pr->{'commit'}{'age_string'}"; - } else { - $colored_age = "$pr->{'commit'}{'age_string'}"; - } - print "\n" . + print "\n" . "" . "\n"; - my $parents = $co{'parents'}; + my $parents = $co{'parents'}; foreach my $par (@$parents) { print "" . "" .
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "$pr->{'descr'}" . chop_str($pr->{'owner'}, 15) . "$colored_age{'commit'}{'age'}) . "\">" . $pr->{'commit'}{'age_string'} . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary")}, "summary") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=shortlog")}, "shortlog") . @@ -1240,7 +1245,7 @@ sub git_blame { print "
" . esc_html($file_name) . "
\n"; print "
\n"; print < + @@ -1261,7 +1266,7 @@ HTML my $data; my $age; my $age_str; - my $age_style; + my $age_class; chomp $line; $line_class_num = ($line_class_num + 1) % $line_class_len; @@ -1273,16 +1278,14 @@ HTML $lineno = $4; $data = $5; } else { - print qq( \n); + print qq( \n); next; } $short_rev = substr ($long_rev, 0, 8); $age = time () - $time; $age_str = age_string ($age); $age_str =~ s/ / /g; - $age_style = 'font-style: italic;'; - $age_style .= ' color: #009900; background: transparent;' if ($age < 60*60*24*2); - $age_style .= ' font-weight: bold;' if ($age < 60*60*2); + $age_class = age_class($age); $author = esc_html ($author); $author =~ s/ / /g; # escape tabs @@ -1293,15 +1296,14 @@ HTML } } $data = esc_html ($data); - $data =~ s/ / /g; print < - - + + - - + + HTML } # while (my $line = <$fd>) @@ -1646,7 +1648,7 @@ sub git_tree { print "\n"; } $alternate ^= 1; - print "\n"; + print "\n"; if ($t_type eq "blob") { print "" . "\n"; print "\n"; print "\n"; - print "\n"; + print "\n"; print "" . "" . - "" . "" . "" . - "" . + "" . "
Commit Age
Unable to parse: $line
Unable to parse: $line
$short_rev..$age_str$short_rev..$age_str $author$lineno$data$lineno$data
" . mode_str($t_mode) . "" . mode_str($t_mode) . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name"), -class => "list"}, esc_html($t_name)) . @@ -1912,7 +1914,7 @@ sub git_commit { "
$ad{'rfc2822'}"; if ($ad{'hour_local'} < 6) { - printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); + printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } else { printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } @@ -1920,10 +1922,10 @@ sub git_commit { "
committer" . esc_html($co{'committer'}) . "
$cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "
commit$co{'id'}
commit$co{'id'}
tree" . + "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . @@ -1933,7 +1935,7 @@ sub git_commit { foreach my $par (@$parents) { print "
parent" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par"), class => "list"}, $par) . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par"), class => "list"}, $par) . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par")}, "commit") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") . @@ -1958,7 +1960,7 @@ sub git_commit { } if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { $signed = 1; - print "" . esc_html($line) . "
\n"; + print "" . esc_html($line) . "
\n"; } else { $signed = 0; print format_log_line_html($line) . "
\n"; @@ -1970,7 +1972,7 @@ sub git_commit { print(($#difftree + 1) . " files changed:\n"); } print "\n"; - print "\n"; + print "
\n"; my $alternate = 0; foreach my $line (@difftree) { # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c' @@ -1998,12 +2000,12 @@ sub git_commit { } print "\n" . - "\n" . + "\n" . "\n"; } elsif ($status eq "D") { print "\n" . - "\n" . + "\n" . "\n" . - "\n" . "\n" . diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index 4378067d3c..ac6a3c774d 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -1,230 +1,320 @@ body { - font-family: sans-serif; - font-size: 12px; - border:solid #d9d8d1; - border-width: 1px; - margin: 10px; - background-color: #ffffff; - color: #000000; + font-family: sans-serif; + font-size: 12px; + border:solid #d9d8d1; + border-width: 1px; + margin: 10px; + background-color: #ffffff; + color: #000000; } a { - color: #0000cc; + color: #0000cc; } a:hover, a:visited, a:active { - color: #880000; + color: #880000; } div.page_header { - height: 25px; - padding: 8px; - font-size: 18px; - font-weight: bold; - background-color: #d9d8d1; + height: 25px; + padding: 8px; + font-size: 18px; + font-weight: bold; + background-color: #d9d8d1; } div.page_header a:visited, a.header { - color: #0000cc; + color: #0000cc; } div.page_header a:hover { - color: #880000; + color: #880000; } div.page_nav { - padding:8px; + padding:8px; } div.page_nav a:visited { - color: #0000cc; + color: #0000cc; } div.page_path { - padding: 8px; - border: solid #d9d8d1; - border-width: 0px 0px 1px; + padding: 8px; + border: solid #d9d8d1; + border-width: 0px 0px 1px; } div.page_footer { - height: 17px; - padding: 4px 8px; - background-color: #d9d8d1; + height: 17px; + padding: 4px 8px; + background-color: #d9d8d1; } div.page_footer_text { - float: left; - color: #555555; - font-style: italic; + float: left; + color: #555555; + font-style: italic; } div.page_body { - padding: 8px; + padding: 8px; } div.title, a.title { - display: block; - padding: 6px 8px; - font-weight: bold; - background-color: #edece6; - text-decoration: none; - color: #000000; + display: block; + padding: 6px 8px; + font-weight: bold; + background-color: #edece6; + text-decoration: none; + color: #000000; } a.title:hover { - background-color: #d9d8d1; + background-color: #d9d8d1; } div.title_text { - padding: 6px 0px; - border: solid #d9d8d1; - border-width: 0px 0px 1px; + padding: 6px 0px; + border: solid #d9d8d1; + border-width: 0px 0px 1px; } div.log_body { - padding: 8px 8px 8px 150px; + padding: 8px 8px 8px 150px; } span.age { - position: relative; - float: left; - width: 142px; - font-style:italic; + position: relative; + float: left; + width: 142px; + font-style: italic; +} + +div.page_body span.signoff { + color: #888888; } div.log_link { - padding: 0px 8px; - font-size: 10px; - font-family: sans-serif; - font-style:normal; - position: relative; - float: left; - width: 136px; + padding: 0px 8px; + font-size: 10px; + font-family: sans-serif; + font-style: normal; + position: relative; + float: left; + width: 136px; } div.list_head { - padding: 6px 8px 4px; - border: solid #d9d8d1; - border-width: 1px 0px 0px; - font-style: italic; + padding: 6px 8px 4px; + border: solid #d9d8d1; + border-width: 1px 0px 0px; + font-style: italic; } a.list { - text-decoration: none; - color: #000000; + text-decoration: none; + color: #000000; } a.list:hover { - text-decoration: underline; - color: #880000; + text-decoration: underline; + color: #880000; } a.text { - text-decoration: none; - color: #0000cc; + text-decoration: none; + color: #0000cc; } a.text:visited { - text-decoration: none; - color: #880000; + text-decoration: none; + color: #880000; } a.text:hover { - text-decoration: underline; - color: #880000; + text-decoration: underline; + color: #880000; } table { - padding: 8px 4px; + padding: 8px 4px; +} + +table.project_list, table.diff_tree { + border-spacing: 0; +} + +table.blame { + border-collapse: collapse; } th { - padding: 2px 5px; - font-size: 12px; - text-align: left; + padding: 2px 5px; + font-size: 12px; + text-align: left; } tr.light:hover { - background-color: #edece6; + background-color: #edece6; } tr.dark { - background-color: #f6f6f0; + background-color: #f6f6f0; } tr.dark:hover { - background-color: #edece6; + background-color: #edece6; } - td { - padding: 2px 5px; - font-size: 12px; - vertical-align:top; + padding: 2px 5px; + font-size: 12px; + vertical-align: top; } td.link { - padding: 2px 5px; - font-family: sans-serif; - font-size: 10px; + padding: 2px 5px; + font-family: sans-serif; + font-size: 10px; +} + +td.sha1 { + font-family: monospace; +} + +td.error { + color: red; + background-color: yellow; +} + +table.diff_tree span.file_status.new { + color: #008000; +} + +table.diff_tree span.file_status.deleted { + color: #c00000; +} + +table.diff_tree span.file_status.moved, +table.diff_tree span.file_status.mode_chnge { + color: #777777; +} + +/* age2: 60*60*24*2 <= age */ +table.project_list td.age2, table.blame td.age2 { + font-style: italic; +} + +/* age1: 60*60*2 <= age < 60*60*24*2 */ +table.project_list td.age1 { + color: #009900; + font-style: italic; } -div.pre { - font-family: monospace; - font-size: 12px; - white-space: pre; +table.blame td.age1 { + color: #009900; + background: transparent; +} + +/* age0: age < 60*60*2 */ +table.project_list td.age0 { + color: #009900; + font-style: italic; + font-weight: bold; +} + +table.blame td.age0 { + color: #009900; + background: transparent; + font-weight: bold; +} + +td.pre, div.pre, div.diff { + font-family: monospace; + font-size: 12px; + white-space: pre; +} + +td.mode { + font-family: monospace; +} + +div.diff.add { + color: #008800; +} + +div.diff.rem { + color: #cc0000; +} + +div.diff.chunk_header { + color: #990099; } div.diff_info { - font-family: monospace; - color: #000099; - background-color: #edece6; - font-style: italic; + font-family: monospace; + color: #000099; + background-color: #edece6; + font-style: italic; } div.index_include { - border: solid #d9d8d1; - border-width: 0px 0px 1px; - padding: 12px 8px; + border: solid #d9d8d1; + border-width: 0px 0px 1px; + padding: 12px 8px; } div.search { - margin: 4px 8px; - position: absolute; - top: 56px; - right: 12px + margin: 4px 8px; + position: absolute; + top: 56px; + right: 12px +} + +td.linenr { + text-align: right; } a.linenr { - color: #999999; - text-decoration: none + color: #999999; + text-decoration: none } a.rss_logo { - float: right; - padding: 3px 0px; - width: 35px; - line-height: 10px; - border: 1px solid; - border-color: #fcc7a5 #7d3302 #3e1a01 #ff954e; - color: #ffffff; - background-color: #ff6600; - font-weight: bold; - font-family: sans-serif; - font-size: 10px; - text-align: center; - text-decoration: none; + float: right; + padding: 3px 0px; + width: 35px; + line-height: 10px; + border: 1px solid; + border-color: #fcc7a5 #7d3302 #3e1a01 #ff954e; + color: #ffffff; + background-color: #ff6600; + font-weight: bold; + font-family: sans-serif; + font-size: 10px; + text-align: center; + text-decoration: none; } a.rss_logo:hover { - background-color: #ee5500; + background-color: #ee5500; } span.tag { - padding: 0px 4px; - font-size: 10px; - font-weight: normal; - background-color: #ffffaa; - border: 1px solid; - border-color: #ffffcc #ffee00 #ffee00 #ffffcc; + padding: 0px 4px; + font-size: 10px; + font-weight: normal; + background-color: #ffffaa; + border: 1px solid; + border-color: #ffffcc #ffee00 #ffee00 #ffffcc; +} + +span.atnight { + color: #cc0000; +} + +span.match { + color: #e00000; } From 7a9b4c5fe3b8d291063c398ecb655281a60b2be7 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Wed, 21 Jun 2006 09:48:02 +0200 Subject: [PATCH 11/16] gitweb: whitespace cleanup Do not use tabs to align variable initialization (actually use tabs only at the beginning of line, for code indent). Remove trailing whitespace. Make whitespace usage more consistent. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 38 +++++++++++++++++++------------------- gitweb/gitweb.css | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 44896bb300..89224e60b7 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -17,33 +17,33 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "267"; -my $my_url = $cgi->url(); -my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +my $version = "267"; +my $my_url = $cgi->url(); +my $my_uri = $cgi->url(-absolute => 1); +my $rss_link = ""; # absolute fs-path which will be prepended to the project path -#my $projectroot = "/pub/scm"; -my $projectroot = "/home/kay/public_html/pub/scm"; +#my $projectroot = "/pub/scm"; +my $projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries -my $gitbin = "/usr/bin"; +my $gitbin = "/usr/bin"; # location for temporary files needed for diffs -my $git_temp = "/tmp/gitweb"; +my $git_temp = "/tmp/gitweb"; # target of the home link on top of all pages -my $home_link = $my_uri; +my $home_link = $my_uri; # html text to include at home page -my $home_text = "indextext.html"; +my $home_text = "indextext.html"; # URI of default stylesheet -my $stylesheet = "gitweb.css"; +my $stylesheet = "gitweb.css"; # source of projects list -#my $projects_list = $projectroot; -my $projects_list = "index/index.aux"; +#my $projects_list = $projectroot; +my $projects_list = "index/index.aux"; # default blob_plain mimetype and default charset for text/plain blob my $default_blob_plain_mimetype = 'text/plain'; @@ -51,7 +51,7 @@ my $default_text_plain_charset = undef; # file to use for guessing MIME types before trying /etc/mime.types # (relative to the current git repository) -my $mimetypes_file = undef; +my $mimetypes_file = undef; # input validation and dispatch @@ -349,7 +349,7 @@ sub git_footer_html { sub die_error { my $status = shift || "403 Forbidden"; - my $error = shift || "Malformed query, file missing or permission denied"; + my $error = shift || "Malformed query, file missing or permission denied"; git_header_html($status); print "
\n" . @@ -1066,7 +1066,7 @@ sub git_summary { "
\n" . ""; @@ -1362,7 +1362,7 @@ sub git_tags { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log"); + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "\n" . ""; @@ -1942,7 +1942,7 @@ sub git_commit { "" . "\n"; } - print "
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "[new " . file_type($to_mode) . "$mode_chng][new " . file_type($to_mode) . "$mode_chng]" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "[deleted " . file_type($from_mode). "][deleted " . file_type($from_mode). "]" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash;f=$file")}, "history") . @@ -2011,7 +2013,7 @@ sub git_commit { } elsif ($status eq "M" || $status eq "T") { my $mode_chnge = ""; if ($from_mode != $to_mode) { - $mode_chnge = " [changed"; + $mode_chnge = " [changed"; if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) { $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode); } @@ -2047,7 +2049,7 @@ sub git_commit { } print "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html($to_file)) . "[moved from " . + "[moved from " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) . " with " . (int $similarity) . "% similarity$mode_chng]" . @@ -2407,7 +2409,7 @@ sub git_search { my $match = esc_html($2) || ""; my $trail = esc_html($3) || ""; $trail = chop_str($trail, 30, 10); - my $text = "$lead$match$trail"; + my $text = "$lead$match$trail"; print chop_str($text, 80, 5) . "
\n"; } } @@ -2456,7 +2458,7 @@ sub git_search { while (my $setref = shift @files) { my %set = %$setref; print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"}, - "" . esc_html($set{'file'}) . "") . + "" . esc_html($set{'file'}) . "") . "
\n"; } print "
"; if (length($co{'title_short'}) < length($co{'title'})) { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "" . esc_html($co{'title_short'}) . "$ref"); + "" . esc_html($co{'title_short'}) . "$ref"); } else { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" . esc_html($co{'title'}) . "$ref"); @@ -1124,7 +1124,7 @@ sub git_summary { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log"); + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "
". + print "
". "
\n"; print "
\n"; my $comment = $co{'comment'}; diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index ac6a3c774d..98410f5b6c 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -1,7 +1,7 @@ body { font-family: sans-serif; font-size: 12px; - border:solid #d9d8d1; + border: solid #d9d8d1; border-width: 1px; margin: 10px; background-color: #ffffff; @@ -33,7 +33,7 @@ div.page_header a:hover { } div.page_nav { - padding:8px; + padding: 8px; } div.page_nav a:visited { From ae20de5386f74dbde991186694cfdac323b21e47 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Wed, 21 Jun 2006 09:48:03 +0200 Subject: [PATCH 12/16] Add git version to gitweb output Add git-core binaries used version as the comment at the beginning of HTML output, just below the comment with version of git web interface version. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 89224e60b7..87ec565f63 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -29,6 +29,14 @@ my $projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries my $gitbin = "/usr/bin"; +# version of the git-core binaries +my $git_version = qx($gitbin/git --version); +if ($git_version =~ m/git version (.*)$/) { + $git_version = $1; +} else { + $git_version = "unknown"; +} + # location for temporary files needed for diffs my $git_temp = "/tmp/gitweb"; @@ -288,11 +296,12 @@ sub git_header_html { + - $title + $rss_link @@ -816,7 +825,7 @@ sub git_get_project_config { $key =~ s/^gitweb\.//; return if ($key =~ m/\W/); - my $val = qx(git-repo-config --get gitweb.$key); + my $val = qx($gitbin/git-repo-config --get gitweb.$key); return ($val); } From 3f7f271004cd6b8f98bc4437408411c96a4766eb Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Wed, 21 Jun 2006 09:48:04 +0200 Subject: [PATCH 13/16] Move $gitbin earlier in gitweb.cgi (cherry picked from 9dca843086356b964f27d8fabe1e3c48074a9f02 commit) Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 87ec565f63..ef7fcbd84f 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -22,13 +22,13 @@ my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; +# location of the git-core binaries +my $gitbin = "/usr/bin"; + # absolute fs-path which will be prepended to the project path #my $projectroot = "/pub/scm"; my $projectroot = "/home/kay/public_html/pub/scm"; -# location of the git-core binaries -my $gitbin = "/usr/bin"; - # version of the git-core binaries my $git_version = qx($gitbin/git --version); if ($git_version =~ m/git version (.*)$/) { From 49f582a0401f3b9b9a80ff6fe0dd601520579b7d Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Wed, 21 Jun 2006 17:06:39 +0200 Subject: [PATCH 14/16] gitweb: Make use of $PATH_INFO for project parameter Allow to have project name in the path part of URL, just after the name of script. For example instead of gitweb.cgi?p=git.git you can write gitweb.cgi/git.git or gitweb.cgi/git.git/ Not used in URLs inside gitweb; it means that the above alternate syntax must be generated by hand, at least for now. Side effect: project name parameter is now stripped of leading and trailing slash before validation. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index ef7fcbd84f..f2e50462d9 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -86,8 +86,9 @@ if (defined $order) { } } -my $project = $cgi->param('p'); +my $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); if (defined $project) { + $project =~ s|^/||; $project =~ s|/$||; $project = validate_input($project); if (!defined($project)) { die_error(undef, "Invalid project parameter."); From 4c5c20261c5403650a31a91ebce0cc9444182383 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Tue, 20 Jun 2006 16:41:05 +0300 Subject: [PATCH 15/16] gitweb: Use $hash_base as $search_hash if possible $hash (h parameter) does not always point to a commit. Use $hash_base as $search_hash when it is defined. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index f2e50462d9..e2108dee7c 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -322,7 +322,9 @@ EOF $searchtext = ""; } my $search_hash; - if (defined $hash) { + if (defined $hash_base) { + $search_hash = $hash_base; + } elsif (defined $hash) { $search_hash = $hash; } else { $search_hash = "HEAD"; From 8adc4bd4a5e800a16e5680f4825ca76ed7cf9a2e Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 22 Jun 2006 08:52:57 +0200 Subject: [PATCH 16/16] gitweb: whitespace cleanup around '=' Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index e2108dee7c..035e76d0a3 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -327,7 +327,7 @@ EOF } elsif (defined $hash) { $search_hash = $hash; } else { - $search_hash = "HEAD"; + $search_hash = "HEAD"; } $cgi->param("a", "search"); $cgi->param("h", $search_hash); @@ -1767,8 +1767,8 @@ sub git_opml { } my $path = esc_html(chop_str($proj{'path'}, 25, 5)); - my $rss = "$my_url?p=$proj{'path'};a=rss"; - my $html = "$my_url?p=$proj{'path'};a=summary"; + my $rss = "$my_url?p=$proj{'path'};a=rss"; + my $html = "$my_url?p=$proj{'path'};a=summary"; print "\n"; } print "\n". @@ -1943,7 +1943,7 @@ sub git_commit { "
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "
parent