]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: add project_filter to limit project list to a subdirectory
[Gitweb] / gitweb.perl
index 843b0b569ba4490ba85ae421cd6071fdf0c0916abf62d4b209befc292b4029eb..a1bf9f5e3f8a8773c721c6caa9b6c393d9239b4a31a9cf76858e692f8795e4eb 100755 (executable)
@@ -761,6 +761,7 @@ our @cgi_param_mapping = (
        search_use_regexp => "sr",
        ctag => "by_tag",
        diff_style => "ds",
        search_use_regexp => "sr",
        ctag => "by_tag",
        diff_style => "ds",
+       project_filter => "pf",
        # this must be last entry (for manipulation from JavaScript)
        javascript => "js"
 );
        # this must be last entry (for manipulation from JavaScript)
        javascript => "js"
 );
@@ -977,7 +978,7 @@ sub evaluate_path_info {
 
 our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,
      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,
 
 our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,
      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,
-     $searchtext, $search_regexp);
+     $searchtext, $search_regexp, $project_filter);
 sub evaluate_and_validate_params {
        our $action = $input_params{'action'};
        if (defined $action) {
 sub evaluate_and_validate_params {
        our $action = $input_params{'action'};
        if (defined $action) {
@@ -995,6 +996,13 @@ sub evaluate_and_validate_params {
                }
        }
 
                }
        }
 
+       our $project_filter = $input_params{'project_filter'};
+       if (defined $project_filter) {
+               if (!validate_pathname($project_filter)) {
+                       die_error(404, "Invalid project_filter parameter");
+               }
+       }
+
        our $file_name = $input_params{'file_name'};
        if (defined $file_name) {
                if (!validate_pathname($file_name)) {
        our $file_name = $input_params{'file_name'};
        if (defined $file_name) {
                if (!validate_pathname($file_name)) {
@@ -3735,7 +3743,12 @@ sub run_highlighter {
 sub get_page_title {
        my $title = to_utf8($site_name);
 
 sub get_page_title {
        my $title = to_utf8($site_name);
 
-       return $title unless (defined $project);
+       unless (defined $project) {
+               if (defined $project_filter) {
+                       $title .= " - " . to_utf8($project_filter);
+               }
+               return $title;
+       }
        $title .= " - " . to_utf8($project);
 
        return $title unless (defined $action);
        $title .= " - " . to_utf8($project);
 
        return $title unless (defined $action);
@@ -5985,7 +5998,7 @@ sub git_project_list {
                die_error(400, "Unknown order parameter");
        }
 
                die_error(400, "Unknown order parameter");
        }
 
-       my @list = git_get_projects_list();
+       my @list = git_get_projects_list($project_filter, $strict_export);
        if (!@list) {
                die_error(404, "No projects found");
        }
        if (!@list) {
                die_error(404, "No projects found");
        }
@@ -6026,7 +6039,7 @@ sub git_forks {
 }
 
 sub git_project_index {
 }
 
 sub git_project_index {
-       my @projects = git_get_projects_list();
+       my @projects = git_get_projects_list($project_filter, $strict_export);
        if (!@projects) {
                die_error(404, "No projects found");
        }
        if (!@projects) {
                die_error(404, "No projects found");
        }
@@ -7865,7 +7878,7 @@ sub git_atom {
 }
 
 sub git_opml {
 }
 
 sub git_opml {
-       my @list = git_get_projects_list();
+       my @list = git_get_projects_list($project_filter, $strict_export);
        if (!@list) {
                die_error(404, "No projects found");
        }
        if (!@list) {
                die_error(404, "No projects found");
        }
@@ -7876,11 +7889,17 @@ sub git_opml {
                -content_disposition => 'inline; filename="opml.xml"');
 
        my $title = esc_html($site_name);
                -content_disposition => 'inline; filename="opml.xml"');
 
        my $title = esc_html($site_name);
+       my $filter = " within subdirectory ";
+       if (defined $project_filter) {
+               $filter .= esc_html($project_filter);
+       } else {
+               $filter = "";
+       }
        print <<XML;
 <?xml version="1.0" encoding="utf-8"?>
 <opml version="1.0">
 <head>
        print <<XML;
 <?xml version="1.0" encoding="utf-8"?>
 <opml version="1.0">
 <head>
-  <title>$title OPML Export</title>
+  <title>$title OPML Export$filter</title>
 </head>
 <body>
 <outline text="git RSS feeds">
 </head>
 <body>
 <outline text="git RSS feeds">
This page took 0.294593 seconds and 4 git commands to generate.