X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Frouter.php;h=be87afd88d647ab8187b4a53c26f8a2b941a326b;hb=d1fc7c0774b4b8883f90c0202c67285ef34be322;hp=ca8daf5a906f65744ace2d77d8bbea7c1850e5c3;hpb=6f0f8cd6c70e1de7ade3d2b26d36ed4cd4197769;p=quix0rs-gnu-social.git diff --git a/lib/router.php b/lib/router.php index ca8daf5a90..be87afd88d 100644 --- a/lib/router.php +++ b/lib/router.php @@ -27,9 +27,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * URL Router @@ -108,6 +106,11 @@ class Router if (Event::handle('StartInitializeRouter', array(&$m))) { + // top of the menu hierarchy, sometimes "Home" + $m->connect('', array('action' => 'top')); + + // public endpoints + $m->connect('robots.txt', array('action' => 'robotstxt')); $m->connect('opensearch/people', array('action' => 'opensearch', @@ -156,13 +159,13 @@ class Router 'deleteaccount', 'restoreaccount', 'top', + 'public', ); foreach ($main as $a) { $m->connect('main/'.$a, array('action' => $a)); } - $m->connect('main/public', array('action' => 'public')); $m->connect('main/all', array('action' => 'networkpublic')); $m->connect('main/tagprofile/:id', array('action' => 'tagprofile'), @@ -220,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]+')); @@ -239,12 +246,10 @@ class Router array('action' => 'shownotice'), array('notice' => '[0-9]+')); - $m->connect('notice/delete/:notice', + $m->connect('notice/:notice/delete', array('action' => 'deletenotice'), array('notice' => '[0-9]+')); - $m->connect('notice/delete', array('action' => 'deletenotice')); - // conversation $m->connect('conversation/:id', @@ -255,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)); @@ -421,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', @@ -763,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')); @@ -824,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)); @@ -875,9 +881,6 @@ class Router array('action' => 'rsd', 'nickname' => $nickname)); - $m->connect('', - array('action' => 'startpage')); - // peopletags $m->connect('peopletags', @@ -921,6 +924,7 @@ class Router $m->connect('all/:tag', array('action' => 'showprofiletag', + 'tagger' => $nickname, 'tag' => self::REGEX_TAG)); foreach (array('subscriptions', 'subscribers') as $a) { @@ -930,9 +934,6 @@ class Router } } - $m->connect('', array('action' => 'startpage')); - $m->connect('main/public', array('action' => 'public')); - $m->connect('main/all', array('action' => 'networkpublic')); $m->connect('rss', array('action' => 'publicrss')); $m->connect('featuredrss', array('action' => 'featuredrss')); $m->connect('featured/', array('action' => 'featured')); @@ -941,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)); @@ -950,6 +951,13 @@ class Router array('action' => 'subqueue'), array('nickname' => Nickname::DISPLAY_FMT)); + // some targeted RSS 1.0 actions (extends TargetedRss10Action) + foreach (array('all', 'replies') as $a) { + $m->connect(':nickname/'.$a.'/rss', + array('action' => $a.'rss'), + array('nickname' => Nickname::DISPLAY_FMT)); + } + // people tags $m->connect(':nickname/peopletags', @@ -999,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) { @@ -1017,12 +1025,6 @@ class Router array('nickname' => Nickname::DISPLAY_FMT)); } - foreach (array('all', 'replies') as $a) { - $m->connect(':nickname/'.$a.'/rss', - array('action' => $a.'rss'), - array('nickname' => Nickname::DISPLAY_FMT)); - } - $m->connect(':nickname/avatar', array('action' => 'avatarbynickname'), array('nickname' => Nickname::DISPLAY_FMT)); @@ -1097,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)