From ffe5702dc3685483e763d5c776c9812d9654c320 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Sep 2011 19:20:55 -0400 Subject: [PATCH] Move more specific routes ahead of more general routes A lot of API routes have versions with or without params. I moved the ones with params up so they match correctly. --- lib/router.php | 144 +++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 71 deletions(-) diff --git a/lib/router.php b/lib/router.php index 606b30e916..1647bfbb7c 100644 --- a/lib/router.php +++ b/lib/router.php @@ -341,17 +341,13 @@ class Router array('action' => 'ApiTimelinePublic', 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statuses/friends_timeline.:format', - array('action' => 'ApiTimelineFriends', - 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statuses/friends_timeline/:id.:format', array('action' => 'ApiTimelineFriends', 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statuses/home_timeline.:format', - array('action' => 'ApiTimelineHome', + $m->connect('api/statuses/friends_timeline.:format', + array('action' => 'ApiTimelineFriends', 'format' => '(xml|json|rss|atom|as)')); $m->connect('api/statuses/home_timeline/:id.:format', @@ -359,8 +355,8 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statuses/user_timeline.:format', - array('action' => 'ApiTimelineUser', + $m->connect('api/statuses/home_timeline.:format', + array('action' => 'ApiTimelineHome', 'format' => '(xml|json|rss|atom|as)')); $m->connect('api/statuses/user_timeline/:id.:format', @@ -368,8 +364,8 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statuses/mentions.:format', - array('action' => 'ApiTimelineMentions', + $m->connect('api/statuses/user_timeline.:format', + array('action' => 'ApiTimelineUser', 'format' => '(xml|json|rss|atom|as)')); $m->connect('api/statuses/mentions/:id.:format', @@ -377,7 +373,7 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statuses/replies.:format', + $m->connect('api/statuses/mentions.:format', array('action' => 'ApiTimelineMentions', 'format' => '(xml|json|rss|atom|as)')); @@ -386,6 +382,10 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); + $m->connect('api/statuses/replies.:format', + 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)')); @@ -398,17 +398,13 @@ class Router array('action' => 'ApiTimelineRetweetsOfMe', 'format' => '(xml|json|atom|as)')); - $m->connect('api/statuses/friends.:format', - array('action' => 'ApiUserFriends', - 'format' => '(xml|json)')); - $m->connect('api/statuses/friends/:id.:format', array('action' => 'ApiUserFriends', 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/statuses/followers.:format', - array('action' => 'ApiUserFollowers', + $m->connect('api/statuses/friends.:format', + array('action' => 'ApiUserFriends', 'format' => '(xml|json)')); $m->connect('api/statuses/followers/:id.:format', @@ -416,26 +412,30 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/statuses/show.:format', - array('action' => 'ApiStatusesShow', - 'format' => '(xml|json|atom)')); + $m->connect('api/statuses/followers.:format', + array('action' => 'ApiUserFollowers', + 'format' => '(xml|json)')); $m->connect('api/statuses/show/:id.:format', array('action' => 'ApiStatusesShow', 'id' => '[0-9]+', 'format' => '(xml|json|atom)')); + $m->connect('api/statuses/show.:format', + array('action' => 'ApiStatusesShow', + 'format' => '(xml|json|atom)')); + $m->connect('api/statuses/update.:format', array('action' => 'ApiStatusesUpdate', 'format' => '(xml|json)')); - $m->connect('api/statuses/destroy.:format', + $m->connect('api/statuses/destroy/:id.:format', array('action' => 'ApiStatusesDestroy', + 'id' => '[0-9]+', 'format' => '(xml|json)')); - $m->connect('api/statuses/destroy/:id.:format', + $m->connect('api/statuses/destroy.:format', array('action' => 'ApiStatusesDestroy', - 'id' => '[0-9]+', 'format' => '(xml|json)')); $m->connect('api/statuses/retweet/:id.:format', @@ -450,13 +450,13 @@ class Router // users - $m->connect('api/users/show.:format', + $m->connect('api/users/show/:id.:format', array('action' => 'ApiUserShow', + 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/users/show/:id.:format', + $m->connect('api/users/show.:format', array('action' => 'ApiUserShow', - 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); $m->connect('api/users/profile_image/:screen_name.:format', @@ -489,17 +489,13 @@ class Router array('action' => 'ApiFriendshipsExists', 'format' => '(xml|json)')); - $m->connect('api/friendships/create.:format', + $m->connect('api/friendships/create/:id.:format', array('action' => 'ApiFriendshipsCreate', + 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/friendships/destroy.:format', - array('action' => 'ApiFriendshipsDestroy', - 'format' => '(xml|json)')); - - $m->connect('api/friendships/create/:id.:format', + $m->connect('api/friendships/create.:format', array('action' => 'ApiFriendshipsCreate', - 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); $m->connect('api/friendships/destroy/:id.:format', @@ -507,6 +503,10 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); + $m->connect('api/friendships/destroy.:format', + array('action' => 'ApiFriendshipsDestroy', + 'format' => '(xml|json)')); + // Social graph $m->connect('api/friends/ids/:id.:format', @@ -549,13 +549,13 @@ class Router // favorites - $m->connect('api/favorites.:format', + $m->connect('api/favorites/:id.:format', array('action' => 'ApiTimelineFavorites', + 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/favorites/:id.:format', + $m->connect('api/favorites.:format', array('action' => 'ApiTimelineFavorites', - 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); $m->connect('api/favorites/create/:id.:format', @@ -569,23 +569,24 @@ class Router 'format' => '(xml|json)')); // blocks - $m->connect('api/blocks/create.:format', - array('action' => 'ApiBlockCreate', - 'format' => '(xml|json)')); - $m->connect('api/blocks/create/:id.:format', array('action' => 'ApiBlockCreate', 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/blocks/destroy.:format', - array('action' => 'ApiBlockDestroy', + $m->connect('api/blocks/create.:format', + array('action' => 'ApiBlockCreate', 'format' => '(xml|json)')); $m->connect('api/blocks/destroy/:id.:format', array('action' => 'ApiBlockDestroy', 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); + + $m->connect('api/blocks/destroy.:format', + array('action' => 'ApiBlockDestroy', + 'format' => '(xml|json)')); + // help $m->connect('api/help/test.:format', @@ -623,26 +624,21 @@ class Router 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom|as)')); - $m->connect('api/statusnet/groups/show.:format', - array('action' => 'ApiGroupShow', - 'format' => '(xml|json)')); - $m->connect('api/statusnet/groups/show/:id.:format', array('action' => 'ApiGroupShow', 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/statusnet/groups/join.:format', - array('action' => 'ApiGroupJoin', - 'id' => Nickname::INPUT_FMT, + $m->connect('api/statusnet/groups/show.:format', + array('action' => 'ApiGroupShow', 'format' => '(xml|json)')); $m->connect('api/statusnet/groups/join/:id.:format', array('action' => 'ApiGroupJoin', 'format' => '(xml|json)')); - $m->connect('api/statusnet/groups/leave.:format', - array('action' => 'ApiGroupLeave', + $m->connect('api/statusnet/groups/join.:format', + array('action' => 'ApiGroupJoin', 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); @@ -650,30 +646,35 @@ class Router array('action' => 'ApiGroupLeave', 'format' => '(xml|json)')); + $m->connect('api/statusnet/groups/leave.:format', + array('action' => 'ApiGroupLeave', + 'id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)')); + $m->connect('api/statusnet/groups/is_member.:format', array('action' => 'ApiGroupIsMember', 'format' => '(xml|json)')); - $m->connect('api/statusnet/groups/list.:format', + $m->connect('api/statusnet/groups/list/:id.:format', array('action' => 'ApiGroupList', + 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom)')); - $m->connect('api/statusnet/groups/list/:id.:format', + $m->connect('api/statusnet/groups/list.:format', array('action' => 'ApiGroupList', - 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json|rss|atom)')); $m->connect('api/statusnet/groups/list_all.:format', array('action' => 'ApiGroupListAll', 'format' => '(xml|json|rss|atom)')); - $m->connect('api/statusnet/groups/membership.:format', + $m->connect('api/statusnet/groups/membership/:id.:format', array('action' => 'ApiGroupMembership', + 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); - $m->connect('api/statusnet/groups/membership/:id.:format', + $m->connect('api/statusnet/groups/membership.:format', array('action' => 'ApiGroupMembership', - 'id' => Nickname::INPUT_FMT, 'format' => '(xml|json)')); $m->connect('api/statusnet/groups/create.:format', @@ -709,13 +710,9 @@ class Router array('action' => 'ApiListSubscriptions', 'user' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); - $m->connect('api/lists.:format', - array('action' => 'ApiLists', - 'format' => '(xml|json)')); - $m->connect('api/:user/lists.:format', + $m->connect('api/lists.:format', array('action' => 'ApiLists', - 'user' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); $m->connect('api/:user/lists/:id.:format', @@ -724,36 +721,41 @@ class Router 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); + $m->connect('api/:user/lists.:format', + array('action' => 'ApiLists', + 'user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + $m->connect('api/:user/lists/:id/statuses.:format', array('action' => 'ApiTimelineList', 'user' => '[a-zA-Z0-9]+', 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json|rss|atom)')); - $m->connect('api/:user/:list_id/members.:format', - array('action' => 'ApiListMembers', + $m->connect('api/:user/:list_id/members/:id.:format', + array('action' => 'ApiListMember', 'user' => '[a-zA-Z0-9]+', 'list_id' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); - $m->connect('api/:user/:list_id/subscribers.:format', - array('action' => 'ApiListSubscribers', + $m->connect('api/:user/:list_id/members.:format', + array('action' => 'ApiListMembers', 'user' => '[a-zA-Z0-9]+', 'list_id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); - $m->connect('api/:user/:list_id/members/:id.:format', - array('action' => 'ApiListMember', + $m->connect('api/:user/:list_id/subscribers/:id.:format', + array('action' => 'ApiListSubscriber', 'user' => '[a-zA-Z0-9]+', 'list_id' => '[a-zA-Z0-9]+', 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); - $m->connect('api/:user/:list_id/subscribers/:id.:format', - array('action' => 'ApiListSubscriber', + $m->connect('api/:user/:list_id/subscribers.:format', + array('action' => 'ApiListSubscribers', 'user' => '[a-zA-Z0-9]+', 'list_id' => '[a-zA-Z0-9]+', - 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); // Tags -- 2.39.5