diff --git a/gitweb.pl b/gitweb.pl index 284a1588ea..a2ec30db10 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 021 +# Version 025 # # (C) 2005, Kay Sievers # (C) 2005, Christian Gierke @@ -14,57 +14,59 @@ use warnings; use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); +my $cgi = new CGI; + my $projectroot = "/home/kay/public_html"; my $defaultprojects = "."; my $gitbin = "/home/kay/bin/git"; my $gittmp = "/tmp"; +my $my_url = $cgi->url(); +my $my_uri = $cgi->url(-absolute => 1); +my $my_url_parm = $cgi->url(-path => 1); +$my_url_parm =~ s/.*$my_uri//; -my $cgi = new CGI; my $project = ""; my $action = ""; my $hash = ""; my $hash_parent = ""; -my $view_back; -my $myself = $cgi->url(-absolute => 1); -my $url_parm = $cgi->url(-path => 1); -$url_parm =~ s/.*$myself//; +my $view_back = 1; # get values from url -if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { +if ($my_url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { $project = $1; $action = "commitdiff"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; $action = "blobdiff"; $hash = $2; $hash_parent = $3; -} elsif ($url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { $project = $1; $action = "blob"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) { $project = $1; $action = "tree"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/log/([0-9]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/log/([0-9]+)$#) { $project = $1; $action = "log"; $view_back = $2; -} elsif ($url_parm =~ m#/(.+)/log$#) { +} elsif ($my_url_parm =~ m#/(.+)/log$#) { $project = $1; $action = "log"; $view_back = 1; -} elsif ($url_parm =~ m#/(.+)/rss$#) { +} elsif ($my_url_parm =~ m#/(.+)/rss$#) { $project = $1; $action = "rss"; $view_back = 1; -} elsif ($url_parm =~ m#/git-logo.png$#) { - print $cgi->header(-type => 'image/png'); +} elsif ($my_url_parm =~ m#/git-logo.png$#) { + print $cgi->header(-type => 'image/png', -expires => '+1d'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". @@ -79,7 +81,7 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; exit; -} elsif ($url_parm =~ m#/(.+)$#) { +} elsif ($my_url_parm =~ m#/(.+)$#) { $project = $1; $action = "log"; $view_back = 1; @@ -91,13 +93,13 @@ $project =~ s#\/\.+##g; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; sub git_header_html { - print $cgi->header(-type => 'text/html; charset: utf-8'); + print $cgi->header(-type => 'text/html', -charset => 'utf-8'); print < git - $project $action - +