* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* URL 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',
'sandbox', 'unsandbox',
'silence', 'unsilence',
'grantrole', 'revokerole',
- 'repeat',
'deleteuser',
'geocode',
'version',
'deleteaccount',
'restoreaccount',
'top',
+ 'public',
);
foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a));
}
+ $m->connect('main/all', array('action' => 'networkpublic'));
+
$m->connect('main/tagprofile/:id', array('action' => 'tagprofile'),
array('id' => '[0-9]+'));
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]+'));
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',
array('action' => 'conversation'),
array('id' => '[0-9]+'));
- $m->connect('message/new', array('action' => 'newmessage'));
- $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => Nickname::DISPLAY_FMT));
- $m->connect('message/:message',
- array('action' => 'showmessage'),
- array('message' => '[0-9]+'));
-
$m->connect('user/:id',
array('action' => 'userbyid'),
array('id' => '[0-9]+'));
array('action' => 'ApiTimelinePublic',
'format' => '(xml|json|rss|atom|as)'));
+ // this is not part of the Twitter API. Also may require authentication depending on server config!
+ $m->connect('api/statuses/networkpublic_timeline.:format',
+ array('action' => 'ApiTimelineNetworkPublic',
+ 'format' => '(xml|json|rss|atom|as)'));
+
$m->connect('api/statuses/friends_timeline/:id.:format',
array('action' => 'ApiTimelineFriends',
'id' => Nickname::INPUT_FMT,
array('action' => 'ApiTimelineMentions',
'format' => '(xml|json|rss|atom|as)'));
- $m->connect('api/statuses/retweeted_by_me.:format',
- array('action' => 'ApiTimelineRetweetedByMe',
- 'format' => '(xml|json|atom|as)'));
-
- $m->connect('api/statuses/retweeted_to_me.:format',
- array('action' => 'ApiTimelineRetweetedToMe',
- 'format' => '(xml|json|atom|as)'));
-
- $m->connect('api/statuses/retweets_of_me.:format',
- array('action' => 'ApiTimelineRetweetsOfMe',
- 'format' => '(xml|json|atom|as)'));
-
$m->connect('api/statuses/friends/:id.:format',
array('action' => 'ApiUserFriends',
'id' => Nickname::INPUT_FMT,
array('action' => 'ApiStatusesDestroy',
'format' => '(xml|json)'));
- $m->connect('api/statuses/retweet/:id.:format',
- array('action' => 'ApiStatusesRetweet',
- 'id' => '[0-9]+',
- 'format' => '(xml|json)'));
-
- $m->connect('api/statuses/retweets/:id.:format',
- array('action' => 'ApiStatusesRetweets',
- 'id' => '[0-9]+',
- 'format' => '(xml|json)'));
-
// START qvitter API additions
$m->connect('api/attachment/:id.:format',
'screen_name' => Nickname::DISPLAY_FMT,
'format' => '(xml|json)'));
- // direct messages
-
- $m->connect('api/direct_messages.:format',
- array('action' => 'ApiDirectMessage',
- 'format' => '(xml|json|rss|atom)'));
-
- $m->connect('api/direct_messages/sent.:format',
- array('action' => 'ApiDirectMessage',
- 'format' => '(xml|json|rss|atom)',
- 'sent' => true));
-
- $m->connect('api/direct_messages/new.:format',
- array('action' => 'ApiDirectMessageNew',
- 'format' => '(xml|json)'));
-
// friendships
$m->connect('api/friendships/show.:format',
'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'));
foreach (array('subscriptions', 'subscribers',
'all', 'foaf', 'replies',
- 'microsummary') as $a) {
+ ) as $a) {
$m->connect($a,
array('action' => $a,
'nickname' => $nickname));
array('action' => 'rsd',
'nickname' => $nickname));
- $m->connect('',
- array('action' => 'showstream',
- 'nickname' => $nickname));
-
// peopletags
$m->connect('peopletags',
$m->connect('all/:tag',
array('action' => 'showprofiletag',
+ 'nickname' => $nickname,
'tag' => self::REGEX_TAG));
foreach (array('subscriptions', 'subscribers') as $a) {
array('action' => $a),
array('tag' => self::REGEX_TAG));
}
- } else {
- $m->connect('', array('action' => 'public'));
- $m->connect('rss', array('action' => 'publicrss'));
- $m->connect('featuredrss', array('action' => 'featuredrss'));
- $m->connect('featured/', array('action' => 'featured'));
- $m->connect('featured', array('action' => 'featured'));
- $m->connect('rsd.xml', array('action' => 'rsd'));
+ }
- foreach (array('subscriptions', 'subscribers',
- 'nudge', 'all', 'foaf', 'replies',
- 'inbox', 'outbox', 'microsummary') as $a) {
- $m->connect(':nickname/'.$a,
- array('action' => $a),
- array('nickname' => Nickname::DISPLAY_FMT));
- }
- $m->connect(':nickname/subscribers/pending',
- array('action' => 'subqueue'),
+ $m->connect('rss', array('action' => 'publicrss'));
+ $m->connect('featuredrss', array('action' => 'featuredrss'));
+ $m->connect('featured/', array('action' => 'featured'));
+ $m->connect('featured', array('action' => 'featured'));
+ $m->connect('rsd.xml', array('action' => 'rsd'));
+
+ foreach (array('subscriptions', 'subscribers',
+ 'nudge', 'all', 'foaf', 'replies',
+ 'inbox', 'outbox') as $a) {
+ $m->connect(':nickname/'.$a,
+ array('action' => $a),
array('nickname' => Nickname::DISPLAY_FMT));
+ }
+ $m->connect(':nickname/subscribers/pending',
+ array('action' => 'subqueue'),
+ array('nickname' => Nickname::DISPLAY_FMT));
- // people tags
-
- $m->connect(':nickname/peopletags',
- array('action' => 'peopletagsbyuser',
- 'nickname' => Nickname::DISPLAY_FMT));
-
- $m->connect(':nickname/peopletags/private',
- array('action' => 'peopletagsbyuser',
- 'nickname' => Nickname::DISPLAY_FMT,
- 'private' => 1));
+ // 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));
+ }
- $m->connect(':nickname/peopletags/public',
- array('action' => 'peopletagsbyuser',
- 'nickname' => Nickname::DISPLAY_FMT,
- 'public' => 1));
+ // people tags
- $m->connect(':nickname/othertags',
- array('action' => 'peopletagsforuser',
- 'nickname' => Nickname::DISPLAY_FMT));
+ $m->connect(':nickname/peopletags',
+ array('action' => 'peopletagsbyuser',
+ 'nickname' => Nickname::DISPLAY_FMT));
- $m->connect(':nickname/peopletagsubscriptions',
- array('action' => 'peopletagsubscriptions',
- 'nickname' => Nickname::DISPLAY_FMT));
+ $m->connect(':nickname/peopletags/private',
+ array('action' => 'peopletagsbyuser',
+ 'nickname' => Nickname::DISPLAY_FMT,
+ 'private' => 1));
- $m->connect(':tagger/all/:tag/subscribers',
- array('action' => 'peopletagsubscribers',
- 'tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG));
+ $m->connect(':nickname/peopletags/public',
+ array('action' => 'peopletagsbyuser',
+ 'nickname' => Nickname::DISPLAY_FMT,
+ 'public' => 1));
- $m->connect(':tagger/all/:tag/tagged',
- array('action' => 'peopletagged',
- 'tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG));
+ $m->connect(':nickname/othertags',
+ array('action' => 'peopletagsforuser',
+ 'nickname' => Nickname::DISPLAY_FMT));
- $m->connect(':tagger/all/:tag/edit',
- array('action' => 'editpeopletag',
- 'tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG));
+ $m->connect(':nickname/peopletagsubscriptions',
+ array('action' => 'peopletagsubscriptions',
+ 'nickname' => Nickname::DISPLAY_FMT));
- 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(':tagger/all/:tag/subscribers',
+ array('action' => 'peopletagsubscribers',
+ 'tagger' => Nickname::DISPLAY_FMT,
+ 'tag' => self::REGEX_TAG));
- $m->connect(':tagger/all/:tag',
- array('action' => 'showprofiletag',
- 'tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG));
+ $m->connect(':tagger/all/:tag/tagged',
+ array('action' => 'peopletagged',
+ 'tagger' => Nickname::DISPLAY_FMT,
+ 'tag' => self::REGEX_TAG));
- foreach (array('subscriptions', 'subscribers') as $a) {
- $m->connect(':nickname/'.$a.'/:tag',
- array('action' => $a),
- array('tag' => self::REGEX_TAG,
- 'nickname' => Nickname::DISPLAY_FMT));
- }
+ $m->connect(':tagger/all/:tag/edit',
+ array('action' => 'editpeopletag',
+ 'tagger' => Nickname::DISPLAY_FMT,
+ 'tag' => self::REGEX_TAG));
- foreach (array('rss', 'groups') as $a) {
- $m->connect(':nickname/'.$a,
- array('action' => 'user'.$a),
- array('nickname' => Nickname::DISPLAY_FMT));
- }
+ 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(':nickname/all/:tag',
+ array('action' => 'showprofiletag'),
+ array('nickname' => Nickname::DISPLAY_FMT,
+ 'tag' => self::REGEX_TAG));
- foreach (array('all', 'replies') as $a) {
- $m->connect(':nickname/'.$a.'/rss',
- array('action' => $a.'rss'),
- array('nickname' => Nickname::DISPLAY_FMT));
- }
+ foreach (array('subscriptions', 'subscribers') as $a) {
+ $m->connect(':nickname/'.$a.'/:tag',
+ array('action' => $a),
+ array('tag' => self::REGEX_TAG,
+ 'nickname' => Nickname::DISPLAY_FMT));
+ }
- $m->connect(':nickname/avatar',
- array('action' => 'avatarbynickname'),
+ foreach (array('rss', 'groups') as $a) {
+ $m->connect(':nickname/'.$a,
+ array('action' => 'user'.$a),
array('nickname' => Nickname::DISPLAY_FMT));
- $m->connect(':nickname/avatar/:size',
- array('action' => 'avatarbynickname'),
- array('size' => '(|original|\d+)',
- 'nickname' => Nickname::DISPLAY_FMT));
+ }
- $m->connect(':nickname/tag/:tag/rss',
- array('action' => 'userrss'),
- array('nickname' => Nickname::DISPLAY_FMT),
- array('tag' => self::REGEX_TAG));
+ $m->connect(':nickname/avatar',
+ array('action' => 'avatarbynickname'),
+ array('nickname' => Nickname::DISPLAY_FMT));
+ $m->connect(':nickname/avatar/:size',
+ array('action' => 'avatarbynickname'),
+ array('size' => '(|original|\d+)',
+ 'nickname' => Nickname::DISPLAY_FMT));
+
+ $m->connect(':nickname/tag/:tag/rss',
+ array('action' => 'userrss'),
+ array('nickname' => Nickname::DISPLAY_FMT),
+ array('tag' => self::REGEX_TAG));
- $m->connect(':nickname/tag/:tag',
- array('action' => 'showstream'),
- array('nickname' => Nickname::DISPLAY_FMT),
- array('tag' => self::REGEX_TAG));
+ $m->connect(':nickname/tag/:tag',
+ array('action' => 'showstream'),
+ array('nickname' => Nickname::DISPLAY_FMT),
+ array('tag' => self::REGEX_TAG));
- $m->connect(':nickname/rsd.xml',
- array('action' => 'rsd'),
- array('nickname' => Nickname::DISPLAY_FMT));
+ $m->connect(':nickname/rsd.xml',
+ array('action' => 'rsd'),
+ array('nickname' => Nickname::DISPLAY_FMT));
- $m->connect(':nickname',
- array('action' => 'showstream'),
- array('nickname' => Nickname::DISPLAY_FMT));
+ $m->connect(':nickname',
+ array('action' => 'showstream'),
+ array('nickname' => Nickname::DISPLAY_FMT));
- $m->connect(':nickname/',
- array('action' => 'showstream'),
- array('nickname' => Nickname::DISPLAY_FMT));
- }
+ $m->connect(':nickname/',
+ array('action' => 'showstream'),
+ array('nickname' => Nickname::DISPLAY_FMT));
// AtomPub API
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)