]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
Merge branch 'issue-326' into 'master'
[quix0rs-gnu-social.git] / lib / router.php
index b13c51c32834c92fb24facdbfeccc59454699871..ab6595b8f8a51b44bd12692f2ef261b4a512bd14 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * URL Router
@@ -225,6 +223,10 @@ class Router
                         array('action' => 'attachment'),
                         array('attachment' => '[0-9]+'));
 
+            $m->connect('attachment/:attachment/download',
+                        array('action' => 'attachment_download'),
+                        array('attachment' => '[0-9]+'));
+
             $m->connect('attachment/:attachment/thumbnail',
                         array('action' => 'attachment_thumbnail'),
                         array('attachment' => '[0-9]+'));
@@ -258,12 +260,6 @@ class Router
                         array('action' => 'userbyid'),
                         array('id' => '[0-9]+'));
 
-            if (!common_config('performance', 'high')) {
-                $m->connect('tags/', array('action' => 'publictagcloud'));
-                $m->connect('tag/', array('action' => 'publictagcloud'));
-                $m->connect('tags', array('action' => 'publictagcloud'));
-                $m->connect('tag', array('action' => 'publictagcloud'));
-            }
             $m->connect('tag/:tag/rss',
                         array('action' => 'tagrss'),
                         array('tag' => self::REGEX_TAG));
@@ -424,7 +420,7 @@ class Router
 
             $m->connect('api/statuses/update.:format',
                         array('action' => 'ApiStatusesUpdate',
-                              'format' => '(xml|json)'));
+                              'format' => '(xml|json|atom)'));
 
             $m->connect('api/statuses/destroy/:id.:format',
                         array('action' => 'ApiStatusesDestroy',
@@ -766,6 +762,13 @@ class Router
                 'api/statuses/update_with_media.json',
                 array('action' => 'ApiMediaUpload')
             );
+            // Twitter Media upload API v1.1
+            $m->connect(
+                'api/media/upload.:format',
+                array('action' => 'ApiMediaUpload',
+                      'format' => '(xml|json)',
+                      )
+            );
 
             // search
             $m->connect('api/search.atom', array('action' => 'ApiSearchAtom'));
@@ -827,7 +830,7 @@ class Router
 
                 foreach (array('subscriptions', 'subscribers',
                                'all', 'foaf', 'replies',
-                               'microsummary') as $a) {
+                               ) as $a) {
                     $m->connect($a,
                                 array('action' => $a,
                                       'nickname' => $nickname));
@@ -921,6 +924,7 @@ class Router
 
                 $m->connect('all/:tag',
                                 array('action' => 'showprofiletag',
+                                      'nickname' => $nickname,
                                       'tag' => self::REGEX_TAG));
 
                 foreach (array('subscriptions', 'subscribers') as $a) {
@@ -938,7 +942,7 @@ class Router
 
             foreach (array('subscriptions', 'subscribers',
                            'nudge', 'all', 'foaf', 'replies',
-                           'inbox', 'outbox', 'microsummary') as $a) {
+                           'inbox', 'outbox') as $a) {
                 $m->connect(':nickname/'.$a,
                             array('action' => $a),
                             array('nickname' => Nickname::DISPLAY_FMT));
@@ -1003,9 +1007,9 @@ class Router
                                   'tagger_id' => '[0-9]+',
                                   'id' => '[0-9]+'));
 
-            $m->connect(':tagger/all/:tag',
-                            array('action' => 'showprofiletag',
-                                  'tagger' => Nickname::DISPLAY_FMT,
+            $m->connect(':nickname/all/:tag',
+                            array('action' => 'showprofiletag'),
+                            array('nickname' => Nickname::DISPLAY_FMT,
                                   'tag' => self::REGEX_TAG));
 
             foreach (array('subscriptions', 'subscribers') as $a) {
@@ -1095,16 +1099,12 @@ class Router
     function map($path)
     {
         try {
-            $match = $this->m->match($path);
-        } catch (Exception $e) {
-            common_log(LOG_ERR, "Problem getting route for $path - " .
-                       $e->getMessage());
+            return $this->m->match($path);
+        } catch (NoRouteMapException $e) {
+            common_debug($e->getMessage());
             // TRANS: Client error on action trying to visit a non-existing page.
-            $cac = new ClientErrorAction(_('Page not found.'), 404);
-            $cac->showPage();
+            throw new ClientException(_('Page not found.'), 404);
         }
-
-        return $match;
     }
 
     function build($action, $args=null, $params=null, $fragment=null)