mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +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',
|
||||
'history/(?P<id>\d+)/' => 'PhamePostHistoryController',
|
||||
'view/(?P<id>\d+)/' => 'PhamePostViewController',
|
||||
'view/(?P<id>\d+)/(?P<slug>[^/]+)/' => 'PhamePostViewController',
|
||||
'publish/(?P<id>\d+)/' => 'PhamePostPublishController',
|
||||
'preview/(?P<id>\d+)/' => 'PhamePostPreviewController',
|
||||
'unpublish/(?P<id>\d+)/' => 'PhamePostUnpublishController',
|
||||
|
|
|
@ -62,7 +62,7 @@ final class PhameBlogFeedController extends PhameBlogController {
|
|||
foreach ($posts as $post) {
|
||||
$content[] = hsprintf('<entry>');
|
||||
$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(
|
||||
'/phame/post/view/'.$post->getID().'/'));
|
||||
|
|
|
@ -6,6 +6,10 @@ final class PhamePostEditController extends PhamePostController {
|
|||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
pht('Blogs'),
|
||||
$this->getApplicationURI('blog/'));
|
||||
if ($id) {
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($viewer)
|
||||
|
@ -29,6 +33,9 @@ final class PhamePostEditController extends PhamePostController {
|
|||
$v_projects = array_reverse($v_projects);
|
||||
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||
$post->getPHID());
|
||||
$blog = $post->getBlog();
|
||||
|
||||
|
||||
} else {
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($viewer)
|
||||
|
@ -102,7 +109,7 @@ final class PhamePostEditController extends PhamePostController {
|
|||
try {
|
||||
$editor->applyTransactions($post, $xactions);
|
||||
|
||||
$uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
|
||||
$uri = $post->getViewURI();
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||
$validation_exception = $ex;
|
||||
|
@ -192,10 +199,12 @@ final class PhamePostEditController extends PhamePostController {
|
|||
->setValidationException($validation_exception)
|
||||
->setForm($form);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
$blog->getName(),
|
||||
$blog->getViewURI());
|
||||
$crumbs->addTextCrumb(
|
||||
$page_title,
|
||||
$this->getApplicationURI('/post/view/'.$id.'/'));
|
||||
$cancel_uri);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($page_title)
|
||||
|
|
|
@ -15,17 +15,10 @@ final class PhamePostNotLiveController extends PhamePostController {
|
|||
}
|
||||
|
||||
$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()) {
|
||||
$reasons[] = phutil_tag('p', array(), pht(
|
||||
'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) {
|
||||
|
@ -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
|
||||
// what happens.
|
||||
$live_uri = $post->getViewURI();
|
||||
$live_uri = $post->getLiveURI();
|
||||
return id(new AphrontRedirectResponse())->setURI($live_uri);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,15 +25,9 @@ final class PhamePostViewController extends PhamePostController {
|
|||
$crumbs->addTextCrumb(
|
||||
pht('Blogs'),
|
||||
$this->getApplicationURI('blog/'));
|
||||
if ($blog) {
|
||||
$crumbs->addTextCrumb(
|
||||
$blog->getName(),
|
||||
$this->getApplicationURI('blog/view/'.$blog->getID().'/'));
|
||||
} else {
|
||||
$crumbs->addTextCrumb(
|
||||
pht('[No Blog]'),
|
||||
null);
|
||||
}
|
||||
$crumbs->addTextCrumb(
|
||||
$post->getTitle(),
|
||||
$this->getApplicationURI('post/view/'.$post->getID().'/'));
|
||||
|
|
|
@ -93,7 +93,7 @@ final class PhamePostSearchEngine
|
|||
->setObject($post)
|
||||
->setHeader($post->getTitle())
|
||||
->setStatusIcon('fa-star')
|
||||
->setHref($this->getApplicationURI("/post/view/{$id}/"))
|
||||
->setHref($post->getViewURI())
|
||||
->addAttribute($blog_name);
|
||||
if ($post->isDraft()) {
|
||||
$item->setStatusIcon('fa-star-o grey');
|
||||
|
|
|
@ -48,7 +48,7 @@ final class PhamePost extends PhameDAO
|
|||
return $this->blog;
|
||||
}
|
||||
|
||||
public function getViewURI() {
|
||||
public function getLiveURI() {
|
||||
// go for the pretty uri if we can
|
||||
$domain = ($this->blog ? $this->blog->getDomain() : '');
|
||||
if ($domain) {
|
||||
|
@ -59,6 +59,11 @@ final class PhamePost extends PhameDAO
|
|||
return PhabricatorEnv::getProductionURI($uri);
|
||||
}
|
||||
|
||||
public function getViewURI() {
|
||||
$phame_title = PhabricatorSlug::normalize($this->getPhameTitle());
|
||||
return '/phame/post/view/'.$this->getID().'/'.$phame_title;
|
||||
}
|
||||
|
||||
public function getEditURI() {
|
||||
return '/phame/post/edit/'.$this->getID().'/';
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ final class PhamePostListView extends AphrontTagView {
|
|||
|
||||
$item = id(new PHUIDocumentSummaryView())
|
||||
->setTitle($post->getTitle())
|
||||
->setHref('/phame/post/view/'.$post->getID().'/')
|
||||
->setHref($post->getViewURI())
|
||||
->setSubtitle($subtitle)
|
||||
->setImage($blogger_image)
|
||||
->setImageHref($blogger_uri)
|
||||
|
|
Loading…
Reference in a new issue