From 290b1467a387a3e5306028f36118a52958fa36c5 Mon Sep 17 00:00:00 2001 From: Li Yang Date: Tue, 6 Mar 2007 11:58:56 +0800 Subject: [PATCH 1/4] gitweb: Change to use explicitly function call cgi->escapHTML() Change to use explicitly function call cgi->escapHTML(). This fix the problem on some systems that escapeHTML() is not functioning, as default CGI is not setting 'escape' parameter. Signed-off-by: Li Yang Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index ea39d7e98b..775eebe0f3 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -591,7 +591,7 @@ sub esc_html ($;%) { my %opts = @_; $str = to_utf8($str); - $str = escapeHTML($str); + $str = $cgi->escapeHTML($str); if ($opts{'-nbsp'}) { $str =~ s/ / /g; } @@ -605,7 +605,7 @@ sub esc_path { my %opts = @_; $str = to_utf8($str); - $str = escapeHTML($str); + $str = $cgi->escapeHTML($str); if ($opts{'-nbsp'}) { $str =~ s/ / /g; } From 346d5e1835937d701785300717ce34f92609c2b3 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Wed, 7 Mar 2007 02:21:25 +0100 Subject: [PATCH 2/4] gitweb: Don't escape attributes in CGI.pm HTML methods There is no need to escape HTML tag's attributes in CGI.pm HTML methods (like CGI::a()), because CGI.pm does attribute escaping automatically. $cgi->a({ ... -attribute => atribute_value }, tag_contents) is translated to tag_contents The rules for escaping attribute values (which are string contents) are different. For example you have to take care about escaping embedded '"' and "'" characters; CGI::a() does that for us automatically. CGI::a() does not HTML escape tag_contents; we would need to write some bold text for example. So we use esc_html (or esc_path) to escape tag_contents as needed. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 775eebe0f3..5214050a88 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1974,17 +1974,17 @@ sub git_print_page_path { $fullname .= ($fullname ? '/' : '') . $dir; print $cgi->a({-href => href(action=>"tree", file_name=>$fullname, hash_base=>$hb), - -title => esc_html($fullname)}, esc_path($dir)); + -title => $fullname}, esc_path($dir)); print " / "; } if (defined $type && $type eq 'blob') { print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name, hash_base=>$hb), - -title => esc_html($name)}, esc_path($basename)); + -title => $name}, esc_path($basename)); } elsif (defined $type && $type eq 'tree') { print $cgi->a({-href => href(action=>"tree", file_name=>$file_name, hash_base=>$hb), - -title => esc_html($name)}, esc_path($basename)); + -title => $name}, esc_path($basename)); print " / "; } else { print esc_path($basename); From 4ae89b76252d1c13a6675a2a4e491983946d72ec Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 24 Mar 2007 20:59:13 +0100 Subject: [PATCH 3/4] gitweb: Fix not marking signoff lines in "log" view The CSS selector for signoff lines style was too strict: in the "log" view the commit message is not encompassed in container "page_body" div. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css index 7177c6e86b..5e40292404 100644 --- a/gitweb/gitweb.css +++ b/gitweb/gitweb.css @@ -107,7 +107,7 @@ span.age { font-style: italic; } -div.page_body span.signoff { +span.signoff { color: #888888; } From cd67c8e0bc6f61ffccc12d1775bc1a200df5fe85 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 24 Mar 2007 20:59:53 +0100 Subject: [PATCH 4/4] gitweb: Add some installation notes in gitweb/INSTALL Add some installation and configuration notes for gitweb in gitweb/INSTALL. Make use of filling gitweb configuration by Makefile. It does not cover (yet?) all the configuration variables and options. Some of contents duplicates information in gitweb/README file (it is referred from gitweb/INSTALL). Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/INSTALL | 184 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 gitweb/INSTALL diff --git a/gitweb/INSTALL b/gitweb/INSTALL new file mode 100644 index 0000000000..371407dc23 --- /dev/null +++ b/gitweb/INSTALL @@ -0,0 +1,184 @@ +GIT web Interface (gitweb) Installation +======================================= + +First you have to generate gitweb.cgi from gitweb.perl using +"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi, +gitweb.css, git-logo.png and git-favicon.png) to their destination. +For example if git was (or is) installed with /usr prefix, you can do + + $ make prefix=/usr gitweb/gitweb.cgi ;# as yourself + # cp gitweb/git* /var/www/cgi-bin/ ;# as root + +Alternatively you can use autoconf generated ./configure script to +set up path to git binaries (via config.mak.autogen), so you can write +instead + + $ make configure ;# as yourself + $ ./configure --prefix=/usr ;# as yourself + $ make gitweb/gitweb.cgi ;# as yourself + # cp gitweb/git* /var/www/cgi-bin/ ;# as root + +The above example assumes that your web server is configured to run +[executable] files in /var/www/cgi-bin/ as server scripts (as CGI +scripts). + + +Build time configuration +------------------------ + +See also "How to configure gitweb for your local system" in README +file for gitweb (in gitweb/README). + +- There are many configuration variables which affects building of + gitweb.cgi; see "default configuration for gitweb" section in main + (top dir) Makefile, and instructions for building gitweb/gitweb.cgi + target. + + One of most important is where to find git wrapper binary. Gitweb + tries to find git wrapper at $(bindir)/git, so you have to set $bindir + when building gitweb.cgi, or $prefix from which $bindir is derived. If + you build and install gitweb together with the rest of git suite, + there should be no problems. Otherwise, if git was for example + installed from a binary package, you have to set $prefix (or $bindir) + accordingly. + +- Another important issue is where are git repositories you want to make + available to gitweb. By default gitweb search for repositories under + /pub/git; if you want to have projects somewhere else, like /home/git, + use GITWEB_PROJECTROOT build configuration variable. + + By default all git repositories under projectroot are visible and + available to gitweb. List of projects is generated by default by + scanning the projectroot directory for git repositories. This can be + changed (configured) as described in "Gitweb repositories" section + below. + + Note that gitweb deals directly with object database, and does not + need working directory; the name of the project is the name of its + repository object database, usually projectname.git for bare + repositories. If you want to provide gitweb access to non-bare (live) + repository, you can make projectname.git symbolic link under + projectroot linking to projectname/.git (but it is just + a suggestion). + +- You can control where gitweb tries to find its main CSS style file, + its favicon and logo with GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO + build configuration variables. By default gitweb tries to find them + in the same directory as gitweb.cgi script. + +Build example +~~~~~~~~~~~~~ + +- To install gitweb to /var/www/cgi-bin/gitweb/ when git wrapper + is installed at /usr/local/bin/git and the repositories (projects) + we want to display are under /home/local/scm, you can do + + make GITWEB_PROJECTROOT="/home/local/scm" \ + GITWEB_CSS="/gitweb/gitweb.css" \ + GITWEB_LOGO="/gitweb/git-logo.png" \ + GITWEB_FAVICON="/gitweb/git-favicon.png" \ + bindir=/usr/local/bin \ + gitweb/gitweb.cgi + + cp -fv ~/git/gitweb/gitweb.{cgi,css} \ + ~/git/gitweb/git-{favicon,logo}.png \ + /var/www/cgi-bin/gitweb/ + + +Gitweb config file +------------------ + +See also "Runtime gitweb configuration" section in README file +for gitweb (in gitweb/README). + +- You can configure gitweb further using gitweb configuration file; + by default it is file named gitweb_config.perl in the same place as + gitweb.cgi script. You can control default place for config file + using GITWEB_CONFIG build configuration variable, and you can set it + using GITWEB_CONFIG environmental variable. + +- Gitweb config file is [fragment] of perl code. You can set variables + using "our $variable = value"; text from "#" character until the end + of a line is ignored. See perlsyn(1) for details. + + See the top of gitweb.perl file for examples of customizable options. + + +Gitweb repositories: +-------------------- + +- By default all git repositories under projectroot are visible and + available to gitweb. List of projects is generated by default by + scanning the projectroot directory for git repositories (for object + databases to be more exact). + + You can provide pre-generated list of [visible] repositories, + together with information about their owners (the project ownership + is taken from owner of repository directory otherwise), by setting + GITWEB_LIST build configuration variable (or $projects_list variable + in gitweb config file) to point to a plain file. + + Each line of projects list file should consist of url-encoded path + to project repository database (relative to projectroot) separated + by space from url-encoded project owner; spaces in both project path + and project owner have to be encoded as either '%20' or '+'. + + You can generate projects list index file using project_index action + (the 'TXT' link on projects list page) directly from gitweb. + +- By default even if project is not visible on projects list page, you + can view it nevertheless by hand-crafting gitweb URL. You can set + GITWEB_STRICT_EXPORT build configuration variable (or $strict_export + variable in gitweb config file) to only allow viewing of + repositories also shown on the overview page. + +- Alternatively, you can configure gitweb to only list and allow + viewing of the explicitly exported repositories, via + GITWEB_EXPORT_OK build configuration variable (or $export_ok + variable in gitweb config file). If it evaluates to true, gitweb + show repository only if this file exists in its object database + (if directory has the magic file $export_ok). + + +Requirements +------------ + + - Core git tools + - Perl + - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename. + - web server + + +Example web server configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See also "Webserver configuration" section in README file for gitweb +(in gitweb/README). + + +- Apache2, gitweb installed as CGI script, + under /var/www/cgi-bin/ + + ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" + + + Options Indexes FollowSymlinks ExecCGI + AllowOverride None + Order allow,deny + Allow from all + + +- Apache2, gitweb installed as mod_perl legacy script, + under /var/www/perl/ + + Alias /perl "/var/www/perl" + + + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + Options Indexes FollowSymlinks +ExecCGI + AllowOverride None + Order allow,deny + Allow from all +