From 6e2f04583728714ff937eb1fa3ab34e99bcdb6a6 Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Mon, 9 Feb 2009 00:02:51 +1100 Subject: Add machine-readable pagination using HTML4.01 ``, etc. These extra `` 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. --- actions/all.php | 22 ++++++++++++++++++++++ actions/favorited.php | 20 ++++++++++++++++++++ actions/groupmembers.php | 24 +++++++++++++++++++++++- actions/groups.php | 20 ++++++++++++++++++++ actions/inbox.php | 22 ++++++++++++++++++++++ actions/outbox.php | 22 ++++++++++++++++++++++ actions/public.php | 20 ++++++++++++++++++++ actions/replies.php | 22 ++++++++++++++++++++++ actions/showfavorites.php | 22 ++++++++++++++++++++++ actions/showgroup.php | 22 ++++++++++++++++++++++ actions/showstream.php | 22 ++++++++++++++++++++++ actions/tag.php | 22 ++++++++++++++++++++++ lib/action.php | 14 ++++++++++++++ 13 files changed, 273 insertions(+), 1 deletion(-) diff --git a/actions/all.php b/actions/all.php index d75d1b946..76b1bbcdf 100644 --- a/actions/all.php +++ b/actions/all.php @@ -78,6 +78,28 @@ class AllAction extends Action '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() { $nav = new PersonalGroupNav($this); diff --git a/actions/favorited.php b/actions/favorited.php index fd5ff413c..367fb6dd6 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -195,4 +195,24 @@ class FavoritedAction extends Action $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $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'))); + } } diff --git a/actions/groupmembers.php b/actions/groupmembers.php index 00f43a9f5..2b2bdba93 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -137,4 +137,26 @@ class GroupmembersAction extends Action $this->page, 'groupmembers', 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'))); + } +} diff --git a/actions/groups.php b/actions/groups.php index 39dc2232b..b0bf7cfc2 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -129,4 +129,24 @@ class GroupsAction extends Action $gbm = new GroupsByMembersSection($this); $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'))); + } } diff --git a/actions/inbox.php b/actions/inbox.php index b553ab26c..d12f3f20a 100644 --- a/actions/inbox.php +++ b/actions/inbox.php @@ -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 * diff --git a/actions/outbox.php b/actions/outbox.php index c8d7f2812..043b74edc 100644 --- a/actions/outbox.php +++ b/actions/outbox.php @@ -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 * diff --git a/actions/public.php b/actions/public.php index cc6537f74..25889eee5 100644 --- a/actions/public.php +++ b/actions/public.php @@ -127,6 +127,26 @@ class PublicAction extends Action '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 * diff --git a/actions/replies.php b/actions/replies.php index 7eff74a66..5ae99e165 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -141,6 +141,28 @@ class RepliesAction extends Action '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 * diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 31479e1a7..f0297172a 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -153,6 +153,28 @@ class ShowfavoritesAction extends Action '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 * diff --git a/actions/showgroup.php b/actions/showgroup.php index 7bc68fbc6..7599a8de6 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -326,6 +326,28 @@ class ShowgroupAction extends Action $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. * diff --git a/actions/showstream.php b/actions/showstream.php index 28bb8453f..11615ebb0 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -195,6 +195,28 @@ class ShowstreamAction extends Action $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() { // FOAF diff --git a/actions/tag.php b/actions/tag.php index 4401f892a..f71f6d342 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -69,6 +69,28 @@ class TagAction extends Action '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() { return sprintf(_('Messages tagged "%s", most recent first'), $this->tag); diff --git a/lib/action.php b/lib/action.php index c4172ada1..ab51d0252 100644 --- a/lib/action.php +++ b/lib/action.php @@ -111,6 +111,7 @@ class Action extends HTMLOutputter // lawsuit $this->showTitle(); $this->showStylesheets(); $this->showScripts(); + $this->showRelationshipLinks(); $this->showOpenSearch(); $this->showFeeds(); $this->showDescription(); @@ -193,6 +194,19 @@ class Action extends HTMLOutputter // lawsuit ' '); } + /** + * Show document relationship links + * + * SHOULD overload + * + * @return nothing + */ + function showRelationshipLinks() + { + // output elements with appropriate HTML4.01 link types: + // http://www.w3.org/TR/html401/types.html#type-links + } + /** * Show OpenSearch headers * -- cgit v1.2.3-54-g00ecf From b240a1719485b15c4a6497b6053c24e8a40a4e3c Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Tue, 10 Feb 2009 19:42:01 +1100 Subject: Beginning to refactor document relationship links to reduce common code. My attempts here are to mimic the `pagination()` method shared by actions. I'm tentatively adding the `$count` property to actions so that we can query the number of notices ''being displayed'' per page prior to calling the actual `pagination()` method itself, since document relationship `` elements need to be output inside of `showHead()`, before `showContent()`, which is where `pagination()` is, gets called. --- actions/all.php | 15 ++------------- actions/favorited.php | 13 ++----------- actions/groupmembers.php | 15 ++------------- actions/groups.php | 13 ++----------- actions/inbox.php | 15 ++------------- actions/outbox.php | 15 ++------------- actions/public.php | 25 ++++++++++++++----------- actions/replies.php | 15 ++------------- actions/showfavorites.php | 16 +++------------- actions/showgroup.php | 15 ++------------- actions/showstream.php | 15 ++------------- actions/tag.php | 15 ++------------- lib/action.php | 34 ++++++++++++++++++++++++++++++++++ 13 files changed, 71 insertions(+), 150 deletions(-) diff --git a/actions/all.php b/actions/all.php index 76b1bbcdf..4a625207a 100644 --- a/actions/all.php +++ b/actions/all.php @@ -85,19 +85,8 @@ class AllAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'all', array('nickname' => $this->user->nickname)); } function showLocalNav() diff --git a/actions/favorited.php b/actions/favorited.php index 367fb6dd6..74920ca7e 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -203,16 +203,7 @@ class FavoritedAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'favorited'); } } diff --git a/actions/groupmembers.php b/actions/groupmembers.php index 2b2bdba93..b80f3d90d 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -145,18 +145,7 @@ class GroupmembersAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'groupmembers', array('nickname' => $this->group->nickname)); } } diff --git a/actions/groups.php b/actions/groups.php index b0bf7cfc2..e158698de 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -137,16 +137,7 @@ class GroupsAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'groups', array('nickname' => $this->group->nickname)); } } diff --git a/actions/inbox.php b/actions/inbox.php index d12f3f20a..7b5cf2d20 100644 --- a/actions/inbox.php +++ b/actions/inbox.php @@ -70,19 +70,8 @@ class InboxAction extends MailboxAction */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'inbox', array('nickname' => $this->user->nickname)); } /** diff --git a/actions/outbox.php b/actions/outbox.php index 043b74edc..deef1cc87 100644 --- a/actions/outbox.php +++ b/actions/outbox.php @@ -69,19 +69,8 @@ class OutboxAction extends MailboxAction */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'outbox', array('nickname' => $this->user->nickname)); } /** diff --git a/actions/public.php b/actions/public.php index 25889eee5..eb2a4b1b0 100644 --- a/actions/public.php +++ b/actions/public.php @@ -56,6 +56,18 @@ class PublicAction extends Action var $page = null; + /** + * Number of notices being shown on this page. + */ + // Does this need to be here? Should it be? + // If it does, this property needs to be + // added to other actions as well, like $page. + // I'm trying to find a way to capture the + // output of the $cnt variable from this + // action's showContent() method but need + // to do so earlier, I think...? + var $count = null; + function isReadOnly() { return true; @@ -134,17 +146,8 @@ class PublicAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'public'); } /** diff --git a/actions/replies.php b/actions/replies.php index 5ae99e165..7c24b554e 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -148,19 +148,8 @@ class RepliesAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'replies', array('nickname' => $this->user->nickname)); } /** diff --git a/actions/showfavorites.php b/actions/showfavorites.php index f0297172a..585b3b75a 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -160,21 +160,11 @@ class ShowfavoritesAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'showfavorites', array('nickname' => $this->user->nickname)); } + /** * show the personal group nav * diff --git a/actions/showgroup.php b/actions/showgroup.php index 7599a8de6..a2b40f994 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -333,19 +333,8 @@ class ShowgroupAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'showgroup', array('nickname' => $this->group->nickname)); } /** diff --git a/actions/showstream.php b/actions/showstream.php index 0c8fea182..1779c70f2 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -202,19 +202,8 @@ class ShowstreamAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'showstream', array('nickname' => $this->user->nickname)); } function extraHead() diff --git a/actions/tag.php b/actions/tag.php index f71f6d342..2a564a25d 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -76,19 +76,8 @@ class TagAction extends Action */ 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'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'tag', array('tag' => $this->tag)); } function showPageNotice() diff --git a/lib/action.php b/lib/action.php index 8d0fea7af..80a8969fa 100644 --- a/lib/action.php +++ b/lib/action.php @@ -938,4 +938,38 @@ class Action extends HTMLOutputter // lawsuit $this->elementEnd('div'); } } + + /** + * 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 elements. + // Pattern taken from $this->pagination() method. + + // "next" is equivalent to "after" + if ($have_next) { + $pargs = array('page' => $page-1); + $newargs = $args ? array_merge($args, $pargs) : $pargs; + $this->element('link', array('rel' => 'next', + 'href' => common_local_url($action, $newargs), + 'title' => _('Next'))); + } + // "previous" is equivalent to "before" + if ($have_previous=true) { // FIXME + $pargs = array('page' => $page+1); + $newargs = $args ? array_merge($args, $pargs) : $pargs; + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url($action, $newargs), + 'title' => _('Previous'))); + } + } } -- cgit v1.2.3-54-g00ecf From 1ba3ac9ee3f00472e0b7f8f25955967ab816a3fd Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 08:45:32 +0100 Subject: Make OMB work if the configured domain name does not exclusively contain lower case letters. If the configured domain is mixed-case OAuth throws invalidsignature errors. The current URL is part of the signated parts; since the consumer does not pass the current URL, the service has to get it itself and add it to the other OAuth params for signature rebuilding. OAuth.php uses $_SERVER for this, however, the domain is lcased in $_SERVER. Hence we pass the complete current URL as generated by common_local_url to OAuthRequest. --- actions/accesstoken.php | 2 +- actions/finishremotesubscribe.php | 2 +- actions/postnotice.php | 2 +- actions/requesttoken.php | 2 +- actions/updateprofile.php | 2 +- actions/userauthorization.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actions/accesstoken.php b/actions/accesstoken.php index 77fdf6aef..bb68d3314 100644 --- a/actions/accesstoken.php +++ b/actions/accesstoken.php @@ -59,7 +59,7 @@ class AccesstokenAction extends Action try { common_debug('getting request from env variables', __FILE__); common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_locale_url('accesstoken')); common_debug('getting a server', __FILE__); $server = omb_oauth_server(); common_debug('fetching the access token', __FILE__); diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index eaf57c2d8..6d73ee234 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -44,7 +44,7 @@ class FinishremotesubscribeAction extends Action common_debug('stored request: '.print_r($omb,true), __FILE__); common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('finishuserauthorization')); $token = $req->get_parameter('oauth_token'); diff --git a/actions/postnotice.php b/actions/postnotice.php index c32d8ca94..3e98b3cd5 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -28,7 +28,7 @@ class PostnoticeAction extends Action parent::handle($args); try { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('postnotice')); # Note: server-to-server function! $server = omb_oauth_server(); list($consumer, $token) = $server->verify_request($req); diff --git a/actions/requesttoken.php b/actions/requesttoken.php index ca253b97a..4e6f92913 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -69,7 +69,7 @@ class RequesttokenAction extends Action parent::handle($args); try { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('requesttoken')); $server = omb_oauth_server(); $token = $server->fetch_request_token($req); print $token; diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 7dc52fda9..08cb31ae0 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -29,7 +29,7 @@ class UpdateprofileAction extends Action parent::handle($args); try { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('updateprofile')); # Note: server-to-server function! $server = omb_oauth_server(); list($consumer, $token) = $server->verify_request($req); diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 6a76e3a4c..9eb1e8836 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -382,7 +382,7 @@ class UserauthorizationAction extends Action function getNewRequest() { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('GET', common_local_url('userauthorization')); return $req; } -- cgit v1.2.3-54-g00ecf From b1940bcb7b028b993b26cd3c36f4fdbbc79c96e6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 14 Apr 2009 16:01:02 -0400 Subject: escape slash in regexp --- plugins/LinkbackPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/LinkbackPlugin.php b/plugins/LinkbackPlugin.php index 56a26176b..881ead99e 100644 --- a/plugins/LinkbackPlugin.php +++ b/plugins/LinkbackPlugin.php @@ -99,7 +99,7 @@ class LinkbackPlugin extends Plugin if (array_key_exists('X-Pingback', $result->headers)) { $pb = $result->headers['X-Pingback']; - } else if (preg_match('//', + } else if (preg_match('//', $result->body, $match)) { $pb = $match[1]; -- cgit v1.2.3-54-g00ecf From b142c260108f43636b69adb90d5a27ffa44f0f74 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 14 Apr 2009 16:02:09 -0400 Subject: Make stuff work with no base --- lib/action.php | 4 ---- theme/default/css/display.css | 10 ++-------- theme/identica/css/display.css | 10 ++-------- theme/iphone/display.css | 16 +++++++--------- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/lib/action.php b/lib/action.php index 1ba062812..b02f525f0 100644 --- a/lib/action.php +++ b/lib/action.php @@ -192,10 +192,6 @@ class Action extends HTMLOutputter // lawsuit { if (Event::handle('StartShowStyles', array($this))) { if (Event::handle('StartShowLaconicaStyles', array($this))) { - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/display.css', 'base') . '?version=' . LACONICA_VERSION, - 'media' => 'screen, projection, tv')); $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION, diff --git a/theme/default/css/display.css b/theme/default/css/display.css index c5d694610..69a600cc2 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -7,6 +7,8 @@ * @link http://laconi.ca/ */ +@import url(../../base/css/display.css); + html, body, a:active { @@ -70,7 +72,6 @@ border-top-color:#D1D9E4; border-top-color:#97BFD1; } - #content .notice p.entry-content a:visited { background-color:#fcfcfc; } @@ -82,7 +83,6 @@ background-color:#fcfffc; background-color:#CEE1E9; } - #notice_text-count { color:#333; } @@ -112,7 +112,6 @@ background-color:rgba(255, 255, 255, 0.2); background-color:rgba(255, 255, 255, 0.7); } - .error { background-color:#F7E8E8; } @@ -120,7 +119,6 @@ background-color:#F7E8E8; background-color:#EFF3DC; } - #anon_notice { background-color:#97BFD1; color:#fff; @@ -131,7 +129,6 @@ border-color:#fff; background-color:#A9BF4F; } - #export_data li a { background-repeat:no-repeat; background-position:0 45%; @@ -184,8 +181,6 @@ background-image:url(../images/icons/twotone/green/mail.gif); background-image:url(../images/icons/twotone/green/shield.gif); } - - /* NOTICES */ .notices li.over { background-color:#fcfcfc; @@ -228,7 +223,6 @@ background-color:#fcfcfc; } /*END: NOTICES */ - #new_group a { background:transparent url(../images/icons/twotone/green/news.gif) no-repeat 0 45%; } diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index c32b6269d..d05578d43 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -7,6 +7,8 @@ * @link http://laconi.ca/ */ +@import url(../../base/css/display.css); + html, body, a:active { @@ -70,7 +72,6 @@ border-top-color:#CEE1E9; border-top-color:#87B4C8; } - #content .notice p.entry-content a:visited { background-color:#fcfcfc; } @@ -82,7 +83,6 @@ background-color:#fcfffc; background-color:#CEE1E9; } - #notice_text-count { color:#333; } @@ -112,7 +112,6 @@ background-color:rgba(135, 180, 200, 0.3); background-color:rgba(255, 255, 255, 0.7); } - .error { background-color:#F7E8E8; } @@ -120,7 +119,6 @@ background-color:#F7E8E8; background-color:#EFF3DC; } - #anon_notice { background-color:#87B4C8; color:#fff; @@ -131,7 +129,6 @@ border-color:#fff; background-color:#9BB43E; } - #export_data li a { background-repeat:no-repeat; background-position:0 45%; @@ -184,8 +181,6 @@ background-image:url(../images/icons/twotone/green/mail.gif); background-image:url(../images/icons/twotone/green/shield.gif); } - - /* NOTICES */ .notices li.over { background-color:#fcfcfc; @@ -228,7 +223,6 @@ background-color:#fcfcfc; } /*END: NOTICES */ - #new_group a { background:transparent url(../images/icons/twotone/green/news.gif) no-repeat 0 45%; } diff --git a/theme/iphone/display.css b/theme/iphone/display.css index 6ac471c1e..1838a8e86 100644 --- a/theme/iphone/display.css +++ b/theme/iphone/display.css @@ -2,6 +2,8 @@ /* Design & CSS by Marie-Claude Doyon http://www.marieclaudedoyon.com */ /* Simplified for mobile by Ken Sheppardson http://identi.ca/kshep */ +@import url(../../base/css/display.css); + html {} body { width: 100%; @@ -28,7 +30,6 @@ h1 { font-size: 1.2em; } - #wrap { margin: 0; } @@ -196,7 +197,7 @@ p#branding a { } .instructions a:hover, .success a:hover, .error a:hover { color: #FCFFF5; -} +} .success { clear: both; float: left; @@ -210,7 +211,6 @@ p#branding a { background-color: #ce3728; } - /* ----- Stream -----*/ #notices { @@ -273,7 +273,7 @@ p.time { p.time a { color: #91AA9D; } - + /* ----- Profile -----*/ #profile { clear: both; @@ -356,7 +356,7 @@ dl.statistics { clear: left; float: left; width: 200px; -} +} .statistics dd { float: left; } @@ -402,8 +402,6 @@ ul.subscriptions li, ul.subscribers li { } /* ----- End Subscriptions & Subscribers -----*/ - - #pagination { margin: 18px auto; } @@ -488,7 +486,7 @@ input#submit:hover, input.submit:hover { input.checkbox { width: auto; border: 0; -} +} textarea, input { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 1em; @@ -629,7 +627,7 @@ input#openid_url { #profiles a:hover { text-decoration: underline; } - + .profile_single { clear: both; display: block; -- cgit v1.2.3-54-g00ecf From e876b74e8ba7e80edcb9a13bff15deff4aa6ff15 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 15 Apr 2009 08:38:05 +0200 Subject: Add license notice to install.php, replace short and asp style tags by more portable long tag form. --- install.php | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/install.php b/install.php index 0240349bb..87a99a650 100644 --- a/install.php +++ b/install.php @@ -1,4 +1,22 @@ -. + */ + define('INSTALLDIR', dirname(__FILE__)); function main() @@ -19,12 +37,12 @@ function checkPrereqs() { if (file_exists(INSTALLDIR.'/config.php')) { ?>

Config file "config.php" already exists.

-

Require PHP version 5 or greater.

Require PHP version 5 or greater.

Cannot load required extension "".

Cannot load required extension "".

Cannot write config file to "".

+ ?>

Cannot write config file to "".

On your server, try this command:

-
chmod a+w
- chmod a+w +

Cannot write avatar directory "/avatar/".

+ ?>

Cannot write avatar directory "/avatar/".

On your server, try this command:

-
chmod a+w /avatar/
+
chmod a+w /avatar/

Install Laconica

- +
- \ No newline at end of file + -- cgit v1.2.3-54-g00ecf From e8fc34e75c4c9684b8c7e03d471a905e08446618 Mon Sep 17 00:00:00 2001 From: Fil Date: Wed, 15 Apr 2009 10:35:15 +0200 Subject: Use preg_quote to fix http://laconi.ca/trac/ticket/1342 --- actions/noticesearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 095d0a454..0828e47d7 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -184,11 +184,11 @@ class SearchNoticeListItem extends NoticeListItem { function highlight($text, $terms) { /* Highligh search terms */ - $pattern = '/('.implode('|', array_map('htmlspecialchars', $terms)).')/i'; + $pattern = '/('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')/i'; $result = preg_replace($pattern, '\\1', $text); /* Remove highlighting from inside links, loop incase multiple highlights in links */ - $pattern = '/(href="[^"]*)('.implode('|', array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU'; + $pattern = '/(href="[^"]*)('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')<\/strong>([^"]*")/iU'; do { $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); } while ($count); -- cgit v1.2.3-54-g00ecf From 8439477201cd59a6c0dba84ddf48eb86a6154199 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 15 Apr 2009 13:29:52 +0200 Subject: Add escaping of /. --- actions/noticesearch.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 0828e47d7..d996998fc 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -184,11 +184,13 @@ class SearchNoticeListItem extends NoticeListItem { function highlight($text, $terms) { /* Highligh search terms */ - $pattern = '/('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')/i'; + $options = implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms), + array_fill(0, sizeof($terms), '/'))); + $pattern = "/($options)/i"; $result = preg_replace($pattern, '\\1', $text); /* Remove highlighting from inside links, loop incase multiple highlights in links */ - $pattern = '/(href="[^"]*)('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')<\/strong>([^"]*")/iU'; + $pattern = '/(href="[^"]*)('.$options.')<\/strong>([^"]*")/iU'; do { $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); } while ($count); -- cgit v1.2.3-54-g00ecf From 8da76e0810342a90ac006f67cfd73500972f883a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 15 Apr 2009 10:05:16 -0400 Subject: add user id to statistics --- lib/profileaction.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/profileaction.php b/lib/profileaction.php index c81924e31..1f2e30994 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -179,6 +179,11 @@ class ProfileAction extends Action $this->element('h2', null, _('Statistics')); // Other stats...? + $this->elementStart('dl', 'entity_user-id'); + $this->element('dt', null, _('User ID')); + $this->element('dd', null, $this->profile->id); + $this->elementEnd('dl'); + $this->elementStart('dl', 'entity_member-since'); $this->element('dt', null, _('Member since')); $this->element('dd', null, date('j M Y', -- cgit v1.2.3-54-g00ecf From 7ba3f8aeb3277bec52eee896f0c6807c7121104c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 15 Apr 2009 11:30:33 -0400 Subject: script to trim very old notices from inboxes --- scripts/triminboxes.php | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 scripts/triminboxes.php diff --git a/scripts/triminboxes.php b/scripts/triminboxes.php new file mode 100644 index 000000000..0d2eaeaf0 --- /dev/null +++ b/scripts/triminboxes.php @@ -0,0 +1,83 @@ +#!/usr/bin/env php +. + */ + +# Abort if called from a web server +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(1); +} + +ini_set("max_execution_time", "0"); +ini_set("max_input_time", "0"); +set_time_limit(0); +mb_internal_encoding('UTF-8'); + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('LACONICA', true); + +require_once(INSTALLDIR . '/lib/common.php'); + +$user = new User(); +if ($argc > 1) { + $user->whereAdd('id > ' . $argv[1]); +} +$cnt = $user->find(); + +while ($user->fetch()) { + + $inbox_entry = new Notice_inbox(); + $inbox_entry->user_id = $user->id; + $inbox_entry->orderBy('created DESC'); + $inbox_entry->limit(1000, 1); + + $id = null; + + if ($inbox_entry->find(true)) { + $id = $inbox_entry->notice_id; + } + + $inbox_entry->free(); + unset($inbox_entry); + + if (is_null($id)) { + continue; + } + + $start = microtime(true); + + $old_inbox = new Notice_inbox(); + $cnt = $old_inbox->query('DELETE from notice_inbox WHERE user_id = ' . $user->id . ' AND notice_id < ' . $id); + $old_inbox->free(); + unset($old_inbox); + + print "Deleted $cnt notices for $user->nickname ($user->id).\n"; + + $finish = microtime(true); + + $delay = 3.0 * ($finish - $start); + + print "Delaying $delay seconds..."; + + // Wait to let slaves catch up + + usleep($delay * 1000000); + + print "DONE.\n"; +} -- cgit v1.2.3-54-g00ecf