1
0
Fork 0
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:
Chad Little 2015-11-05 12:13:35 -08:00
parent 9132b565d5
commit e4806631a5
5 changed files with 88 additions and 87 deletions

View file

@ -126,7 +126,7 @@ return array(
'rsrc/css/phui/phui-box.css' => 'a5bb366d',
'rsrc/css/phui/phui-button.css' => '16020a60',
'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-feed-story.css' => 'b7b26d23',
'rsrc/css/phui/phui-fontkit.css' => 'c9d63950',
@ -781,7 +781,7 @@ return array(
'phui-calendar-month-css' => '476be7e0',
'phui-crumbs-view-css' => 'd842f867',
'phui-document-view-css' => '9fa715d2',
'phui-document-view-pro-css' => '61d70f8e',
'phui-document-view-pro-css' => '4f2b42e3',
'phui-feed-story-css' => 'b7b26d23',
'phui-font-icon-base-css' => 'ecbbb4c2',
'phui-fontkit-css' => 'c9d63950',

View file

@ -3,12 +3,12 @@
final class PhamePostEditController extends PhameController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if ($id) {
$post = id(new PhamePostQuery())
->setViewer($user)
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
array(
@ -29,7 +29,7 @@ final class PhamePostEditController extends PhameController {
$v_projects = array_reverse($v_projects);
} else {
$blog = id(new PhameBlogQuery())
->setViewer($user)
->setViewer($viewer)
->withIDs(array($request->getInt('blog')))
->requireCapabilities(
array(
@ -42,7 +42,7 @@ final class PhamePostEditController extends PhameController {
}
$v_projects = array();
$post = PhamePost::initializePost($user, $blog);
$post = PhamePost::initializePost($viewer, $blog);
$cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/');
$submit_button = pht('Save Draft');
@ -87,7 +87,7 @@ final class PhamePostEditController extends PhameController {
->setNewValue(array('=' => array_fuse($v_projects)));
$editor = id(new PhamePostEditor())
->setActor($user)
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true);
@ -106,12 +106,12 @@ final class PhamePostEditController extends PhameController {
}
$handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->setViewer($viewer)
->withPHIDs(array($post->getBlogPHID()))
->executeOne();
$form = id(new AphrontFormView())
->setUser($user)
->setUser($viewer)
->addHiddenInput('blog', $request->getInt('blog'))
->appendChild(
id(new AphrontFormMarkupControl())
@ -141,7 +141,7 @@ final class PhamePostEditController extends PhameController {
->setValue($body)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setID('post-body')
->setUser($user)
->setUser($viewer)
->setDisableMacros(true))
->appendControl(
id(new AphrontFormTokenizerControl())
@ -160,14 +160,18 @@ final class PhamePostEditController extends PhameController {
->addCancelButton($cancel_uri)
->setValue($submit_button));
$loading = phutil_tag_div(
'aphront-panel-preview-loading-text',
pht('Loading preview...'));
$header = id(new PHUIHeaderView())
->setHeader(pht('%s (Post Preview)', $title));
$preview_panel = phutil_tag_div('aphront-panel-preview', array(
phutil_tag_div('phame-post-preview-header', pht('Post Preview')),
phutil_tag('div', array('id' => 'post-preview'), $loading),
));
$container = id(new PHUIBoxView())
->setID('post-preview');
$document = id(new PHUIDocumentViewPro())
->setHeader($header)
->appendChild($container);
$preview_panel = id(new PHUIObjectBoxView())
->appendChild($document);
Javelin::initBehavior(
'phame-post-preview',
@ -189,14 +193,13 @@ final class PhamePostEditController extends PhameController {
$page_title,
$this->getApplicationURI('/post/view/'.$id.'/'));
return $this->buildApplicationPage(
return $this->newPage()
->setTitle($page_title)
->setCrumbs($crumbs)
->appendChild(
array(
$crumbs,
$form_box,
$preview_panel,
),
array(
'title' => $page_title,
));
}

View file

@ -6,9 +6,8 @@ final class PhamePostPreviewController extends PhameController {
return null;
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$body = $request->getStr('body');
$post = id(new PhamePost())
@ -17,7 +16,7 @@ final class PhamePostPreviewController extends PhameController {
$content = PhabricatorMarkupEngine::renderOneObject(
$post,
PhamePost::MARKUP_FIELD_BODY,
$user);
$viewer);
$content = phutil_tag_div('phabricator-remarkup', $content);

View file

@ -3,10 +3,10 @@
final class PhamePostViewController extends PhameController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$viewer = $request->getViewer();
$post = id(new PhamePostQuery())
->setViewer($user)
->setViewer($viewer)
->withIDs(array($request->getURIData('id')))
->executeOne();
@ -14,29 +14,35 @@ final class PhamePostViewController extends PhameController {
return new Aphront404Response();
}
$nav = $this->renderSideNavFilterView();
$actions = $this->renderActions($post, $user);
$properties = $this->renderProperties($post, $user, $actions);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
$post->getTitle(),
$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())
->setHeader($post->getTitle())
->setUser($user)
->setPolicyObject($post);
->setUser($viewer)
->setPolicyObject($post)
->addActionLink($action_button);
$object_box = id(new PHUIObjectBoxView())
$document = id(new PHUIDocumentViewPro())
->setHeader($header)
->addPropertyList($properties);
->setPropertyList($properties);
if ($post->isDraft()) {
$object_box->appendChild(
$document->appendChild(
id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setTitle(pht('Draft Post'))
@ -47,7 +53,7 @@ final class PhamePostViewController extends PhameController {
}
if (!$post->getBlog()) {
$object_box->appendChild(
$document->appendChild(
id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
->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.')));
}
$nav->appendChild(
array(
$object_box,
$this->buildTransactionTimeline(
$post,
new PhamePostTransactionQuery()),
));
$engine = id(new PhabricatorMarkupEngine())
->setViewer($viewer)
->addObject($post, PhamePost::MARKUP_FIELD_BODY)
->process();
return $this->buildApplicationPage(
$nav,
$document->appendChild(
phutil_tag(
'div',
array(
'title' => $post->getTitle(),
'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(
PhamePost $post,
PhabricatorUser $user) {
PhabricatorUser $viewer) {
$actions = id(new PhabricatorActionListView())
->setObject($post)
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($user);
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$viewer,
$post,
PhabricatorPolicyCapability::CAN_EDIT);
@ -139,7 +153,7 @@ final class PhamePostViewController extends PhameController {
$actions->addAction(
id(new PhabricatorActionView())
->setUser($user)
->setUser($viewer)
->setIcon('fa-globe')
->setHref($live_uri)
->setName(pht('View Live'))
@ -151,43 +165,28 @@ final class PhamePostViewController extends PhameController {
private function renderProperties(
PhamePost $post,
PhabricatorUser $user,
PhabricatorActionListView $actions) {
PhabricatorUser $viewer) {
$properties = id(new PHUIPropertyListView())
->setUser($user)
->setObject($post)
->setActionList($actions);
->setUser($viewer)
->setObject($post);
$properties->addProperty(
pht('Blog'),
$user->renderHandle($post->getBlogPHID()));
$viewer->renderHandle($post->getBlogPHID()));
$properties->addProperty(
pht('Blogger'),
$user->renderHandle($post->getBloggerPHID()));
$viewer->renderHandle($post->getBloggerPHID()));
$properties->addProperty(
pht('Published'),
$post->isDraft()
? pht('Draft')
: phabricator_datetime($post->getDatePublished(), $user));
$engine = id(new PhabricatorMarkupEngine())
->setViewer($user)
->addObject($post, PhamePost::MARKUP_FIELD_BODY)
->process();
: phabricator_datetime($post->getDatePublished(), $viewer));
$properties->invokeWillRenderEvent();
$properties->addTextContent(
phutil_tag(
'div',
array(
'class' => 'phabricator-remarkup',
),
$engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY)));
return $properties;
}

View file

@ -3,7 +3,8 @@
*/
.phui-document-view.phui-document-view-pro,
.phui-document-view-pro-box {
.phui-document-view-pro-box,
.phui-document-properties {
max-width: 800px;
padding: 0 16px;
position: relative;
@ -11,15 +12,14 @@
}
.phui-document-properties {
max-width: 800px;
padding: 0 16px;
max-width: 768px;
background-color: {$lightgreybackground};
margin: 0 auto;
margin: 16px auto;
border-radius: 3px;
}
.device-phone .phui-document-properties {
margin: 0 8px;
.device .phui-document-properties {
margin: 0 8px 16px;
}
.device-phone .phui-document-view.phui-document-view-pro {