fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-04-19 11:05 am

[dw-free] Move controllers over to get subpatterns from @_

[commit: http://hg.dwscoalition.org/dw-free/rev/038fab79a02a]

http://bugs.dwscoalition.org/show_bug.cgi?id=3537

Refactor.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Controller/Dev.pm
  • cgi-bin/DW/Controller/Interface/AtomAPI.pm
  • cgi-bin/DW/Controller/Interface/S2.pm
  • cgi-bin/DW/Controller/Nav.pm
  • cgi-bin/DW/Controller/Rename.pm
--------------------------------------------------------------------------------
diff -r ae12bfaa91d2 -r 038fab79a02a cgi-bin/DW/Controller/Dev.pm
--- a/cgi-bin/DW/Controller/Dev.pm	Tue Apr 19 18:53:32 2011 +0800
+++ b/cgi-bin/DW/Controller/Dev.pm	Tue Apr 19 19:05:46 2011 +0800
@@ -44,9 +44,7 @@ sub tests_index_handler {
 }
     
 sub tests_handler {
-    my ( $opts ) = @_;
-    my $test = $opts->subpatterns->[0];
-    my $lib = $opts->subpatterns->[1];
+    my ( $opts, $test, $lib ) = @_;
 
     my $r = DW::Request->get;
 
diff -r ae12bfaa91d2 -r 038fab79a02a cgi-bin/DW/Controller/Interface/AtomAPI.pm
--- a/cgi-bin/DW/Controller/Interface/AtomAPI.pm	Tue Apr 19 18:53:32 2011 +0800
+++ b/cgi-bin/DW/Controller/Interface/AtomAPI.pm	Tue Apr 19 19:05:46 2011 +0800
@@ -353,7 +353,7 @@ sub _list_entries {
 
 
 sub entry_handler {
-    my ( $call_info ) = @_;
+    my ( $call_info, $jitemid ) = @_;
 
     my ( $ok, $rv ) = check_enabled();
     return $rv unless $ok;
@@ -366,7 +366,7 @@ sub entry_handler {
     my $u = $rv->{u};
     my $remote = $rv->{remote};
 
-    my $jitemid = int( $call_info->subpatterns->[0] || 0 );
+    $jitemid = int( $jitemid || 0 );
 
     my $req = {
         ver         => 1,
diff -r ae12bfaa91d2 -r 038fab79a02a cgi-bin/DW/Controller/Interface/S2.pm
--- a/cgi-bin/DW/Controller/Interface/S2.pm	Tue Apr 19 18:53:32 2011 +0800
+++ b/cgi-bin/DW/Controller/Interface/S2.pm	Tue Apr 19 19:05:46 2011 +0800
@@ -25,10 +25,11 @@ DW::Routing->register_regex( '^/interfac
 
 # handles menu nav pages
 sub interface_handler {
+    my ( $call_info, $layerid ) = @_;
     my $r = DW::Request->get;
     my $method = $r->method;
 
-    my $layerid = int( $_[0]->subpatterns->[0] || 0 ) || '';
+    $layerid = int( $layerid || 0 ) || '';
     return error( $r, $r->NOT_FOUND, 'No layerid', 'Must provide the layerid, e.g., /interface/s2/1234' )
         unless $layerid;
 
diff -r ae12bfaa91d2 -r 038fab79a02a cgi-bin/DW/Controller/Nav.pm
--- a/cgi-bin/DW/Controller/Nav.pm	Tue Apr 19 18:53:32 2011 +0800
+++ b/cgi-bin/DW/Controller/Nav.pm	Tue Apr 19 19:05:46 2011 +0800
@@ -30,11 +30,11 @@ DW::Routing->register_regex( qr!^/nav(?:
 
 # handles menu nav pages
 sub nav_handler {
-    my $opts = shift @_;
+    my ( $opts, $cat ) = @_;
     my $r = DW::Request->get;
 
     # Check for a category like nav/read, then for a ?cat=read argument, else no category
-    my $cat = $opts->subpatterns->[0] || $r->get_args->{cat} || '';
+    $cat ||= $r->get_args->{cat} || '';
 
     # this function returns an array reference of menu hashes
     my $menu_nav = DW::Logic::MenuNav->get_menu_display( $cat )
diff -r ae12bfaa91d2 -r 038fab79a02a cgi-bin/DW/Controller/Rename.pm
--- a/cgi-bin/DW/Controller/Rename.pm	Tue Apr 19 18:53:32 2011 +0800
+++ b/cgi-bin/DW/Controller/Rename.pm	Tue Apr 19 19:05:46 2011 +0800
@@ -45,6 +45,8 @@ DW::Controller::Admin->register_admin_pa
 );
 
 sub rename_handler {
+    my ( $opts, $given_token ) = @_;
+
     my $r = DW::Request->get;
 
     my ( $ok, $rv ) = controller();
@@ -56,7 +58,6 @@ sub rename_handler {
 
     my $vars = {};
 
-    my $given_token = $_[0]->subpatterns->[0];
     my $token = DW::RenameToken->new( token => $given_token );
     my $post_args = DW::Request->get->post_args || {};
     my $get_args = DW::Request->get->get_args || {};
--------------------------------------------------------------------------------