mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Use PHUIDocumentProView in Phame
Summary: Updates "View Post" to use PHUIDocumentViewPro, updates calls to `newPage` and other minor modernizations. Edit Page updated to show proper document display as well. Ref T9545 Test Plan: Write a blog post, edit it. {F945897} {F945896} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9545 Differential Revision: https://secure.phabricator.com/D14415
This commit is contained in:
parent
9132b565d5
commit
e4806631a5
5 changed files with 88 additions and 87 deletions
|
@ -126,7 +126,7 @@ return array(
|
||||||
'rsrc/css/phui/phui-box.css' => 'a5bb366d',
|
'rsrc/css/phui/phui-box.css' => 'a5bb366d',
|
||||||
'rsrc/css/phui/phui-button.css' => '16020a60',
|
'rsrc/css/phui/phui-button.css' => '16020a60',
|
||||||
'rsrc/css/phui/phui-crumbs-view.css' => 'd842f867',
|
'rsrc/css/phui/phui-crumbs-view.css' => 'd842f867',
|
||||||
'rsrc/css/phui/phui-document-pro.css' => '61d70f8e',
|
'rsrc/css/phui/phui-document-pro.css' => '4f2b42e3',
|
||||||
'rsrc/css/phui/phui-document.css' => '9fa715d2',
|
'rsrc/css/phui/phui-document.css' => '9fa715d2',
|
||||||
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
|
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
|
||||||
'rsrc/css/phui/phui-fontkit.css' => 'c9d63950',
|
'rsrc/css/phui/phui-fontkit.css' => 'c9d63950',
|
||||||
|
@ -781,7 +781,7 @@ return array(
|
||||||
'phui-calendar-month-css' => '476be7e0',
|
'phui-calendar-month-css' => '476be7e0',
|
||||||
'phui-crumbs-view-css' => 'd842f867',
|
'phui-crumbs-view-css' => 'd842f867',
|
||||||
'phui-document-view-css' => '9fa715d2',
|
'phui-document-view-css' => '9fa715d2',
|
||||||
'phui-document-view-pro-css' => '61d70f8e',
|
'phui-document-view-pro-css' => '4f2b42e3',
|
||||||
'phui-feed-story-css' => 'b7b26d23',
|
'phui-feed-story-css' => 'b7b26d23',
|
||||||
'phui-font-icon-base-css' => 'ecbbb4c2',
|
'phui-font-icon-base-css' => 'ecbbb4c2',
|
||||||
'phui-fontkit-css' => 'c9d63950',
|
'phui-fontkit-css' => 'c9d63950',
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
final class PhamePostEditController extends PhameController {
|
final class PhamePostEditController extends PhameController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$user = $request->getUser();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$post = id(new PhamePostQuery())
|
$post = id(new PhamePostQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($id))
|
->withIDs(array($id))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
|
@ -29,7 +29,7 @@ final class PhamePostEditController extends PhameController {
|
||||||
$v_projects = array_reverse($v_projects);
|
$v_projects = array_reverse($v_projects);
|
||||||
} else {
|
} else {
|
||||||
$blog = id(new PhameBlogQuery())
|
$blog = id(new PhameBlogQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($request->getInt('blog')))
|
->withIDs(array($request->getInt('blog')))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
|
@ -42,7 +42,7 @@ final class PhamePostEditController extends PhameController {
|
||||||
}
|
}
|
||||||
$v_projects = array();
|
$v_projects = array();
|
||||||
|
|
||||||
$post = PhamePost::initializePost($user, $blog);
|
$post = PhamePost::initializePost($viewer, $blog);
|
||||||
$cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/');
|
$cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/');
|
||||||
|
|
||||||
$submit_button = pht('Save Draft');
|
$submit_button = pht('Save Draft');
|
||||||
|
@ -87,7 +87,7 @@ final class PhamePostEditController extends PhameController {
|
||||||
->setNewValue(array('=' => array_fuse($v_projects)));
|
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||||
|
|
||||||
$editor = id(new PhamePostEditor())
|
$editor = id(new PhamePostEditor())
|
||||||
->setActor($user)
|
->setActor($viewer)
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
->setContinueOnNoEffect(true);
|
->setContinueOnNoEffect(true);
|
||||||
|
|
||||||
|
@ -106,12 +106,12 @@ final class PhamePostEditController extends PhameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$handle = id(new PhabricatorHandleQuery())
|
$handle = id(new PhabricatorHandleQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array($post->getBlogPHID()))
|
->withPHIDs(array($post->getBlogPHID()))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->addHiddenInput('blog', $request->getInt('blog'))
|
->addHiddenInput('blog', $request->getInt('blog'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormMarkupControl())
|
id(new AphrontFormMarkupControl())
|
||||||
|
@ -141,7 +141,7 @@ final class PhamePostEditController extends PhameController {
|
||||||
->setValue($body)
|
->setValue($body)
|
||||||
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
|
||||||
->setID('post-body')
|
->setID('post-body')
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setDisableMacros(true))
|
->setDisableMacros(true))
|
||||||
->appendControl(
|
->appendControl(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
|
@ -160,14 +160,18 @@ final class PhamePostEditController extends PhameController {
|
||||||
->addCancelButton($cancel_uri)
|
->addCancelButton($cancel_uri)
|
||||||
->setValue($submit_button));
|
->setValue($submit_button));
|
||||||
|
|
||||||
$loading = phutil_tag_div(
|
$header = id(new PHUIHeaderView())
|
||||||
'aphront-panel-preview-loading-text',
|
->setHeader(pht('%s (Post Preview)', $title));
|
||||||
pht('Loading preview...'));
|
|
||||||
|
|
||||||
$preview_panel = phutil_tag_div('aphront-panel-preview', array(
|
$container = id(new PHUIBoxView())
|
||||||
phutil_tag_div('phame-post-preview-header', pht('Post Preview')),
|
->setID('post-preview');
|
||||||
phutil_tag('div', array('id' => 'post-preview'), $loading),
|
|
||||||
));
|
$document = id(new PHUIDocumentViewPro())
|
||||||
|
->setHeader($header)
|
||||||
|
->appendChild($container);
|
||||||
|
|
||||||
|
$preview_panel = id(new PHUIObjectBoxView())
|
||||||
|
->appendChild($document);
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'phame-post-preview',
|
'phame-post-preview',
|
||||||
|
@ -189,14 +193,13 @@ final class PhamePostEditController extends PhameController {
|
||||||
$page_title,
|
$page_title,
|
||||||
$this->getApplicationURI('/post/view/'.$id.'/'));
|
$this->getApplicationURI('/post/view/'.$id.'/'));
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->newPage()
|
||||||
array(
|
->setTitle($page_title)
|
||||||
$crumbs,
|
->setCrumbs($crumbs)
|
||||||
$form_box,
|
->appendChild(
|
||||||
$preview_panel,
|
array(
|
||||||
),
|
$form_box,
|
||||||
array(
|
$preview_panel,
|
||||||
'title' => $page_title,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,9 @@ final class PhamePostPreviewController extends PhameController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $request->getViewer();
|
||||||
$user = $request->getUser();
|
$body = $request->getStr('body');
|
||||||
$body = $request->getStr('body');
|
|
||||||
|
|
||||||
$post = id(new PhamePost())
|
$post = id(new PhamePost())
|
||||||
->setBody($body);
|
->setBody($body);
|
||||||
|
@ -17,7 +16,7 @@ final class PhamePostPreviewController extends PhameController {
|
||||||
$content = PhabricatorMarkupEngine::renderOneObject(
|
$content = PhabricatorMarkupEngine::renderOneObject(
|
||||||
$post,
|
$post,
|
||||||
PhamePost::MARKUP_FIELD_BODY,
|
PhamePost::MARKUP_FIELD_BODY,
|
||||||
$user);
|
$viewer);
|
||||||
|
|
||||||
$content = phutil_tag_div('phabricator-remarkup', $content);
|
$content = phutil_tag_div('phabricator-remarkup', $content);
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
final class PhamePostViewController extends PhameController {
|
final class PhamePostViewController extends PhameController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$user = $request->getUser();
|
$viewer = $request->getViewer();
|
||||||
|
|
||||||
$post = id(new PhamePostQuery())
|
$post = id(new PhamePostQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($request->getURIData('id')))
|
->withIDs(array($request->getURIData('id')))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
|
@ -14,29 +14,35 @@ final class PhamePostViewController extends PhameController {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav = $this->renderSideNavFilterView();
|
|
||||||
|
|
||||||
$actions = $this->renderActions($post, $user);
|
|
||||||
$properties = $this->renderProperties($post, $user, $actions);
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
$post->getTitle(),
|
$post->getTitle(),
|
||||||
$this->getApplicationURI('post/view/'.$post->getID().'/'));
|
$this->getApplicationURI('post/view/'.$post->getID().'/'));
|
||||||
|
$crumbs->setBorder(true);
|
||||||
|
|
||||||
$nav->appendChild($crumbs);
|
$actions = $this->renderActions($post, $viewer);
|
||||||
|
$properties = $this->renderProperties($post, $viewer);
|
||||||
|
|
||||||
|
$action_button = id(new PHUIButtonView())
|
||||||
|
->setTag('a')
|
||||||
|
->setText(pht('Actions'))
|
||||||
|
->setHref('#')
|
||||||
|
->setIconFont('fa-bars')
|
||||||
|
->addClass('phui-mobile-menu')
|
||||||
|
->setDropdownMenu($actions);
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader($post->getTitle())
|
->setHeader($post->getTitle())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setPolicyObject($post);
|
->setPolicyObject($post)
|
||||||
|
->addActionLink($action_button);
|
||||||
|
|
||||||
$object_box = id(new PHUIObjectBoxView())
|
$document = id(new PHUIDocumentViewPro())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->addPropertyList($properties);
|
->setPropertyList($properties);
|
||||||
|
|
||||||
if ($post->isDraft()) {
|
if ($post->isDraft()) {
|
||||||
$object_box->appendChild(
|
$document->appendChild(
|
||||||
id(new PHUIInfoView())
|
id(new PHUIInfoView())
|
||||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
||||||
->setTitle(pht('Draft Post'))
|
->setTitle(pht('Draft Post'))
|
||||||
|
@ -47,7 +53,7 @@ final class PhamePostViewController extends PhameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$post->getBlog()) {
|
if (!$post->getBlog()) {
|
||||||
$object_box->appendChild(
|
$document->appendChild(
|
||||||
id(new PHUIInfoView())
|
id(new PHUIInfoView())
|
||||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
||||||
->setTitle(pht('Not On A Blog'))
|
->setTitle(pht('Not On A Blog'))
|
||||||
|
@ -57,32 +63,40 @@ final class PhamePostViewController extends PhameController {
|
||||||
'been deleted). Use "Move Post" to move it to a new blog.')));
|
'been deleted). Use "Move Post" to move it to a new blog.')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav->appendChild(
|
$engine = id(new PhabricatorMarkupEngine())
|
||||||
array(
|
->setViewer($viewer)
|
||||||
$object_box,
|
->addObject($post, PhamePost::MARKUP_FIELD_BODY)
|
||||||
$this->buildTransactionTimeline(
|
->process();
|
||||||
$post,
|
|
||||||
new PhamePostTransactionQuery()),
|
|
||||||
));
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
$document->appendChild(
|
||||||
$nav,
|
phutil_tag(
|
||||||
array(
|
'div',
|
||||||
'title' => $post->getTitle(),
|
array(
|
||||||
|
'class' => 'phabricator-remarkup',
|
||||||
|
),
|
||||||
|
$engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY)));
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($post->getTitle())
|
||||||
|
->addClass('pro-white-background')
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->appendChild(
|
||||||
|
array(
|
||||||
|
$document,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderActions(
|
private function renderActions(
|
||||||
PhamePost $post,
|
PhamePost $post,
|
||||||
PhabricatorUser $user) {
|
PhabricatorUser $viewer) {
|
||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setObject($post)
|
->setObject($post)
|
||||||
->setObjectURI($this->getRequest()->getRequestURI())
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setUser($user);
|
->setUser($viewer);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
$user,
|
$viewer,
|
||||||
$post,
|
$post,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
@ -139,7 +153,7 @@ final class PhamePostViewController extends PhameController {
|
||||||
|
|
||||||
$actions->addAction(
|
$actions->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setIcon('fa-globe')
|
->setIcon('fa-globe')
|
||||||
->setHref($live_uri)
|
->setHref($live_uri)
|
||||||
->setName(pht('View Live'))
|
->setName(pht('View Live'))
|
||||||
|
@ -151,43 +165,28 @@ final class PhamePostViewController extends PhameController {
|
||||||
|
|
||||||
private function renderProperties(
|
private function renderProperties(
|
||||||
PhamePost $post,
|
PhamePost $post,
|
||||||
PhabricatorUser $user,
|
PhabricatorUser $viewer) {
|
||||||
PhabricatorActionListView $actions) {
|
|
||||||
|
|
||||||
$properties = id(new PHUIPropertyListView())
|
$properties = id(new PHUIPropertyListView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setObject($post)
|
->setObject($post);
|
||||||
->setActionList($actions);
|
|
||||||
|
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Blog'),
|
pht('Blog'),
|
||||||
$user->renderHandle($post->getBlogPHID()));
|
$viewer->renderHandle($post->getBlogPHID()));
|
||||||
|
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Blogger'),
|
pht('Blogger'),
|
||||||
$user->renderHandle($post->getBloggerPHID()));
|
$viewer->renderHandle($post->getBloggerPHID()));
|
||||||
|
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Published'),
|
pht('Published'),
|
||||||
$post->isDraft()
|
$post->isDraft()
|
||||||
? pht('Draft')
|
? pht('Draft')
|
||||||
: phabricator_datetime($post->getDatePublished(), $user));
|
: phabricator_datetime($post->getDatePublished(), $viewer));
|
||||||
|
|
||||||
$engine = id(new PhabricatorMarkupEngine())
|
|
||||||
->setViewer($user)
|
|
||||||
->addObject($post, PhamePost::MARKUP_FIELD_BODY)
|
|
||||||
->process();
|
|
||||||
|
|
||||||
$properties->invokeWillRenderEvent();
|
$properties->invokeWillRenderEvent();
|
||||||
|
|
||||||
$properties->addTextContent(
|
|
||||||
phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'phabricator-remarkup',
|
|
||||||
),
|
|
||||||
$engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY)));
|
|
||||||
|
|
||||||
return $properties;
|
return $properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.phui-document-view.phui-document-view-pro,
|
.phui-document-view.phui-document-view-pro,
|
||||||
.phui-document-view-pro-box {
|
.phui-document-view-pro-box,
|
||||||
|
.phui-document-properties {
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -11,15 +12,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.phui-document-properties {
|
.phui-document-properties {
|
||||||
max-width: 800px;
|
max-width: 768px;
|
||||||
padding: 0 16px;
|
|
||||||
background-color: {$lightgreybackground};
|
background-color: {$lightgreybackground};
|
||||||
margin: 0 auto;
|
margin: 16px auto;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-phone .phui-document-properties {
|
.device .phui-document-properties {
|
||||||
margin: 0 8px;
|
margin: 0 8px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-phone .phui-document-view.phui-document-view-pro {
|
.device-phone .phui-document-view.phui-document-view-pro {
|
||||||
|
|
Loading…
Reference in a new issue