]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
Properly unlink all old avatars when deleting/uploading a new
[quix0rs-gnu-social.git] / lib / router.php
index fa34b17537f335e50b9c4ab21d73ff318e7ee58e..0180594e26ecdf9350d3c093dd1981bbb3f1eefc 100644 (file)
@@ -124,6 +124,20 @@ class Router
                         array('user_id' => '[0-9]+',
                               'token' => '.+'));
 
+            // these take a code; before the main part
+
+            foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
+                $m->connect('main/'.$c.'/:code', array('action' => $c));
+            }
+
+            // Also need a block variant accepting ID on URL for mail links
+            $m->connect('main/block/:profileid',
+                        array('action' => 'block'),
+                        array('profileid' => '[0-9]+'));
+
+            $m->connect('main/sup/:seconds', array('action' => 'sup'),
+                        array('seconds' => '[0-9]+'));
+
             // main stuff is repetitive
 
             $main = array('login', 'logout', 'register', 'subscribe',
@@ -142,39 +156,23 @@ class Router
                           'backupaccount',
                           'deleteaccount',
                           'restoreaccount',
+                          'top',
             );
 
             foreach ($main as $a) {
                 $m->connect('main/'.$a, array('action' => $a));
             }
 
-            // Also need a block variant accepting ID on URL for mail links
-            $m->connect('main/block/:profileid',
-                        array('action' => 'block'),
-                        array('profileid' => '[0-9]+'));
-
-            $m->connect('main/sup/:seconds', array('action' => 'sup'),
-                        array('seconds' => '[0-9]+'));
-
-            $m->connect('main/tagprofile', array('action' => 'tagprofile'));
             $m->connect('main/tagprofile/:id', array('action' => 'tagprofile'),
                                                array('id' => '[0-9]+'));
 
+            $m->connect('main/tagprofile', array('action' => 'tagprofile'));
+
             $m->connect('main/oembed',
                         array('action' => 'oembed'));
 
             $m->connect('main/xrds',
                         array('action' => 'publicxrds'));
-            $m->connect('.well-known/host-meta',
-                        array('action' => 'hostmeta'));
-            $m->connect('main/xrd',
-                        array('action' => 'userxrd'));
-
-            // these take a code
-
-            foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
-                $m->connect('main/'.$c.'/:code', array('action' => $c));
-            }
 
             // settings
 
@@ -183,6 +181,10 @@ class Router
                 $m->connect('settings/'.$s, array('action' => $s.'settings'));
             }
 
+            if (common_config('oldschool', 'enabled')) {
+                $m->connect('settings/oldschool', array('action' => 'oldschoolsettings'));
+            }
+
             $m->connect('settings/oauthapps/show/:id',
                         array('action' => 'showapplication'),
                         array('id' => '[0-9]+')
@@ -202,18 +204,18 @@ class Router
             // search
 
             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/'.$s, array('action' => $s.'search'));
             }
 
             // The second of these is needed to make the link work correctly
             // when inserted into the page. The first is needed to match the
             // route on the way in. Seems to be another Net_URL_Mapper bug to me.
-            $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
             $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
                         array('q' => '.+'));
+            $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
 
             $m->connect('attachment/:attachment',
                         array('action' => 'attachment'),
@@ -273,10 +275,12 @@ class Router
                         array('action' => 'userbyid'),
                         array('id' => '[0-9]+'));
 
-            $m->connect('tags/', array('action' => 'publictagcloud'));
-            $m->connect('tag/', array('action' => 'publictagcloud'));
-            $m->connect('tags', array('action' => 'publictagcloud'));
-            $m->connect('tag', array('action' => 'publictagcloud'));
+            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));
@@ -327,6 +331,10 @@ class Router
                         array('action' => 'showgroup'),
                         array('nickname' => Nickname::DISPLAY_FMT));
 
+            $m->connect('group/:nickname/',
+                        array('action' => 'showgroup'),
+                        array('nickname' => Nickname::DISPLAY_FMT));
+
             $m->connect('group/', array('action' => 'groups'));
             $m->connect('group', array('action' => 'groups'));
             $m->connect('groups/', array('action' => 'groups'));
@@ -810,6 +818,22 @@ class Router
                         array('action' => 'getfile'),
                         array('filename' => '[A-Za-z0-9._-]+'));
 
+            // Common people-tag stuff
+
+            $m->connect('peopletag/:tag', array('action' => 'peopletag',
+                                                'tag'    => self::REGEX_TAG));
+
+            $m->connect('selftag/:tag', array('action' => 'selftag',
+                                              'tag'    => self::REGEX_TAG));
+
+            $m->connect('main/addpeopletag', array('action' => 'addpeopletag'));
+
+            $m->connect('main/removepeopletag', array('action' => 'removepeopletag'));
+
+            $m->connect('main/profilecompletion', array('action' => 'profilecompletion'));
+
+            $m->connect('main/peopletagautocomplete', array('action' => 'peopletagautocomplete'));
+
             // In the "root"
 
             if (common_config('singleuser', 'enabled')) {
@@ -818,7 +842,7 @@ class Router
 
                 foreach (array('subscriptions', 'subscribers',
                                'all', 'foaf', 'replies',
-                               'microsummary', 'hcard') as $a) {
+                               'microsummary') as $a) {
                     $m->connect($a,
                                 array('action' => $a,
                                       'nickname' => $nickname));
@@ -851,10 +875,13 @@ class Router
                             array('action' => 'showfavorites',
                                   'nickname' => $nickname));
 
+                $m->connect('avatar',
+                            array('action' => 'avatarbynickname',
+                                  'nickname' => $nickname));
                 $m->connect('avatar/:size',
                             array('action' => 'avatarbynickname',
                                   'nickname' => $nickname),
-                            array('size' => '(original|96|48|24)'));
+                            array('size' => '(|original|\d+)'));
 
                 $m->connect('tag/:tag/rss',
                             array('action' => 'userrss',
@@ -873,6 +900,57 @@ class Router
                 $m->connect('',
                             array('action' => 'showstream',
                                   'nickname' => $nickname));
+
+                // peopletags
+
+                $m->connect('peopletags',
+                            array('action' => 'peopletagsbyuser'));
+
+                $m->connect('peopletags/private',
+                            array('action' => 'peopletagsbyuser',
+                                  'private' => 1));
+
+                $m->connect('peopletags/public',
+                            array('action' => 'peopletagsbyuser',
+                                  'public' => 1));
+
+                $m->connect('othertags',
+                            array('action' => 'peopletagsforuser'));
+
+                $m->connect('peopletagsubscriptions',
+                            array('action' => 'peopletagsubscriptions'));
+
+                $m->connect('all/:tag/subscribers',
+                            array('action' => 'peopletagsubscribers',
+                                  'tag' => self::REGEX_TAG));
+
+                $m->connect('all/:tag/tagged',
+                                array('action' => 'peopletagged',
+                                      'tag' => self::REGEX_TAG));
+
+                $m->connect('all/:tag/edit',
+                                array('action' => 'editpeopletag',
+                                      'tag' => self::REGEX_TAG));
+
+                foreach(array('subscribe', 'unsubscribe') as $v) {
+                    $m->connect('peopletag/:id/'.$v,
+                                    array('action' => $v.'peopletag',
+                                          'id' => '[0-9]{1,64}'));
+                }
+                $m->connect('user/:tagger_id/profiletag/:id/id',
+                                array('action' => 'profiletagbyid',
+                                      'tagger_id' => '[0-9]+',
+                                      'id' => '[0-9]+'));
+
+                $m->connect('all/:tag',
+                                array('action' => 'showprofiletag',
+                                      'tag' => self::REGEX_TAG));
+
+                foreach (array('subscriptions', 'subscribers') as $a) {
+                    $m->connect($a.'/:tag',
+                                array('action' => $a),
+                                array('tag' => self::REGEX_TAG));
+                }
             } else {
                 $m->connect('', array('action' => 'public'));
                 $m->connect('rss', array('action' => 'publicrss'));
@@ -886,7 +964,7 @@ class Router
 
                 foreach (array('subscriptions', 'subscribers',
                                'nudge', 'all', 'foaf', 'replies',
-                               'inbox', 'outbox', 'microsummary', 'hcard') as $a) {
+                               'inbox', 'outbox', 'microsummary') as $a) {
                     $m->connect(':nickname/'.$a,
                                 array('action' => $a),
                                 array('nickname' => Nickname::DISPLAY_FMT));
@@ -897,22 +975,6 @@ class Router
 
                 // people tags
 
-                $m->connect('peopletags', array('action' => 'publicpeopletagcloud'));
-
-                $m->connect('peopletag/:tag', array('action' => 'peopletag',
-                                                    'tag'    => self::REGEX_TAG));
-
-                $m->connect('selftag/:tag', array('action' => 'selftag',
-                                                  'tag'    => self::REGEX_TAG));
-
-                $m->connect('main/addpeopletag', array('action' => 'addpeopletag'));
-
-                $m->connect('main/removepeopletag', array('action' => 'removepeopletag'));
-
-                $m->connect('main/profilecompletion', array('action' => 'profilecompletion'));
-
-                $m->connect('main/peopletagautocomplete', array('action' => 'peopletagautocomplete'));
-
                 $m->connect(':nickname/peopletags',
                                 array('action' => 'peopletagsbyuser',
                                       'nickname' => Nickname::DISPLAY_FMT));
@@ -988,9 +1050,12 @@ class Router
                             array('action' => 'showfavorites'),
                             array('nickname' => Nickname::DISPLAY_FMT));
 
+                $m->connect(':nickname/avatar',
+                            array('action' => 'avatarbynickname'),
+                            array('nickname' => Nickname::DISPLAY_FMT));
                 $m->connect(':nickname/avatar/:size',
                             array('action' => 'avatarbynickname'),
-                            array('size' => '(original|96|48|24)',
+                            array('size' => '(|original|\d+)',
                                   'nickname' => Nickname::DISPLAY_FMT));
 
                 $m->connect(':nickname/tag/:tag/rss',
@@ -1010,6 +1075,10 @@ class Router
                 $m->connect(':nickname',
                             array('action' => 'showstream'),
                             array('nickname' => Nickname::DISPLAY_FMT));
+
+                $m->connect(':nickname/',
+                            array('action' => 'showstream'),
+                            array('nickname' => Nickname::DISPLAY_FMT));
             }
 
             // AtomPub API