]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
Added the new pinghandler to the stopdaemons script and improved the behaviour and...
[quix0rs-gnu-social.git] / lib / router.php
index e842604e9a35d11abd55ba1194eaec80b56534f0..52051fdb50a8c05aa43f70d57fd9382a2f6e2675 100644 (file)
@@ -49,6 +49,9 @@ class Router
 {
     var $m = null;
     static $inst = null;
+    static $bare = array('requesttoken', 'accesstoken', 'userauthorization',
+                         'postnotice', 'updateprofile', 'finishremotesubscribe',
+                         'finishopenidlogin', 'finishaddopenid');
 
     static function get()
     {
@@ -116,6 +119,11 @@ class Router
 
         $m->connect('main/openid', array('action' => 'openidlogin'));
         $m->connect('main/remote', array('action' => 'remotesubscribe'));
+        $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+'));
+
+        foreach (Router::$bare as $action) {
+            $m->connect('index.php?action=' . $action, array('action' => $action));
+        }
 
         // settings
 
@@ -128,6 +136,7 @@ class Router
 
         foreach (array('group', 'people', 'notice') as $s) {
             $m->connect('search/'.$s, array('action' => $s.'search'));
+            $m->connect('search/'.$s.'?q=:q', array('action' => $s.'search'), array('q' => '.+'));
         }
 
         $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
@@ -135,6 +144,9 @@ class Router
         // notice
 
         $m->connect('notice/new', array('action' => 'newnotice'));
+        $m->connect('notice/new?replyto=:replyto',
+                    array('action' => 'newnotice'),
+                    array('replyto' => '[A-Za-z0-9_-]+'));
         $m->connect('notice/:notice',
                     array('action' => 'shownotice'),
                     array('notice' => '[0-9]+'));
@@ -144,6 +156,7 @@ class Router
                     array('notice' => '[0-9]+'));
 
         $m->connect('message/new', array('action' => 'newmessage'));
+        $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]'));
         $m->connect('message/:message',
                     array('action' => 'showmessage'),
                     array('message' => '[0-9]+'));
@@ -213,18 +226,19 @@ class Router
         $m->connect('api/statuses/:method/:argument',
                     array('action' => 'api',
                           'apiaction' => 'statuses'),
-                    array('method' => '(user_timeline|show|destroy|friends|followers)'));
+                    array('method' => '(user_timeline|friends_timeline|show|destroy|friends|followers)'));
 
         // users
 
-        $m->connect('api/users/show/:argument',
+        $m->connect('api/users/:method/:argument',
                     array('action' => 'api',
-                          'apiaction' => 'users'));
+                          'apiaction' => 'users'),
+                    array('method' => 'show(\.(xml|json))?'));
 
         $m->connect('api/users/:method',
                     array('action' => 'api',
                           'apiaction' => 'users'),
-                    array('method' => 'show(\.(xml|json|atom|rss))?'));
+                    array('method' => 'show(\.(xml|json))?'));
 
         // direct messages
 
@@ -265,6 +279,32 @@ class Router
                           'apiaction' => 'friendships'),
                     array('method' => 'exists(\.(xml|json|rss|atom))'));
 
+        // Social graph
+
+        $m->connect('api/friends/ids/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'statuses',
+                          'method' => 'friendsIDs'));
+
+        foreach (array('xml', 'json') as $e) {
+            $m->connect('api/friends/ids.'.$e,
+                        array('action' => 'api',
+                              'apiaction' => 'statuses',
+                              'method' => 'friendsIDs.'.$e));
+        }
+
+        $m->connect('api/followers/ids/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'statuses',
+                          'method' => 'followersIDs'));
+
+        foreach (array('xml', 'json') as $e) {
+            $m->connect('api/followers/ids.'.$e,
+                        array('action' => 'api',
+                              'apiaction' => 'statuses',
+                              'method' => 'followersIDs.'.$e));
+        }
+
         // account
 
         $m->connect('api/account/:method',
@@ -313,9 +353,14 @@ class Router
                     array('action' => 'api',
                           'apiaction' => 'laconica'));
 
+        // search
+        $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
+        $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
+        $m->connect('api/trends.json', array('action' => 'twitapitrends'));
+
         // user stuff
 
-        foreach (array('subscriptions', 'subscribers',
+      foreach (array('subscriptions', 'subscribers',
                        'nudge', 'xrds', 'all', 'foaf',
                        'replies', 'inbox', 'outbox', 'microsummary') as $a) {
             $m->connect(':nickname/'.$a,
@@ -355,6 +400,8 @@ class Router
                     array('action' => 'showstream'),
                     array('nickname' => '[a-zA-Z0-9]{1,64}'));
 
+        Event::handle('RouterInitialized', array($m));
+
         return $m;
     }
 
@@ -384,4 +431,4 @@ class Router
 
         return $this->m->generate($args, $params, $fragment);
     }
-}
\ No newline at end of file
+}