]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
ApiTimelineNetworkPublicAction available now
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 29 Jan 2015 21:16:30 +0000 (22:16 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 29 Jan 2015 22:01:53 +0000 (23:01 +0100)
Feeds added in NetworkpublicAction too.

actions/apitimelinenetworkpublic.php [new file with mode: 0644]
actions/apitimelinepublic.php
actions/networkpublic.php
lib/router.php

diff --git a/actions/apitimelinenetworkpublic.php b/actions/apitimelinenetworkpublic.php
new file mode 100644 (file)
index 0000000..a2039a3
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class ApiTimelineNetworkPublicAction extends ApiTimelinePublicAction
+{
+    function title()
+    {
+        return sprintf(_("%s network public timeline"), common_config('site', 'name'));
+    }
+
+    protected function getStream()
+    {
+        return new NetworkPublicNoticeStream($this->scoped);
+    }
+}
index 338cd16fa093eff36a9a0c22081146ceed0cb56b..07dcace942457b254660005ca48b18135c5e837d 100644 (file)
@@ -154,7 +154,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      * @return boolean success flag
      *
      */
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -168,16 +168,20 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      *
      * Just show the notices
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
+        parent::handle();
         $this->showTimeline();
     }
 
+    function title()
+    {
+        // TRANS: Title for site timeline. %s is the GNU social sitename.
+        return sprintf(_("%s public timeline"), common_config('site', 'name'));
+    }
+
     /**
      * Show the timeline of notices
      *
@@ -185,16 +189,16 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
      */
     function showTimeline()
     {
-        $sitename   = common_config('site', 'name');
+        $nonapi_action = substr($this->action, strlen('apitimeline'));  // Just so we don't need to set this explicitly
+
         $sitelogo   = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
-        // TRANS: Title for site timeline. %s is the StatusNet sitename.
-        $title      = sprintf(_("%s public timeline"), $sitename);
+        $title      = $this->title();
         $taguribase = TagURI::base();
-        $id         = "tag:$taguribase:PublicTimeline";
-        $link       = common_local_url('public');
+        $id         = "tag:$taguribase:" . ucfirst($nonapi_action) . 'Timeline';    // Public or Networkpublic probably
+        $link       = common_local_url($nonapi_action);
         $self       = $this->getSelfUri();
-        // TRANS: Subtitle for site timeline. %s is the StatusNet sitename.
-        $subtitle   = sprintf(_("%s updates from everyone!"), $sitename);
+        // TRANS: Subtitle for site timeline. %s is the GNU social sitename.
+        $subtitle   = sprintf(_("%s updates from everyone!"), common_config('site', 'name'));
 
         switch($this->format) {
         case 'xml':
@@ -222,7 +226,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
             $atom->setSubtitle($subtitle);
             $atom->setLogo($sitelogo);
             $atom->setUpdated('now');
-            $atom->addLink(common_local_url('public'));
+            $atom->addLink(common_local_url($nonapi_action));
             $atom->setSelfLink($self);
             $atom->addEntryFromNotices($this->notices);
 
@@ -256,9 +260,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
     {
         $notices = array();
 
-        $profile = ($this->auth_user) ? $this->auth_user->getProfile() : null;
-
-        $stream = new PublicNoticeStream($profile);
+        $stream = $this->getStream();
 
         $notice = $stream->getNotices(($this->page - 1) * $this->count,
                                       $this->count,
@@ -272,6 +274,11 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
         return $notices;
     }
 
+    protected function getStream()
+    {
+        return new PublicNoticeStream($this->scoped);
+    }
+
     /**
      * Is this action read only?
      *
index 4bba2f7f477854f5c254917097d9e3a33de73949..0948c35399be33100c45bda192a54aae8bfba331 100644 (file)
@@ -56,11 +56,25 @@ class NetworkpublicAction extends PublicAction
         // Network public tag cloud?
     }
 
-    /**
-     * FIXME: Network public feed! Get a template from PublicAction
-     */
     function getFeeds()
     {
-        return array();
+        return array(new Feed(Feed::JSON,
+                              common_local_url('ApiTimelineNetworkPublic',
+                                               array('format' => 'as')),
+                              // TRANS: Link description for public timeline feed.
+                              _('Public Timeline Feed (Activity Streams JSON)')),
+                    new Feed(Feed::RSS1, common_local_url('publicrss'),
+                              // TRANS: Link description for public timeline feed.
+                              _('Public Timeline Feed (RSS 1.0)')),
+                     new Feed(Feed::RSS2,
+                              common_local_url('ApiTimelineNetworkPublic',
+                                               array('format' => 'rss')),
+                              // TRANS: Link description for public timeline feed.
+                              _('Public Timeline Feed (RSS 2.0)')),
+                     new Feed(Feed::ATOM,
+                              common_local_url('ApiTimelineNetworkPublic',
+                                               array('format' => 'atom')),
+                              // TRANS: Link description for public timeline feed.
+                              _('Public Timeline Feed (Atom)')));
     }
 }
index 725ecf6d06382699c8f19ebd45b62faf4b1e2be7..45efceec3656d74cad53749d7e15602cd48bcc3a 100644 (file)
@@ -334,6 +334,11 @@ class Router
                         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,