mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
Clean up URIs in Phame
Summary: Normalize "getViewURI" and "getLiveURI" for PhameBlog and PhamePost. Use pretty URIs in PhamePost Test Plan: View Recent, View posts, edit post, new post, move post, view live. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14713
This commit is contained in:
parent
d53187e10a
commit
dafdd39ba9
8 changed files with 27 additions and 25 deletions
|
@ -47,6 +47,7 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
|
||||||
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
|
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
|
||||||
'history/(?P<id>\d+)/' => 'PhamePostHistoryController',
|
'history/(?P<id>\d+)/' => 'PhamePostHistoryController',
|
||||||
'view/(?P<id>\d+)/' => 'PhamePostViewController',
|
'view/(?P<id>\d+)/' => 'PhamePostViewController',
|
||||||
|
'view/(?P<id>\d+)/(?P<slug>[^/]+)/' => 'PhamePostViewController',
|
||||||
'publish/(?P<id>\d+)/' => 'PhamePostPublishController',
|
'publish/(?P<id>\d+)/' => 'PhamePostPublishController',
|
||||||
'preview/(?P<id>\d+)/' => 'PhamePostPreviewController',
|
'preview/(?P<id>\d+)/' => 'PhamePostPreviewController',
|
||||||
'unpublish/(?P<id>\d+)/' => 'PhamePostUnpublishController',
|
'unpublish/(?P<id>\d+)/' => 'PhamePostUnpublishController',
|
||||||
|
|
|
@ -62,7 +62,7 @@ final class PhameBlogFeedController extends PhameBlogController {
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
$content[] = hsprintf('<entry>');
|
$content[] = hsprintf('<entry>');
|
||||||
$content[] = phutil_tag('title', array(), $post->getTitle());
|
$content[] = phutil_tag('title', array(), $post->getTitle());
|
||||||
$content[] = phutil_tag('link', array('href' => $post->getViewURI()));
|
$content[] = phutil_tag('link', array('href' => $post->getLiveURI()));
|
||||||
|
|
||||||
$content[] = phutil_tag('id', array(), PhabricatorEnv::getProductionURI(
|
$content[] = phutil_tag('id', array(), PhabricatorEnv::getProductionURI(
|
||||||
'/phame/post/view/'.$post->getID().'/'));
|
'/phame/post/view/'.$post->getID().'/'));
|
||||||
|
|
|
@ -6,6 +6,10 @@ final class PhamePostEditController extends PhamePostController {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
pht('Blogs'),
|
||||||
|
$this->getApplicationURI('blog/'));
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$post = id(new PhamePostQuery())
|
$post = id(new PhamePostQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
@ -29,6 +33,9 @@ final class PhamePostEditController extends PhamePostController {
|
||||||
$v_projects = array_reverse($v_projects);
|
$v_projects = array_reverse($v_projects);
|
||||||
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||||
$post->getPHID());
|
$post->getPHID());
|
||||||
|
$blog = $post->getBlog();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$blog = id(new PhameBlogQuery())
|
$blog = id(new PhameBlogQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
@ -102,7 +109,7 @@ final class PhamePostEditController extends PhamePostController {
|
||||||
try {
|
try {
|
||||||
$editor->applyTransactions($post, $xactions);
|
$editor->applyTransactions($post, $xactions);
|
||||||
|
|
||||||
$uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
|
$uri = $post->getViewURI();
|
||||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||||
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||||
$validation_exception = $ex;
|
$validation_exception = $ex;
|
||||||
|
@ -192,10 +199,12 @@ final class PhamePostEditController extends PhamePostController {
|
||||||
->setValidationException($validation_exception)
|
->setValidationException($validation_exception)
|
||||||
->setForm($form);
|
->setForm($form);
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs->addTextCrumb(
|
||||||
|
$blog->getName(),
|
||||||
|
$blog->getViewURI());
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
$page_title,
|
$page_title,
|
||||||
$this->getApplicationURI('/post/view/'.$id.'/'));
|
$cancel_uri);
|
||||||
|
|
||||||
return $this->newPage()
|
return $this->newPage()
|
||||||
->setTitle($page_title)
|
->setTitle($page_title)
|
||||||
|
|
|
@ -15,17 +15,10 @@ final class PhamePostNotLiveController extends PhamePostController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$reasons = array();
|
$reasons = array();
|
||||||
if (!$post->getBlog()) {
|
|
||||||
$reasons[] = phutil_tag('p', array(), pht(
|
|
||||||
'You can not view the live version of this post because it '.
|
|
||||||
'is not associated with a blog. Move the post to a blog in order to '.
|
|
||||||
'view it live.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($post->isDraft()) {
|
if ($post->isDraft()) {
|
||||||
$reasons[] = phutil_tag('p', array(), pht(
|
$reasons[] = phutil_tag('p', array(), pht(
|
||||||
'You can not view the live version of this post because it '.
|
'You can not view the live version of this post because it '.
|
||||||
'is still a draft. Use "Preview/Publish" to publish the post.'));
|
'is still a draft. Use "Preview" or "Publish" to publish the post.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reasons) {
|
if ($reasons) {
|
||||||
|
@ -45,7 +38,7 @@ final class PhamePostNotLiveController extends PhamePostController {
|
||||||
|
|
||||||
// No reason this can't go live, maybe an old link. Kick them live and see
|
// No reason this can't go live, maybe an old link. Kick them live and see
|
||||||
// what happens.
|
// what happens.
|
||||||
$live_uri = $post->getViewURI();
|
$live_uri = $post->getLiveURI();
|
||||||
return id(new AphrontRedirectResponse())->setURI($live_uri);
|
return id(new AphrontRedirectResponse())->setURI($live_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,9 @@ final class PhamePostViewController extends PhamePostController {
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
pht('Blogs'),
|
pht('Blogs'),
|
||||||
$this->getApplicationURI('blog/'));
|
$this->getApplicationURI('blog/'));
|
||||||
if ($blog) {
|
$crumbs->addTextCrumb(
|
||||||
$crumbs->addTextCrumb(
|
$blog->getName(),
|
||||||
$blog->getName(),
|
$this->getApplicationURI('blog/view/'.$blog->getID().'/'));
|
||||||
$this->getApplicationURI('blog/view/'.$blog->getID().'/'));
|
|
||||||
} else {
|
|
||||||
$crumbs->addTextCrumb(
|
|
||||||
pht('[No Blog]'),
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
$post->getTitle(),
|
$post->getTitle(),
|
||||||
$this->getApplicationURI('post/view/'.$post->getID().'/'));
|
$this->getApplicationURI('post/view/'.$post->getID().'/'));
|
||||||
|
|
|
@ -93,7 +93,7 @@ final class PhamePostSearchEngine
|
||||||
->setObject($post)
|
->setObject($post)
|
||||||
->setHeader($post->getTitle())
|
->setHeader($post->getTitle())
|
||||||
->setStatusIcon('fa-star')
|
->setStatusIcon('fa-star')
|
||||||
->setHref($this->getApplicationURI("/post/view/{$id}/"))
|
->setHref($post->getViewURI())
|
||||||
->addAttribute($blog_name);
|
->addAttribute($blog_name);
|
||||||
if ($post->isDraft()) {
|
if ($post->isDraft()) {
|
||||||
$item->setStatusIcon('fa-star-o grey');
|
$item->setStatusIcon('fa-star-o grey');
|
||||||
|
|
|
@ -48,7 +48,7 @@ final class PhamePost extends PhameDAO
|
||||||
return $this->blog;
|
return $this->blog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getViewURI() {
|
public function getLiveURI() {
|
||||||
// go for the pretty uri if we can
|
// go for the pretty uri if we can
|
||||||
$domain = ($this->blog ? $this->blog->getDomain() : '');
|
$domain = ($this->blog ? $this->blog->getDomain() : '');
|
||||||
if ($domain) {
|
if ($domain) {
|
||||||
|
@ -59,6 +59,11 @@ final class PhamePost extends PhameDAO
|
||||||
return PhabricatorEnv::getProductionURI($uri);
|
return PhabricatorEnv::getProductionURI($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getViewURI() {
|
||||||
|
$phame_title = PhabricatorSlug::normalize($this->getPhameTitle());
|
||||||
|
return '/phame/post/view/'.$this->getID().'/'.$phame_title;
|
||||||
|
}
|
||||||
|
|
||||||
public function getEditURI() {
|
public function getEditURI() {
|
||||||
return '/phame/post/edit/'.$this->getID().'/';
|
return '/phame/post/edit/'.$this->getID().'/';
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ final class PhamePostListView extends AphrontTagView {
|
||||||
|
|
||||||
$item = id(new PHUIDocumentSummaryView())
|
$item = id(new PHUIDocumentSummaryView())
|
||||||
->setTitle($post->getTitle())
|
->setTitle($post->getTitle())
|
||||||
->setHref('/phame/post/view/'.$post->getID().'/')
|
->setHref($post->getViewURI())
|
||||||
->setSubtitle($subtitle)
|
->setSubtitle($subtitle)
|
||||||
->setImage($blogger_image)
|
->setImage($blogger_image)
|
||||||
->setImageHref($blogger_uri)
|
->setImageHref($blogger_uri)
|
||||||
|
|
Loading…
Reference in a new issue