From fec3aaf9b2f0d6feedb5267586f3a4c5b5bafa31 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 30 Dec 2017 00:19:45 -0500 Subject: [PATCH] Add Feed module - Update profile alternate links --- mod/profile.php | 4 +++- src/Module/Feed.php | 53 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/Module/Feed.php diff --git a/mod/profile.php b/mod/profile.php index 9b609f885a..843f06de3e 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -64,7 +64,9 @@ function profile_init(App $a) } $a->page['htmlhead'] .= '' . "\r\n"; - $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : '')); $a->page['htmlhead'] .= '' . "\r\n"; header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); diff --git a/src/Module/Feed.php b/src/Module/Feed.php new file mode 100644 index 0000000000..a8101e8061 --- /dev/null +++ b/src/Module/Feed.php @@ -0,0 +1,53 @@ + posts + * - /feed/[nickname]/posts => posts + * - /feed/[nickname]/comments => comments + * - /feed/[nickname]/replies => comments + * - /feed/[nickname]/activity => activity + * + * @brief Provides public Atom feeds + * + * @author Hypolite Petovan + */ +class Feed extends BaseModule +{ + public static function content() + { + $a = self::getApp(); + + $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : ''; + $nocache = x($_GET, 'nocache') && local_user(); + + $type = null; + if ($a->argc > 2) { + $type = $a->argv[2]; + } + + switch ($type) { + case 'posts': + case 'comments': + case 'activity': + break; + case 'replies': + $type = 'comments'; + break; + default: + $type = 'posts'; + } + + $nickname = $a->argv[1]; + header("Content-type: application/atom+xml"); + echo OStatus::feed($nickname, $last_update, 10, $type, $nocache); + killme(); + } +} -- 2.39.5