@matheusbsbs / matheus-bagliano / commits / 77a153fd92
Fork 0

gitweb: Route rest of action subroutines through %actions

Route rest of action subroutines, namely git_project_list and git_opml (both of which doesn't need $project) through %actions hash. This has disadvantage that all parameters are read and validated; earlier git_opml was called as soon as $action was parsed and validated, git_project_list was called as soon as $project was parsed and validated. This has advantage that all action dispatch is grouped in one place. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 22, 2006 at 16:59 UTC 77a153fd92ae6e4e40e0ccb15c9f808d63e198a0
1 file changed +8 -9
gitweb/gitweb.perl
+8 -9
@@ -155,11 +155,6 @@ if (defined $action) {
155 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
156 die_error(undef, "Invalid action parameter");
157 }
158 - # action which does not check rest of parameters
159 - if ($action eq "opml") {
160 - git_opml();
161 - exit;
162 - }
158 }
159
160 our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
@@ -179,9 +174,6 @@ if (defined $project) {
174 die_error(undef, "No such project");
175 }
176 $ENV{'GIT_DIR'} = "$projectroot/$project";
182 -} else {
183 - git_project_list();
184 - exit;
177 }
178
179 our $file_name = $cgi->param('f');
@@ -255,9 +247,16 @@ my %actions = (
247 "tags" => \&git_tags,
248 "tree" => \&git_tree,
249 "snapshot" => \&git_snapshot,
250 + # those below don't need $project
251 + "opml" => \&git_opml,
252 + "project_list" => \&git_project_list,
253 );
254
260 -$action = 'summary' if (!defined($action));
255 +if (defined $project) {
256 + $action ||= 'summary';
257 +} else {
258 + $action ||= 'project_list';
259 +}
260 if (!defined($actions{$action})) {
261 die_error(undef, "Unknown action");
262 }