From 74882503aaf9bc1ec4a3b802b1d0dd0868e17816 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Thu, 3 Dec 2015 15:27:01 -0800 Subject: [PATCH] Spiffy up PhamePostView Summary: Cleaner Author information, less "Properties", Build a History Page. Ref T9897 Test Plan: Review New Posts, Draft Posts, View History {F1012934} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9897 Differential Revision: https://secure.phabricator.com/D14660 --- resources/celerity/map.php | 4 +- src/__phutil_library_map__.php | 2 + .../PhabricatorPhameApplication.php | 1 + .../blog/PhameBlogViewController.php | 2 +- .../post/PhamePostHistoryController.php | 55 +++++++++++++++ .../post/PhamePostViewController.php | 68 +++++++++++-------- .../phame/view/PhameDescriptionView.php | 2 +- webroot/rsrc/css/application/phame/phame.css | 5 ++ 8 files changed, 107 insertions(+), 32 deletions(-) create mode 100644 src/applications/phame/controller/post/PhamePostHistoryController.php diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 1b6da908b9..038f5d0ab9 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -82,7 +82,7 @@ return array( 'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b', 'rsrc/css/application/paste/paste.css' => 'b2f5a543', 'rsrc/css/application/people/people-profile.css' => '25970776', - 'rsrc/css/application/phame/phame.css' => '46166309', + 'rsrc/css/application/phame/phame.css' => 'cea3c9e1', 'rsrc/css/application/pholio/pholio-edit.css' => '3ad9d1ee', 'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49', 'rsrc/css/application/pholio/pholio.css' => '95174bdd', @@ -776,7 +776,7 @@ return array( 'phabricator-uiexample-reactor-sendclass' => '1def2711', 'phabricator-uiexample-reactor-sendproperties' => 'b1f0ccee', 'phabricator-zindex-css' => '57ddcaa2', - 'phame-css' => '46166309', + 'phame-css' => 'cea3c9e1', 'pholio-css' => '95174bdd', 'pholio-edit-css' => '3ad9d1ee', 'pholio-inline-comments-css' => '8e545e49', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ac2fa8cdf1..859c551ff5 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3327,6 +3327,7 @@ phutil_register_library_map(array( 'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php', 'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php', 'PhamePostFramedController' => 'applications/phame/controller/post/PhamePostFramedController.php', + 'PhamePostHistoryController' => 'applications/phame/controller/post/PhamePostHistoryController.php', 'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php', 'PhamePostListView' => 'applications/phame/view/PhamePostListView.php', 'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php', @@ -7668,6 +7669,7 @@ phutil_register_library_map(array( 'PhamePostEditController' => 'PhamePostController', 'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor', 'PhamePostFramedController' => 'PhamePostController', + 'PhamePostHistoryController' => 'PhamePostController', 'PhamePostListController' => 'PhamePostController', 'PhamePostListView' => 'AphrontTagView', 'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver', diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php index 78c90373fe..ef6a907b2c 100644 --- a/src/applications/phame/application/PhabricatorPhameApplication.php +++ b/src/applications/phame/application/PhabricatorPhameApplication.php @@ -45,6 +45,7 @@ final class PhabricatorPhameApplication extends PhabricatorApplication { '(?:query/(?P[^/]+)/)?' => 'PhamePostListController', 'blogger/(?P[\w\.-_]+)/' => 'PhamePostListController', 'edit/(?:(?P[^/]+)/)?' => 'PhamePostEditController', + 'history/(?P\d+)/' => 'PhamePostHistoryController', 'view/(?P\d+)/' => 'PhamePostViewController', 'publish/(?P\d+)/' => 'PhamePostPublishController', 'preview/(?P\d+)/' => 'PhamePostPreviewController', diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php index 5d6326b5d3..e822e6b933 100644 --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -84,7 +84,7 @@ final class PhameBlogViewController extends PhameBlogController { } $about = id(new PhameDescriptionView()) - ->setTitle($blog->getName()) + ->setTitle(pht('About %s', $blog->getName())) ->setDescription($description) ->setImage($blog->getProfileImageURI()); diff --git a/src/applications/phame/controller/post/PhamePostHistoryController.php b/src/applications/phame/controller/post/PhamePostHistoryController.php new file mode 100644 index 0000000000..616538f4bc --- /dev/null +++ b/src/applications/phame/controller/post/PhamePostHistoryController.php @@ -0,0 +1,55 @@ +getViewer(); + + $post = id(new PhamePostQuery()) + ->setViewer($viewer) + ->withIDs(array($request->getURIData('id'))) + ->executeOne(); + + if (!$post) { + return new Aphront404Response(); + } + + $blog = $post->getBlog(); + + $crumbs = $this->buildApplicationCrumbs(); + 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().'/')); + $crumbs->addTextCrumb(pht('Post History')); + $crumbs->setBorder(true); + + $timeline = $this->buildTransactionTimeline( + $post, + new PhamePostTransactionQuery()); + $timeline->setShouldTerminate(true); + + return $this->newPage() + ->setTitle($post->getTitle()) + ->setPageObjectPHIDs(array($post->getPHID())) + ->setCrumbs($crumbs) + ->appendChild( + array( + $timeline, + )); + } + + +} diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php index 89a7b29969..76b33f1b03 100644 --- a/src/applications/phame/controller/post/PhamePostViewController.php +++ b/src/applications/phame/controller/post/PhamePostViewController.php @@ -36,7 +36,6 @@ final class PhamePostViewController extends PhamePostController { $crumbs->setBorder(true); $actions = $this->renderActions($post, $viewer); - $properties = $this->renderProperties($post, $viewer); $action_button = id(new PHUIButtonView()) ->setTag('a') @@ -90,6 +89,33 @@ final class PhamePostViewController extends PhamePostController { ), $engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY))); + $blogger = id(new PhabricatorPeopleQuery()) + ->setViewer($viewer) + ->withPHIDs(array($post->getBloggerPHID())) + ->needProfileImage(true) + ->executeOne(); + $blogger_profile = $blogger->loadUserProfile(); + + $author = phutil_tag( + 'a', + array( + 'href' => '/p/'.$blogger->getUsername().'/', + ), + $blogger->getUsername()); + + $date = phabricator_datetime($post->getDatePublished(), $viewer); + if ($post->isDraft()) { + $subtitle = pht('Unpublished draft by %s.', $author); + } else { + $subtitle = pht('Written by %s on %s.', $author, $date); + } + + $about = id(new PhameDescriptionView()) + ->setTitle($subtitle) + ->setDescription($blogger_profile->getTitle()) + ->setImage($blogger->getProfileImageURI()) + ->setImageHref('/p/'.$blogger->getUsername()); + $timeline = $this->buildTransactionTimeline( $post, id(new PhamePostTransactionQuery()) @@ -99,6 +125,12 @@ final class PhamePostViewController extends PhamePostController { $add_comment = $this->buildCommentForm($post); $add_comment = phutil_tag_div('mlb mlt', $add_comment); + $properties = id(new PHUIPropertyListView()) + ->setUser($viewer) + ->setObject($post); + + $properties->invokeWillRenderEvent(); + return $this->newPage() ->setTitle($post->getTitle()) ->setPageObjectPHIDs(array($post->getPHID())) @@ -106,6 +138,7 @@ final class PhamePostViewController extends PhamePostController { ->appendChild( array( $document, + $about, $properties, $timeline, $add_comment, @@ -144,6 +177,12 @@ final class PhamePostViewController extends PhamePostController { ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); + $actions->addAction( + id(new PhabricatorActionView()) + ->setIcon('fa-history') + ->setHref($this->getApplicationURI('post/history/'.$id.'/')) + ->setName(pht('View History'))); + if ($post->isDraft()) { $actions->addAction( id(new PhabricatorActionView()) @@ -190,33 +229,6 @@ final class PhamePostViewController extends PhamePostController { return $actions; } - private function renderProperties( - PhamePost $post, - PhabricatorUser $viewer) { - - $properties = id(new PHUIPropertyListView()) - ->setUser($viewer) - ->setObject($post); - - $properties->addProperty( - pht('Blog'), - $viewer->renderHandle($post->getBlogPHID())); - - $properties->addProperty( - pht('Blogger'), - $viewer->renderHandle($post->getBloggerPHID())); - - $properties->addProperty( - pht('Published'), - $post->isDraft() - ? pht('Draft') - : phabricator_datetime($post->getDatePublished(), $viewer)); - - $properties->invokeWillRenderEvent(); - - return $properties; - } - private function buildCommentForm(PhamePost $post) { $viewer = $this->getViewer(); diff --git a/src/applications/phame/view/PhameDescriptionView.php b/src/applications/phame/view/PhameDescriptionView.php index b8c8126918..346b22640f 100644 --- a/src/applications/phame/view/PhameDescriptionView.php +++ b/src/applications/phame/view/PhameDescriptionView.php @@ -52,7 +52,7 @@ final class PhameDescriptionView extends AphrontTagView { array( 'class' => 'phame-blog-description-name', ), - pht('About %s', $this->title)); + $this->title); return array($image, $header, $description); } diff --git a/webroot/rsrc/css/application/phame/phame.css b/webroot/rsrc/css/application/phame/phame.css index 0204444991..67cb65c614 100644 --- a/webroot/rsrc/css/application/phame/phame.css +++ b/webroot/rsrc/css/application/phame/phame.css @@ -29,3 +29,8 @@ border-radius: 3px; position: absolute; } + +.phame-blog-description + .phui-property-list-section { + border-top: 1px solid rgba(71, 87, 120, 0.20); + padding-top: 16px; +}