3 * GNU Social - a federating social network
4 * Copyright (C) 2014, Free Software Foundation, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('GNUSOCIAL')) { exit(1); }
24 * @maintainer Mikael Nordfeldth <mmn@hethane.se>
26 class FavoritePlugin extends Plugin
28 public function onRouterInitialized(URLMapper $m)
31 $m->connect('main/favor', array('action' => 'favor'));
32 $m->connect('main/disfavor', array('action' => 'disfavor'));
34 if (common_config('singleuser', 'enabled')) {
35 $nickname = User::singleUserNickname();
37 $m->connect('favorites',
38 array('action' => 'showfavorites',
39 'nickname' => $nickname));
40 $m->connect('favoritesrss',
41 array('action' => 'favoritesrss',
42 'nickname' => $nickname));
44 $m->connect('favoritedrss', array('action' => 'favoritedrss'));
45 $m->connect('favorited/', array('action' => 'favorited'));
46 $m->connect('favorited', array('action' => 'favorited'));
48 $m->connect(':nickname/favorites',
49 array('action' => 'showfavorites'),
50 array('nickname' => Nickname::DISPLAY_FMT));
51 $m->connect(':nickname/favorites/rss',
52 array('action' => 'favoritesrss'),
53 array('nickname' => Nickname::DISPLAY_FMT));
57 $m->connect('api/favorites/create.:format',
58 array('action' => 'ApiFavoriteCreate',
59 'format' => '(xml|json)'));
60 $m->connect('api/favorites/destroy.:format',
61 array('action' => 'ApiFavoriteDestroy',
62 'format' => '(xml|json)'));
63 $m->connect('api/favorites/list.:format',
64 array('action' => 'ApiTimelineFavorites',
65 'format' => '(xml|json|rss|atom|as)'));
66 $m->connect('api/favorites/:id.:format',
67 array('action' => 'ApiTimelineFavorites',
68 'id' => Nickname::INPUT_FMT,
69 'format' => '(xml|json|rss|atom|as)'));
70 $m->connect('api/favorites.:format',
71 array('action' => 'ApiTimelineFavorites',
72 'format' => '(xml|json|rss|atom|as)'));
73 $m->connect('api/favorites/create/:id.:format',
74 array('action' => 'ApiFavoriteCreate',
76 'format' => '(xml|json)'));
77 $m->connect('api/favorites/destroy/:id.:format',
78 array('action' => 'ApiFavoriteDestroy',
80 'format' => '(xml|json)'));
83 $m->connect('api/statusnet/app/favorites/:profile/:notice.atom',
84 array('action' => 'AtomPubShowFavorite'),
85 array('profile' => '[0-9]+',
86 'notice' => '[0-9]+'));
88 $m->connect('api/statusnet/app/favorites/:profile.atom',
89 array('action' => 'AtomPubFavoriteFeed'),
90 array('profile' => '[0-9]+'));
92 // Required for qvitter API
93 $m->connect('api/statuses/favs/:id.:format',
94 array('action' => 'ApiStatusesFavs',
96 'format' => '(xml|json)'));
99 public function onPluginVersion(array &$versions)
101 $versions[] = array('name' => 'Favorite',
102 'version' => GNUSOCIAL_VERSION,
103 'author' => 'Mikael Nordfeldth',
104 'homepage' => 'http://gnu.io/',
106 // TRANS: Plugin description.
107 _m('Favorites (likes) using ActivityStreams.'));