We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 6e2f0458 authored by Meitar Moscovitz's avatar Meitar Moscovitz

Add machine-readable pagination using HTML4.01 `<link rel="next">`, etc.

These extra `<link>` elements only appear on pages where pagination
makes sense. They trigger functionality in some user agents, such as
Opera's Navigation Bar for more easily navigating forward and backwards
across a paged set of notices, messages, or group lists, etc.
parent e85f0ae4
...@@ -78,6 +78,28 @@ class AllAction extends Action ...@@ -78,6 +78,28 @@ class AllAction extends Action
'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname))); 'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('all',
array('nickname' => $this->user->nickname,
'page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('all',
array('nickname' => $this->user->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
function showLocalNav() function showLocalNav()
{ {
$nav = new PersonalGroupNav($this); $nav = new PersonalGroupNav($this);
......
...@@ -195,4 +195,24 @@ class FavoritedAction extends Action ...@@ -195,4 +195,24 @@ class FavoritedAction extends Action
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'favorited'); $this->page, 'favorited');
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('favorited',
array('page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('favorited',
array('page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
} }
...@@ -137,4 +137,26 @@ class GroupmembersAction extends Action ...@@ -137,4 +137,26 @@ class GroupmembersAction extends Action
$this->page, 'groupmembers', $this->page, 'groupmembers',
array('nickname' => $this->group->nickname)); array('nickname' => $this->group->nickname));
} }
}
\ No newline at end of file /**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('groupmembers',
array('nickname' => $this->group->nickname,
'page' => $this->page - 1)),
'title' => _('Next Group Members')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('groupmembers',
array('nickname' => $this->group->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Group Members')));
}
}
...@@ -129,4 +129,24 @@ class GroupsAction extends Action ...@@ -129,4 +129,24 @@ class GroupsAction extends Action
$gbm = new GroupsByMembersSection($this); $gbm = new GroupsByMembersSection($this);
$gbm->show(); $gbm->show();
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('groups',
array('page' => $this->page - 1)),
'title' => _('Next Groups')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('groups',
array('page' => $this->page + 1)),
'title' => _('Previous Groups')));
}
} }
...@@ -63,6 +63,28 @@ class InboxAction extends MailboxAction ...@@ -63,6 +63,28 @@ class InboxAction extends MailboxAction
} }
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('inbox',
array('nickname' => $this->user->nickname,
'page' => $this->page - 1)),
'title' => _('Next Messages')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('inbox',
array('nickname' => $this->user->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Messages')));
}
/** /**
* Retrieve the messages for this user and this page * Retrieve the messages for this user and this page
* *
......
...@@ -62,6 +62,28 @@ class OutboxAction extends MailboxAction ...@@ -62,6 +62,28 @@ class OutboxAction extends MailboxAction
} }
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('outbox',
array('nickname' => $this->user->nickname,
'page' => $this->page - 1)),
'title' => _('Next Messages')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('outbox',
array('nickname' => $this->user->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Messages')));
}
/** /**
* retrieve the messages for this user and this page * retrieve the messages for this user and this page
* *
......
...@@ -127,6 +127,26 @@ class PublicAction extends Action ...@@ -127,6 +127,26 @@ class PublicAction extends Action
'title' => _('Public Stream Feed'))); 'title' => _('Public Stream Feed')));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('public',
array('page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('public',
array('page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
/** /**
* Extra head elements * Extra head elements
* *
......
...@@ -141,6 +141,28 @@ class RepliesAction extends Action ...@@ -141,6 +141,28 @@ class RepliesAction extends Action
'title' => $rsstitle)); 'title' => $rsstitle));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('replies',
array('nickname' => $this->user->nickname,
'page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('replies',
array('nickname' => $this->user->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
/** /**
* show the personal group nav * show the personal group nav
* *
......
...@@ -153,6 +153,28 @@ class ShowfavoritesAction extends Action ...@@ -153,6 +153,28 @@ class ShowfavoritesAction extends Action
'title' => $feedtitle)); 'title' => $feedtitle));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('showfavorites',
array('nickname' => $this->user->nickname,
'page' => $this->page - 1)),
'title' => _('Next Favorite Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('showfavorites',
array('nickname' => $this->user->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Favorite Notices')));
}
/** /**
* show the personal group nav * show the personal group nav
* *
......
...@@ -326,6 +326,28 @@ class ShowgroupAction extends Action ...@@ -326,6 +326,28 @@ class ShowgroupAction extends Action
$this->group->nickname))); $this->group->nickname)));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('showgroup',
array('nickname' => $this->group->nickname,
'page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('showgroup',
array('nickname' => $this->group->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
/** /**
* Fill in the sidebar. * Fill in the sidebar.
* *
......
...@@ -195,6 +195,28 @@ class ShowstreamAction extends Action ...@@ -195,6 +195,28 @@ class ShowstreamAction extends Action
$this->user->nickname))); $this->user->nickname)));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('showstream',
array('nickname' => $this->user->nickname,
'page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('showstream',
array('nickname' => $this->user->nickname,
'page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
function extraHead() function extraHead()
{ {
// FOAF // FOAF
......
...@@ -69,6 +69,28 @@ class TagAction extends Action ...@@ -69,6 +69,28 @@ class TagAction extends Action
'title' => sprintf(_('Feed for tag %s'), $this->tag))); 'title' => sprintf(_('Feed for tag %s'), $this->tag)));
} }
/**
* Output document relationship links
*
* @return void
*/
function showRelationshipLinks()
{
// Machine-readable pagination
if ($this->page > 1) {
$this->element('link', array('rel' => 'next',
'href' => common_local_url('tag',
array('tag' => $this->tag,
'page' => $this->page - 1)),
'title' => _('Next Notices')));
}
$this->element('link', array('rel' => 'prev',
'href' => common_local_url('tag',
array('tag' => $this->tag,
'page' => $this->page + 1)),
'title' => _('Previous Notices')));
}
function showPageNotice() function showPageNotice()
{ {
return sprintf(_('Messages tagged "%s", most recent first'), $this->tag); return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
......
...@@ -111,6 +111,7 @@ class Action extends HTMLOutputter // lawsuit ...@@ -111,6 +111,7 @@ class Action extends HTMLOutputter // lawsuit
$this->showTitle(); $this->showTitle();
$this->showStylesheets(); $this->showStylesheets();
$this->showScripts(); $this->showScripts();
$this->showRelationshipLinks();
$this->showOpenSearch(); $this->showOpenSearch();
$this->showFeeds(); $this->showFeeds();
$this->showDescription(); $this->showDescription();
...@@ -193,6 +194,19 @@ class Action extends HTMLOutputter // lawsuit ...@@ -193,6 +194,19 @@ class Action extends HTMLOutputter // lawsuit
' '); ' ');
} }
/**
* Show document relationship links
*
* SHOULD overload
*
* @return nothing
*/
function showRelationshipLinks()
{
// output <link> elements with appropriate HTML4.01 link types:
// http://www.w3.org/TR/html401/types.html#type-links
}
/** /**
* Show OpenSearch headers * Show OpenSearch headers
* *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment