X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fgitweb.pm;h=9e689d1bd57ba596258015262886b7432248c84d;hb=09214cdde075e77c9713fdc14b472e982712917d;hp=488d18f810e7560e329086867ff9154ec0260784;hpb=6f28c4e47874ce95bb912cf9873a088a87a923af;p=catagits%2FGitalist.git
diff --git a/lib/gitweb.pm b/lib/gitweb.pm
index 488d18f..9e689d1 100755
--- a/lib/gitweb.pm
+++ b/lib/gitweb.pm
@@ -1,4 +1,4 @@
-co#!/usr/bin/perl
+#!/usr/bin/perl
# gitweb - simple web interface to track changes in git repositories
#
@@ -26,8 +26,8 @@ BEGIN {
use vars qw(
$cgi $version $my_url $my_uri $base_url $path_info $GIT $projectroot
- $project_maxdepth $home_link $home_link_str $site_name $site_header
- $home_text $site_footer @stylesheets $stylesheet $logo $favicon
+ $project_maxdepth $home_link $home_link_str $site_header
+ $home_text $site_footer @stylesheets
$logo_url $logo_label $logo_url $logo_label $projects_list
$projects_list_description_width $default_projects_order
$export_ok $export_auth_hook $strict_export @git_base_url_list
@@ -79,14 +79,11 @@ sub main {
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
- our $GIT = "/usr/bin/git";
+ our $GIT = `which git`;
+ chomp($GIT);
# absolute fs-path which will be prepended to the project path
- our $projectroot = "/pub/scm";
-
- # fs traversing limit for getting project list
- # the number is relative to the projectroot
- our $project_maxdepth = 2007;
+ #our $projectroot = "/pub/scm";
# target of the home link on top of all pages
our $home_link = $my_uri || "/";
@@ -94,11 +91,6 @@ sub main {
# string of the home link on top of all pages
our $home_link_str = "Project Gitalist";
- # name of your site or organization to appear in page titles
- # replace this with something more descriptive for clearer bookmarks
- our $site_name = ""
- || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
-
# filename of html text to include at top of each page
our $site_header = "";
# html text to include at home page
@@ -108,19 +100,13 @@ sub main {
# URI of stylesheets
our @stylesheets = ("gitweb.css");
- # URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
- our $stylesheet = undef;
- # URI of GIT logo (72x27 size)
- our $logo = "git-logo.png";
- # URI of GIT favicon, assumed to be image/png type
- our $favicon = "git-favicon.png";
# URI and label (title) of GIT logo link
our $logo_url = "http://www.kernel.org/pub/software/scm/git/docs/";
our $logo_label = "git documentation";
# source of projects list
- our $projects_list = "";
+ our $projectroot = our $projects_list = $c->config->{projectroot};
# the width (in characters) of the projects list "Description" column
our $projects_list_description_width = 25;
@@ -436,8 +422,6 @@ sub main {
# version of the core git binary
our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown";
- $projects_list ||= $projectroot;
-
# ======================================================================
# input validation and dispatch
@@ -1031,19 +1015,6 @@ sub validate_refname {
return $input;
}
-# decode sequences of octets in utf8 into Perl's internal form,
-# which is utf-8 with utf8 flag set if needed. gitweb writes out
-# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
-sub to_utf8 {
- my $str = shift;
- if (utf8::valid($str)) {
- utf8::decode($str);
- return $str;
- } else {
- return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
- }
-}
-
# quote unsafe chars, but keep the slash, even when it's not
# correct, but quoted slashes look too horrible in bookmarks
sub esc_param {
@@ -1186,6 +1157,19 @@ sub project_in_list {
return @list && scalar(grep { $_->{'path'} eq $project } @list);
}
+# decode sequences of octets in utf8 into Perl's internal form,
+# which is utf-8 with utf8 flag set if needed. gitweb writes out
+# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
+sub to_utf8 {
+ my $str = shift;
+ if (utf8::valid($str)) {
+ utf8::decode($str);
+ return $str;
+ } else {
+ return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
+ }
+}
+
## ----------------------------------------------------------------------
## HTML aware string manipulation
@@ -2167,106 +2151,6 @@ sub git_get_project_url_list {
return wantarray ? @git_project_url_list : \@git_project_url_list;
}
-sub git_get_projects_list {
- my ($filter) = @_;
- my @list;
-
- $filter ||= '';
- $filter =~ s/\.git$//;
-
- my $check_forks = gitweb_check_feature('forks');
-
- if (-d $projects_list) {
- # search in directory
- my $dir = $projects_list . ($filter ? "/$filter" : '');
- # remove the trailing "/"
- $dir =~ s!/+$!!;
- my $pfxlen = length("$dir");
- my $pfxdepth = ($dir =~ tr!/!!);
-
- File::Find::find({
- follow_fast => 1, # follow symbolic links
- follow_skip => 2, # ignore duplicates
- dangling_symlinks => 0, # ignore dangling symlinks, silently
- wanted => sub {
- # skip project-list toplevel, if we get it.
- return if (m!^[/.]$!);
- # only directories can be git repositories
- return unless (-d $_);
- # don't traverse too deep (Find is super slow on os x)
- if (($File::Find::name =~ tr!/!!) - $pfxdepth > $project_maxdepth) {
- $File::Find::prune = 1;
- return;
- }
-
- my $subdir = substr($File::Find::name, $pfxlen + 1);
- # we check related file in $projectroot
- my $path = ($filter ? "$filter/" : '') . $subdir;
- if (check_export_ok("$projectroot/$path")) {
- push @list, { path => $path };
- $File::Find::prune = 1;
- }
- },
- }, "$dir");
-
- } elsif (-f $projects_list) {
- # read from file(url-encoded):
- # 'git%2Fgit.git Linus+Torvalds'
- # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
- # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
- my %paths;
- open my ($fd), $projects_list or return;
- PROJECT:
- while (my $line = <$fd>) {
- chomp $line;
- my ($path, $owner) = split ' ', $line;
- $path = unescape($path);
- $owner = unescape($owner);
- if (!defined $path) {
- next;
- }
- if ($filter ne '') {
- # looking for forks;
- my $pfx = substr($path, 0, length($filter));
- if ($pfx ne $filter) {
- next PROJECT;
- }
- my $sfx = substr($path, length($filter));
- if ($sfx !~ /^\/.*\.git$/) {
- next PROJECT;
- }
- } elsif ($check_forks) {
- PATH:
- foreach my $filter (keys %paths) {
- # looking for forks;
- my $pfx = substr($path, 0, length($filter));
- if ($pfx ne $filter) {
- next PATH;
- }
- my $sfx = substr($path, length($filter));
- if ($sfx !~ /^\/.*\.git$/) {
- next PATH;
- }
- # is a fork, don't include it in
- # the list
- next PROJECT;
- }
- }
- if (check_export_ok("$projectroot/$path")) {
- my $pr = {
- path => $path,
- owner => to_utf8($owner),
- };
- push @list, $pr;
- (my $forks_path = $path) =~ s/\.git$//;
- $paths{$forks_path}++;
- }
- }
- close $fd;
- }
- return @list;
-}
-
our $gitweb_project_owner = undef;
sub git_get_project_list_from_file {
@@ -2903,182 +2787,6 @@ sub blob_contenttype {
return $type;
}
-## ======================================================================
-## functions printing HTML: header, footer, error page
-
-sub git_header_html {
- # XXX These aren't used, how odd.
- my $status = shift || "200 OK";
- my $expires = shift;
-
- my $title = "$site_name";
- if (defined $project) {
- $title .= " - " . to_utf8($project);
- if (defined $action) {
- $title .= "/$action";
- if (defined $file_name) {
- $title .= " - " . esc_path($file_name);
- if ($action eq "tree" && $file_name !~ m|/$|) {
- $title .= "/";
- }
- }
- }
- }
-
- $c->stash->{version} = $version;
- $c->stash->{git_version} = $git_version;
- $c->stash->{title} = $title;
-
- # the stylesheet, favicon etc urls won't work correctly with path_info
- # unless we set the appropriate base URL
- $c->stash->{baseurl} = $ENV{PATH_INFO}
- ? q[