X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fgitweb.pm;h=d110b7647690287269fc0c02c8d81b32f015736a;hb=e679ab757426141825f7f3d92e560cc37bc85544;hp=bb57fdddb89c5f87c68f95c515622c8f01805837;hpb=86382b958ab98c7e48ffbb72b2eb8234afd25741;p=catagits%2FGitalist.git diff --git a/lib/gitweb.pm b/lib/gitweb.pm index bb57fdd..d110b76 100755 --- a/lib/gitweb.pm +++ b/lib/gitweb.pm @@ -28,7 +28,7 @@ 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 + $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 @@ -85,7 +85,7 @@ sub main { chomp($GIT); # absolute fs-path which will be prepended to the project path - our $projectroot = "/pub/scm"; + #our $projectroot = "/pub/scm"; # target of the home link on top of all pages our $home_link = $my_uri || "/"; @@ -93,11 +93,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 @@ -113,7 +108,7 @@ sub main { our $logo_label = "git documentation"; # source of projects list - our $projects_list = $c->config->{projectroot}; + our $projectroot = our $projects_list = $c->config->{projectroot}; # the width (in characters) of the projects list "Description" column our $projects_list_description_width = 25; @@ -2781,184 +2776,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[] - : ''; - - # print out each stylesheet that exist, providing backwards capability - # for those people who defined $stylesheet in a config file - my $ssfmt = q[]; - $c->stash->{stylesheets} = [$c->config->{stylesheet} - ? sprintf($ssfmt, $c->config->{stylesheet}) - : map(sprintf($ssfmt, $_), grep $_, @stylesheets) - ]; - - $c->stash->{project} = defined $project; - if (defined $project) { - my %href_params = get_feed_info(); - if (!exists $href_params{'-title'}) { - $href_params{'-title'} = 'log'; - } - - foreach my $format qw(RSS Atom) { - my $type = lc($format); - my %link_attr = ( - '-rel' => 'alternate', - '-title' => "$project - $href_params{'-title'} - $format feed", - '-type' => "application/$type+xml" - ); - - $href_params{'action'} = $type; - $link_attr{'-href'} = href(%href_params); - $c->stash->{lc $format.'_link'} = "\n"; - - $href_params{'extra_options'} = '--no-merges'; - $link_attr{'-href'} = href(%href_params); - $link_attr{'-title'} .= ' (no merges)'; - $c->stash->{lc $format.'_link_no_merges'} = "\n"; - } - - } else { - $c->stash->{projects_list} = sprintf(''."\n", - $site_name, href(project=>undef, action=>"project_index")); - $c->stash->{projects_feed} = sprintf(''."\n", - $site_name, href(project=>undef, action=>"opml")); - } - - my $favicon = $c->config->{favicon}; - $c->stash->{favicon} = defined $favicon - ? qq() - : ''; - - # - - $c->stash->{site_header} = -f $site_header - ? insert_file($site_header) - : ''; - - my $logo = $c->config->{logo}; - $c->stash->{logo} - = $cgi->a({-href => esc_url($logo_url), - -title => $logo_label}, - qq()); - $c->stash->{home_link} = $cgi->a({-href => esc_url($home_link)}, $home_link_str); - - if(defined $project) { - $c->stash->{summary} = $cgi->a({-href => href(action=>"summary")}, esc_html($project)); - $c->stash->{action} = $action; - } - - my $have_search = $c->stash->{have_search} = gitweb_check_feature('search'); - if (defined $project && $have_search) { - if (!defined $searchtext) { - $searchtext = ""; - } - my $search_hash; - if (defined $hash_base) { - $search_hash = $hash_base; - } elsif (defined $hash) { - $search_hash = $hash; - } else { - $search_hash = "HEAD"; - } - my $action = $my_uri; - my $use_pathinfo = gitweb_check_feature('pathinfo'); - if ($use_pathinfo) { - $action .= "/".esc_url($project); - } - # This could be done better, but meh. - $c->stash->{search_form} = $cgi->startform(-method => "get", -action => $action) . - (!$use_pathinfo && - $cgi->input({-name=>"p", -value=>$project, -type=>"hidden"}) . "\n") . - $cgi->input({-name=>"a", -value=>"search", -type=>"hidden"}) . "\n" . - $cgi->input({-name=>"h", -value=>$search_hash, -type=>"hidden"}) . "\n" . - $cgi->popup_menu(-name => 'st', -default => 'commit', - -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) . - $cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) . - " search:\n". - $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . - "" . - $cgi->checkbox(-name => 'sr', -value => 1, -label => 're', - -checked => $search_use_regexp) . - "" . - $cgi->end_form() . "\n"; - } -} - -sub git_footer_html { - my $feed_class = 'rss_logo'; - - if (defined $project) { - my $descr = git_get_project_description($project); - $c->stash->{project_description} = defined $descr - ? esc_html($descr) - : ''; - - my %href_params = get_feed_info(); - if (!%href_params) { - $feed_class .= ' generic'; - } - $href_params{'-title'} ||= 'log'; - - foreach my $format qw(RSS Atom) { - $href_params{'action'} = lc($format); - $c->stash->{lc $format.'_feed'} = $cgi->a({-href => href(%href_params), - -title => "$href_params{'-title'} $format feed", - -class => $feed_class}, $format); - } - - } else { - $c->stash->{opml_feed} = $cgi->a({-href => href(project=>undef, action=>"opml"), - -class => $feed_class}, "OPML"); - $c->stash->{index_feed} = $cgi->a({-href => href(project=>undef, action=>"project_index"), - -class => $feed_class}, "TXT"); - } - - $c->stash->{site_footer} = -f $site_footer - ? insert_file($site_footer) - : ''; -} - # die_error(, ) # Example: die_error(404, 'Hash not found') # By convention, use the following status codes (as defined in RFC 2616): @@ -2987,7 +2804,7 @@ sub die_error {
EOF - die bless {}; + die bless { $status => $http_responses{$status}, err => $error }; } ## ---------------------------------------------------------------------- @@ -5933,7 +5750,7 @@ sub git_feed { return if ($cgi->request_method() eq 'HEAD'); # header variables - my $title = "$site_name - $project/$action"; + my $title = $c->config->{sitename} . " - $project/$action"; my $feed_type = 'log'; if (defined $hash) { $title .= " - '$hash'"; @@ -6147,11 +5964,12 @@ sub git_opml { -charset => 'utf-8', -content_disposition => 'inline; filename="opml.xml"'); + my $sitename = $c->config->{sitename}; print < - $site_name OPML Export + $sitename OPML Export