mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
tweak pager and title in basic => template skin
Summary: its a bit confusing but "newer" posts are the "previous" page and "older" posts are the "next" page. this is because newer posts are those with higher ids. also make the title be the title of the post if we have an actual post. Test Plan: set page limit to 5 and got somewhat sensical results (note this pagination seems to break with my test data set where there's fun gaps in the contiguity of the ids in a given blog) viewed an actual post and noted the page title was the post title Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4222
This commit is contained in:
parent
53c1483ee5
commit
bd70693d84
2 changed files with 22 additions and 11 deletions
|
@ -8,6 +8,15 @@
|
|||
abstract class PhameBasicBlogSkin extends PhameBlogSkin {
|
||||
|
||||
private $pager;
|
||||
private $title;
|
||||
|
||||
protected function setTitle($title) {
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
protected function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
@ -145,7 +154,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
|
|||
*/
|
||||
protected function getNewerPageURI() {
|
||||
if ($this->pager) {
|
||||
$next = $this->pager->getNextPageID();
|
||||
$next = $this->pager->getPrevPageID();
|
||||
if ($next) {
|
||||
return $this->getURI('newer/'.$next.'/');
|
||||
}
|
||||
|
@ -183,6 +192,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
|
|||
|
||||
$matches = null;
|
||||
$path = $request->getPath();
|
||||
$this->setTitle($this->getBlog()->getName());
|
||||
if (preg_match('@^/post/(?P<name>.*)$@', $path, $matches)) {
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
|
@ -191,6 +201,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
|
|||
->executeOne();
|
||||
|
||||
if ($post) {
|
||||
$this->setTitle($post->getTitle());
|
||||
$view = head($this->buildPostViews(array($post)));
|
||||
return $this->renderPostDetail($view);
|
||||
}
|
||||
|
@ -198,9 +209,9 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
|
|||
$pager = new AphrontCursorPagerView();
|
||||
|
||||
if (preg_match('@^/older/(?P<before>\d+)/$@', $path, $matches)) {
|
||||
$pager->setBeforeID($matches['before']);
|
||||
$pager->setAfterID($matches['before']);
|
||||
} else if (preg_match('@^/newer/(?P<after>\d)/$@', $path, $matches)) {
|
||||
$pager->setAfterID($matches['after']);
|
||||
$pager->setBeforeID($matches['after']);
|
||||
} else if (preg_match('@^/$@', $path, $matches)) {
|
||||
// Just show the first page.
|
||||
} else {
|
||||
|
|
|
@ -80,18 +80,18 @@ final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin {
|
|||
|
||||
private function getDefaultScope() {
|
||||
return array(
|
||||
'skin' => $this,
|
||||
'blog' => $this->getBlog(),
|
||||
'uri' => $this->getURI(''),
|
||||
'skin' => $this,
|
||||
'blog' => $this->getBlog(),
|
||||
'uri' => $this->getURI(''),
|
||||
'title' => $this->getTitle(),
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderHeader() {
|
||||
return $this->renderTemplate(
|
||||
'header.php',
|
||||
array(
|
||||
'title' => $this->getBlog()->getName(),
|
||||
));
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderFooter() {
|
||||
|
@ -115,8 +115,8 @@ final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin {
|
|||
'post-list.php',
|
||||
array(
|
||||
'posts' => $posts,
|
||||
'older' => $this->renderNewerPageLink(),
|
||||
'newer' => $this->renderOlderPageLink(),
|
||||
'older' => $this->renderOlderPageLink(),
|
||||
'newer' => $this->renderNewerPageLink(),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue