1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

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
This commit is contained in:
Chad Little 2015-12-03 15:27:01 -08:00
parent 7ce2ad294f
commit 74882503aa
8 changed files with 107 additions and 32 deletions

View file

@ -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',

View file

@ -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',

View file

@ -45,6 +45,7 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhamePostListController',
'blogger/(?P<bloggername>[\w\.-_]+)/' => 'PhamePostListController',
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
'history/(?P<id>\d+)/' => 'PhamePostHistoryController',
'view/(?P<id>\d+)/' => 'PhamePostViewController',
'publish/(?P<id>\d+)/' => 'PhamePostPublishController',
'preview/(?P<id>\d+)/' => 'PhamePostPreviewController',

View file

@ -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());

View file

@ -0,0 +1,55 @@
<?php
final class PhamePostHistoryController extends PhamePostController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->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,
));
}
}

View file

@ -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();

View file

@ -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);
}

View file

@ -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;
}