From df7f21b4e8117b65650c364b1a19bff77f9ca804 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 23 Nov 2015 10:28:59 -0800 Subject: [PATCH] Use PHUIRemarkupPreviewView in Phame Summary: Reuse PHUIMarkupPreviewView in Phame for consistency, less custom code. Also, doesn't work (JS issue). Test Plan: New Post, Edit Post, Save Post Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14552 --- resources/celerity/map.php | 16 ++++++------ src/__phutil_library_map__.php | 2 -- .../PhabricatorPhameApplication.php | 2 +- .../post/PhamePostEditController.php | 22 +++++----------- .../post/PhamePostPreviewController.php | 26 ------------------- src/view/phui/PHUIRemarkupPreviewPanel.php | 2 +- .../application/phame/phame-post-preview.js | 13 ---------- 7 files changed, 16 insertions(+), 67 deletions(-) delete mode 100644 src/applications/phame/controller/post/PhamePostPreviewController.php diff --git a/resources/celerity/map.php b/resources/celerity/map.php index d746796b00..48e2119287 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -402,7 +402,7 @@ return array( 'rsrc/js/application/owners/OwnersPathEditor.js' => 'aa1733d0', 'rsrc/js/application/owners/owners-path-editor.js' => '7a68dda3', 'rsrc/js/application/passphrase/passphrase-credential-control.js' => '3cb0b2fc', - 'rsrc/js/application/phame/phame-post-preview.js' => 'be807912', + 'rsrc/js/application/phame/phame-post-preview.js' => 'd6bba572', 'rsrc/js/application/pholio/behavior-pholio-mock-edit.js' => '246dc085', 'rsrc/js/application/pholio/behavior-pholio-mock-view.js' => 'fbe497e7', 'rsrc/js/application/phortune/behavior-stripe-payment-form.js' => '3f5d6dbf', @@ -637,7 +637,7 @@ return array( 'javelin-behavior-phabricator-transaction-comment-form' => 'b23b49e6', 'javelin-behavior-phabricator-transaction-list' => '13c739ea', 'javelin-behavior-phabricator-watch-anchor' => '9f36c42d', - 'javelin-behavior-phame-post-preview' => 'be807912', + 'javelin-behavior-phame-post-preview' => 'd6bba572', 'javelin-behavior-pholio-mock-edit' => '246dc085', 'javelin-behavior-pholio-mock-view' => 'fbe497e7', 'javelin-behavior-phui-dropdown-menu' => '54733475', @@ -1765,12 +1765,6 @@ return array( 'javelin-util', 'javelin-request', ), - 'be807912' => array( - 'javelin-behavior', - 'javelin-dom', - 'javelin-util', - 'phabricator-shaped-request', - ), 'c1700f6f' => array( 'javelin-install', 'javelin-util', @@ -1851,6 +1845,12 @@ return array( 'javelin-dom', 'javelin-stratcom', ), + 'd6bba572' => array( + 'javelin-behavior', + 'javelin-dom', + 'javelin-util', + 'phabricator-shaped-request', + ), 'd75709e6' => array( 'javelin-behavior', 'javelin-workflow', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index c1eac5a583..4816faaa44 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3310,7 +3310,6 @@ phutil_register_library_map(array( 'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php', 'PhamePostNewController' => 'applications/phame/controller/post/PhamePostNewController.php', 'PhamePostNotLiveController' => 'applications/phame/controller/post/PhamePostNotLiveController.php', - 'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php', 'PhamePostPublishController' => 'applications/phame/controller/post/PhamePostPublishController.php', 'PhamePostQuery' => 'applications/phame/query/PhamePostQuery.php', 'PhamePostReplyHandler' => 'applications/phame/mail/PhamePostReplyHandler.php', @@ -7627,7 +7626,6 @@ phutil_register_library_map(array( 'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhamePostNewController' => 'PhamePostController', 'PhamePostNotLiveController' => 'PhamePostController', - 'PhamePostPreviewController' => 'PhamePostController', 'PhamePostPublishController' => 'PhamePostController', 'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhamePostReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php index 456a58c9eb..bc841087db 100644 --- a/src/applications/phame/application/PhabricatorPhameApplication.php +++ b/src/applications/phame/application/PhabricatorPhameApplication.php @@ -50,7 +50,7 @@ final class PhabricatorPhameApplication extends PhabricatorApplication { 'publish/(?P\d+)/' => 'PhamePostPublishController', 'unpublish/(?P\d+)/' => 'PhamePostUnpublishController', 'notlive/(?P\d+)/' => 'PhamePostNotLiveController', - 'preview/' => 'PhamePostPreviewController', + 'preview/' => 'PhabricatorMarkupPreviewController', 'framed/(?P\d+)/' => 'PhamePostFramedController', 'new/' => 'PhamePostNewController', 'move/(?P\d+)/' => 'PhamePostNewController', diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php index c768e3c3a0..145c291efb 100644 --- a/src/applications/phame/controller/post/PhamePostEditController.php +++ b/src/applications/phame/controller/post/PhamePostEditController.php @@ -175,27 +175,17 @@ final class PhamePostEditController extends PhamePostController { ->addCancelButton($cancel_uri) ->setValue($submit_button)); - $header = id(new PHUIHeaderView()) - ->setHeader(pht('%s (Post Preview)', $title)); - - $container = id(new PHUIBoxView()) - ->setID('post-preview'); - - $document = id(new PHUIDocumentViewPro()) - ->setHeader($header) - ->appendChild($container); - - $preview_panel = id(new PHUIObjectBoxView()) - ->appendChild($document); + $preview = id(new PHUIRemarkupPreviewPanel()) + ->setHeader($post->getTitle()) + ->setPreviewURI($this->getApplicationURI('post/preview/')) + ->setControlID('post-body') + ->setPreviewType(PHUIRemarkupPreviewPanel::DOCUMENT); Javelin::initBehavior( 'phame-post-preview', array( - 'preview' => 'post-preview', - 'body' => 'post-body', 'title' => 'post-title', 'phame_title' => 'post-phame-title', - 'uri' => '/phame/post/preview/', )); $form_box = id(new PHUIObjectBoxView()) @@ -214,7 +204,7 @@ final class PhamePostEditController extends PhamePostController { ->appendChild( array( $form_box, - $preview_panel, + $preview, )); } diff --git a/src/applications/phame/controller/post/PhamePostPreviewController.php b/src/applications/phame/controller/post/PhamePostPreviewController.php deleted file mode 100644 index 3f81481576..0000000000 --- a/src/applications/phame/controller/post/PhamePostPreviewController.php +++ /dev/null @@ -1,26 +0,0 @@ -getViewer(); - $body = $request->getStr('body'); - - $post = id(new PhamePost()) - ->setBody($body); - - $content = PhabricatorMarkupEngine::renderOneObject( - $post, - PhamePost::MARKUP_FIELD_BODY, - $viewer); - - $content = phutil_tag_div('phabricator-remarkup', $content); - - return id(new AphrontAjaxResponse())->setContent($content); - } - -} diff --git a/src/view/phui/PHUIRemarkupPreviewPanel.php b/src/view/phui/PHUIRemarkupPreviewPanel.php index 5a0d8cfd84..064379cd0c 100644 --- a/src/view/phui/PHUIRemarkupPreviewPanel.php +++ b/src/view/phui/PHUIRemarkupPreviewPanel.php @@ -103,7 +103,7 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView { } else if ($this->previewType == self::DOCUMENT) { $header = id(new PHUIHeaderView()) - ->setHeader(pht('%s (Document Preview)', $this->header)); + ->setHeader(pht('%s (Preview)', $this->header)); $content = id(new PHUIDocumentViewPro()) ->setHeader($header) diff --git a/webroot/rsrc/js/application/phame/phame-post-preview.js b/webroot/rsrc/js/application/phame/phame-post-preview.js index 196b6e6469..377a6f66d5 100644 --- a/webroot/rsrc/js/application/phame/phame-post-preview.js +++ b/webroot/rsrc/js/application/phame/phame-post-preview.js @@ -8,7 +8,6 @@ JX.behavior('phame-post-preview', function(config) { - var body = JX.$(config.body); var title = JX.$(config.title); var phame_title = JX.$(config.phame_title); var sync_titles = true; @@ -54,27 +53,15 @@ JX.behavior('phame-post-preview', function(config) { return s; }; - var callback = function(r) { - JX.DOM.setContent(JX.$(config.preview), JX.$H(r)); - }; - var getdata = function() { return { - body : body.value, title : title.value, phame_title : phame_title.value }; }; - var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); - var trigger = JX.bind(request, request.trigger); - - JX.DOM.listen(body, 'keydown', null, trigger); - JX.DOM.listen(title, 'keydown', null, trigger); JX.DOM.listen(title, 'keyup', null, titleCallback); - JX.DOM.listen(phame_title, 'keydown', null, trigger); JX.DOM.listen(phame_title, 'keyup', null, phameTitleKeyupCallback); JX.DOM.listen(phame_title, 'blur', null, phameTitleBlurCallback); - request.start(); });