]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'link-rel-paginate' of git://gitorious.org/laconica/meitar. Fixed wrong...
authorAdrian Lang <mail@adrianlang.de>
Wed, 15 Apr 2009 07:38:19 +0000 (09:38 +0200)
committerAdrian Lang <mail@adrianlang.de>
Wed, 15 Apr 2009 07:38:19 +0000 (09:38 +0200)
These changes add opera-readable prev/next relations.

1  2 
actions/all.php
actions/favorited.php
actions/public.php
actions/replies.php
actions/showfavorites.php
actions/showgroup.php
actions/showstream.php
actions/tag.php
lib/action.php

diff --cc actions/all.php
index f5bbfe2e395c00138bdc990da56f01a9326a5bb8,4a625207a45f5623b8ca5c573883afa44225b58b..cb68691ba08e440eb23286f68ccf11550c2259b6
@@@ -51,24 -69,26 +51,35 @@@ class AllAction extends ProfileActio
          }
      }
  
 -    function showFeeds()
 +    function getFeeds()
      {
 -        $this->element('link', array('rel' => 'alternate',
 -                                     'href' => common_local_url('allrss', array('nickname' =>
 -                                                                                $this->user->nickname)),
 -                                     'type' => 'application/rss+xml',
 -                                     'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
 +        return array(new Feed(Feed::RSS1,
 +                              common_local_url('allrss', array('nickname' =>
 +                                                               $this->user->nickname)),
 +                              sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
 +                     new Feed(Feed::RSS2,
 +                              common_local_url('api', array('apiaction' => 'statuses',
 +                                                            'method' => 'friends_timeline',
 +                                                            'argument' => $this->user->nickname.'.rss')),
 +                              sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
 +                     new Feed(Feed::ATOM,
 +                              common_local_url('api', array('apiaction' => 'statuses',
 +                                                            'method' => 'friends_timeline',
 +                                                            'argument' => $this->user->nickname.'.atom')),
 +                              sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
      }
  
+     /**
+      * Output document relationship links
+      *
+      * @return void
+      */
+     function showRelationshipLinks()
+     {
+         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
+                                      $this->page, 'all', array('nickname' => $this->user->nickname));
+     }
      function showLocalNav()
      {
          $nav = new PersonalGroupNav($this);
Simple merge
index 5a380de9a8bb984ddf03b579febb03e348c6c147,eb2a4b1b004439ce7ba2a2d0cecc06e913ada860..961606908db126c3977a35d4eac1ddc2ca2eeb49
@@@ -119,22 -131,25 +131,33 @@@ class PublicAction extends Actio
       * @return void
       */
  
 -    function showFeeds()
 +    function getFeeds()
      {
 -        $this->element('link', array('rel' => 'alternate',
 -                                     'href' => common_local_url('publicrss'),
 -                                     'type' => 'application/rss+xml',
 -                                     'title' => _('Public Stream Feed')));
 +        return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
 +                              _('Public Stream Feed (RSS 1.0)')),
 +                     new Feed(Feed::RSS2,
 +                              common_local_url('api',
 +                                               array('apiaction' => 'statuses',
 +                                                     'method' => 'public_timeline.rss')),
 +                              _('Public Stream Feed (RSS 2.0)')),
 +                     new Feed(Feed::ATOM,
 +                              common_local_url('api',
 +                                               array('apiaction' => 'statuses',
 +                                                     'method' => 'public_timeline.atom')),
 +                              _('Public Stream Feed (Atom)')));
      }
  
+     /**
+      * Output document relationship links
+      *
+      * @return void
+      */
+     function showRelationshipLinks()
+     {
+         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
+                                      $this->page, 'public');
+     }
      /**
       * Extra head elements
       *
index 2769cb4227c05ea2796167a6e61a07913de4a4a0,7c24b554e0a0768ae81671b338103253570aac9c..1b593776e3dbb855e41613f0489bafcf4ccf20cc
@@@ -135,9 -135,23 +135,20 @@@ class RepliesAction extends Actio
                                       array('nickname' => $this->user->nickname));
          $rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
  
 -        $this->element('link', array('rel' => 'alternate',
 -                                     'href' => $rssurl,
 -                                     'type' => 'application/rss+xml',
 -                                     'title' => $rsstitle));
 +        return array(new Feed(Feed::RSS1, $rssurl, $rsstitle));
      }
  
+     /**
+      * Output document relationship links
+      *
+      * @return void
+      */
+     function showRelationshipLinks()
+     {
+         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
+                                      $this->page, 'replies', array('nickname' => $this->user->nickname));
+     }
      /**
       * show the personal group nav
       *
index 4d434950548e14d00a0f0d738f225e90d62fb605,585b3b75ab8809a6c6ff68c5693d30bee1cb0952..5ebbfef776a1e95e7afc79c23d8c5dbb9e132378
@@@ -147,9 -147,24 +147,21 @@@ class ShowfavoritesAction extends Actio
          $feedtitle = sprintf(_('Feed for favorites of %s'),
                               $this->user->nickname);
  
 -        $this->element('link', array('rel' => 'alternate',
 -                                     'href' => $feedurl,
 -                                     'type' => 'application/rss+xml',
 -                                     'title' => $feedtitle));
 +        return array(new Feed(Feed::RSS1, $feedurl, $feedtitle));
      }
  
+     /**
+      * Output document relationship links
+      *
+      * @return void
+      */
+     function showRelationshipLinks()
+     {
+         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
+                                      $this->page, 'showfavorites', array('nickname' => $this->user->nickname));
+     }
      /**
       * show the personal group nav
       *
Simple merge
index ce237dae225560dcdbdea879473851bc768b9f23,1779c70f2c5e2069c4d35180d89c82604ce833b7..3fe604f24b6c617d5d6d97d0f5485cfafbec11b8
@@@ -108,35 -155,65 +108,46 @@@ class ShowstreamAction extends ProfileA
          return;
      }
  
 -    function showExportData()
 -    {
 -        $fl = new FeedList($this);
 -        $fl->show(array(0=>array('href'=>common_local_url('userrss',
 -                                                          array('nickname' => $this->user->nickname)),
 -                                 'type' => 'rss',
 -                                 'version' => 'RSS 1.0',
 -                                 'item' => 'notices'),
 -                        1=>array('href'=>common_local_url('usertimeline',
 -                                                          array('nickname' => $this->user->nickname)),
 -                                 'type' => 'atom',
 -                                 'version' => 'Atom 1.0',
 -                                 'item' => 'usertimeline'),
 -                        2=>array('href'=>common_local_url('foaf',
 -                                                          array('nickname' => $this->user->nickname)),
 -                                 'type' => 'rdf',
 -                                 'version' => 'FOAF',
 -                                 'item' => 'foaf')));
 -    }
 -
 -    function showFeeds()
 +    function getFeeds()
      {
 -        $this->element('link', array('rel' => 'alternate',
 -                                     'type' => 'application/rss+xml',
 -                                     'href' => common_local_url('userrss',
 -                                                                array('nickname' => $this->user->nickname)),
 -                                     'title' => sprintf(_('Notice feed for %s (RSS)'),
 -                                                        $this->user->nickname)));
 -
 -        $this->element('link',
 -                       array('rel' => 'alternate',
 -                             'href' => common_local_url('api',
 -                                                        array('apiaction' => 'statuses',
 -                                                              'method' => 'user_timeline.atom',
 -                                                              'argument' => $this->user->nickname)),
 -                             'type' => 'application/atom+xml',
 -                             'title' => sprintf(_('Notice feed for %s (Atom)'),
 -                                                $this->user->nickname)));
 +        return array(new Feed(Feed::RSS1,
 +                              common_local_url('userrss',
 +                                               array('nickname' => $this->user->nickname)),
 +                              sprintf(_('Notice feed for %s (RSS 1.0)'),
 +                                      $this->user->nickname)),
 +                     new Feed(Feed::RSS2,
 +                              common_local_url('api',
 +                                               array('apiaction' => 'statuses',
 +                                                     'method' => 'user_timeline',
 +                                                     'argument' => $this->user->nickname.'.rss')),
 +                              sprintf(_('Notice feed for %s (RSS 2.0)'),
 +                                      $this->user->nickname)),
 +                     new Feed(Feed::ATOM,
 +                              common_local_url('api',
 +                                               array('apiaction' => 'statuses',
 +                                                     'method' => 'user_timeline',
 +                                                     'argument' => $this->user->nickname.'.atom')),
 +                              sprintf(_('Notice feed for %s (Atom)'),
 +                                      $this->user->nickname)),
 +                     new Feed(Feed::FOAF,
 +                              common_local_url('foaf', array('nickname' =>
 +                                                             $this->user->nickname)),
 +                              sprintf(_('FOAF for %s'), $this->user->nickname)));
      }
  
+     /**
+      * Output document relationship links
+      *
+      * @return void
+      */
+     function showRelationshipLinks()
+     {
+         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
+                                      $this->page, 'showstream', array('nickname' => $this->user->nickname));
+     }
      function extraHead()
      {
 -        // FOAF
 -        $this->element('link', array('rel' => 'meta',
 -                                     'href' => common_local_url('foaf', array('nickname' =>
 -                                                                              $this->user->nickname)),
 -                                     'type' => 'application/rdf+xml',
 -                                     'title' => 'FOAF'));
          // for remote subscriptions etc.
          $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
                                       'content' => common_local_url('xrds', array('nickname' =>
diff --cc actions/tag.php
index 583879f9cc12b0f0411c4ba5328829dc39b555ab,2a564a25d49442d72f1306a21c5119f916016139..06411085b7ce190b8760fee8e5cf493ea2d829cf
@@@ -70,13 -61,25 +70,24 @@@ class TagAction extends Actio
          $this->showPage();
      }
  
 -    function showFeeds()
 +    function getFeeds()
      {
 -        $this->element('link', array('rel' => 'alternate',
 -                                     'href' => common_local_url('tagrss', array('tag' => $this->tag)),
 -                                     'type' => 'application/rss+xml',
 -                                     'title' => sprintf(_('Feed for tag %s'), $this->tag)));
 +        return array(new Feed(Feed::RSS1,
 +                              common_local_url('tagrss', array('tag' => $this->tag)),
 +                              sprintf(_('Feed for tag %s'), $this->tag)));
      }
  
+     /**
+      * Output document relationship links
+      *
+      * @return void
+      */
+     function showRelationshipLinks()
+     {
+         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
+                                      $this->page, 'tag', array('tag' => $this->tag));
+     }
      function showPageNotice()
      {
          return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
diff --cc lib/action.php
index cc98d4445a4b6c1d95b602b50677c14c28d53cd8,80a8969fa2bd3cdf89b71fdaacad8540cc85313e..dddba9eb026794b6f029d674cecb0920e96d9df2
@@@ -121,9 -109,9 +121,10 @@@ class Action extends HTMLOutputter // l
          // XXX: attributes (profile?)
          $this->elementStart('head');
          $this->showTitle();
 +        $this->showShortcutIcon();
          $this->showStylesheets();
          $this->showScripts();
+         $this->showRelationshipLinks();
          $this->showOpenSearch();
          $this->showFeeds();
          $this->showDescription();
          }
      }
  
 -            $newargs = $args ? array_merge($args, $pargs) : $pargs;
 +    /**
 +     * An array of feeds for this action.
 +     *
 +     * Returns an array of potential feeds for this action.
 +     *
 +     * @return array Feed object to show in head and links
 +     */
 +
 +    function getFeeds()
 +    {
 +        return null;
 +    }
++
+     /**
+      * Generate document metadata for sequential navigation
+      *
+      * @param boolean $have_before is there something before?
+      * @param boolean $have_after  is there something after?
+      * @param integer $page        current page
+      * @param string  $action      current action
+      * @param array   $args        rest of query arguments
+      *
+      * @return nothing
+      */
+     function sequenceRelationships($have_next, $have_previous, $page, $action, $args=null)
+     {
+         // Outputs machine-readable pagination in <link> elements.
+         // Pattern taken from $this->pagination() method.
+         // "next" is equivalent to "after"
+         if ($have_next) {
+             $pargs   = array('page' => $page-1);
 -                                         'href' => common_local_url($action, $newargs),
+             $this->element('link', array('rel' => 'next',
 -            $newargs = $args ? array_merge($args, $pargs) : $pargs;
++                                         'href' => common_local_url($action, $args, $pargs),
+                                          'title' => _('Next')));
+         }
+         // "previous" is equivalent to "before"
+         if ($have_previous=true) { // FIXME
+             $pargs   = array('page' => $page+1);
 -                                         'href' => common_local_url($action, $newargs),
+             $this->element('link', array('rel' => 'prev',
++                                         'href' => common_local_url($action, $args, $pargs),
+                                          'title' => _('Previous')));
+         }
+     }
  }