diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 406c38ae29..8fa5e928de 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -2268,19 +2268,6 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/phriction/phriction-document-preview.js', ), - 'javelin-behavior-ponder-feedback-preview' => - array( - 'uri' => '/res/2e802dd9/rsrc/js/application/ponder/behavior-comment-preview.js', - 'type' => 'js', - 'requires' => - array( - 0 => 'javelin-behavior', - 1 => 'javelin-dom', - 2 => 'javelin-util', - 3 => 'phabricator-shaped-request', - ), - 'disk' => '/rsrc/js/application/ponder/behavior-comment-preview.js', - ), 'javelin-behavior-ponder-votebox' => array( 'uri' => '/res/c28daa12/rsrc/js/application/ponder/behavior-votebox.js', @@ -3866,7 +3853,7 @@ celerity_register_resource_map(array( ), 'phui-remarkup-preview-css' => array( - 'uri' => '/res/702b30c4/rsrc/css/phui/phui-remarkup-preview.css', + 'uri' => '/res/80d54c8c/rsrc/css/phui/phui-remarkup-preview.css', 'type' => 'css', 'requires' => array( diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bcd0997123..ebf0ac40fb 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1899,10 +1899,8 @@ phutil_register_library_map(array( 'PonderConstants' => 'applications/ponder/constants/PonderConstants.php', 'PonderController' => 'applications/ponder/controller/PonderController.php', 'PonderDAO' => 'applications/ponder/storage/PonderDAO.php', - 'PonderLiterals' => 'applications/ponder/constants/PonderLiterals.php', 'PonderPHIDTypeAnswer' => 'applications/ponder/phid/PonderPHIDTypeAnswer.php', 'PonderPHIDTypeQuestion' => 'applications/ponder/phid/PonderPHIDTypeQuestion.php', - 'PonderPostBodyView' => 'applications/ponder/view/PonderPostBodyView.php', 'PonderQuestion' => 'applications/ponder/storage/PonderQuestion.php', 'PonderQuestionCommentController' => 'applications/ponder/controller/PonderQuestionCommentController.php', 'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php', @@ -1910,7 +1908,6 @@ phutil_register_library_map(array( 'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php', 'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php', 'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php', - 'PonderQuestionPreviewController' => 'applications/ponder/controller/PonderQuestionPreviewController.php', 'PonderQuestionQuery' => 'applications/ponder/query/PonderQuestionQuery.php', 'PonderQuestionReplyHandler' => 'applications/ponder/mail/PonderQuestionReplyHandler.php', 'PonderQuestionSearchEngine' => 'applications/ponder/query/PonderQuestionSearchEngine.php', @@ -4034,10 +4031,8 @@ phutil_register_library_map(array( 'PonderCommentQuery' => 'PhabricatorQuery', 'PonderController' => 'PhabricatorController', 'PonderDAO' => 'PhabricatorLiskDAO', - 'PonderLiterals' => 'PonderConstants', 'PonderPHIDTypeAnswer' => 'PhabricatorPHIDType', 'PonderPHIDTypeQuestion' => 'PhabricatorPHIDType', - 'PonderPostBodyView' => 'AphrontView', 'PonderQuestion' => array( 0 => 'PonderDAO', @@ -4057,7 +4052,6 @@ phutil_register_library_map(array( 1 => 'PhabricatorApplicationSearchResultsControllerInterface', ), 'PonderQuestionMailReceiver' => 'PhabricatorObjectMailReceiver', - 'PonderQuestionPreviewController' => 'PonderController', 'PonderQuestionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PonderQuestionReplyHandler' => 'PhabricatorMailReplyHandler', 'PonderQuestionSearchEngine' => 'PhabricatorApplicationSearchEngine', diff --git a/src/applications/ponder/application/PhabricatorApplicationPonder.php b/src/applications/ponder/application/PhabricatorApplicationPonder.php index 5e6fb5ebdf..220750b558 100644 --- a/src/applications/ponder/application/PhabricatorApplicationPonder.php +++ b/src/applications/ponder/application/PhabricatorApplicationPonder.php @@ -57,7 +57,7 @@ final class PhabricatorApplicationPonder extends PhabricatorApplication { 'question/edit/(?:(?P\d+)/)?' => 'PonderQuestionEditController', 'question/comment/(?P\d+)/' => 'PonderQuestionCommentController', 'question/history/(?P\d+)/' => 'PonderQuestionHistoryController', - 'question/preview/' => 'PonderQuestionPreviewController', + 'preview/' => 'PhabricatorMarkupPreviewController', 'question/(?Popen|close)/(?P[1-9]\d*)/' => 'PonderQuestionStatusController', 'vote/' => 'PonderVoteSaveController', diff --git a/src/applications/ponder/constants/PonderLiterals.php b/src/applications/ponder/constants/PonderLiterals.php deleted file mode 100644 index be7deb9f05..0000000000 --- a/src/applications/ponder/constants/PonderLiterals.php +++ /dev/null @@ -1,10 +0,0 @@ -setErrors($errors); } + $answer_content_id = celerity_generate_unique_node_id(); + $form = id(new AphrontFormView()) ->setUser($viewer) ->appendChild( @@ -76,6 +78,7 @@ final class PonderAnswerEditController extends PonderController { id(new PhabricatorRemarkupControl()) ->setLabel(pht('Answer')) ->setName('content') + ->setID($answer_content_id) ->setValue($v_content) ->setError($e_content)) ->appendChild( @@ -92,11 +95,17 @@ final class PonderAnswerEditController extends PonderController { id(new PhabricatorCrumbView()) ->setName(pht('Edit Answer'))); + $preview = id(new PHUIRemarkupPreviewPanel()) + ->setHeader(pht('Answer Preview')) + ->setControlID($answer_content_id) + ->setPreviewURI($this->getApplicationURI('preview/')); + return $this->buildApplicationPage( array( $crumbs, $errors, $form, + $preview, ), array( 'title' => pht('Edit Answer'), diff --git a/src/applications/ponder/controller/PonderQuestionEditController.php b/src/applications/ponder/controller/PonderQuestionEditController.php index aa6165ff9c..c9999fa4c0 100644 --- a/src/applications/ponder/controller/PonderQuestionEditController.php +++ b/src/applications/ponder/controller/PonderQuestionEditController.php @@ -104,22 +104,10 @@ final class PonderQuestionEditController extends PonderController { ->addCancelButton($this->getApplicationURI()) ->setValue(pht('Ask Away!'))); - $preview = hsprintf( - '
'. - '
'. - '%s'. - '
'. - '
', - pht('Loading question preview...')); - - Javelin::initBehavior( - 'ponder-feedback-preview', - array( - 'uri' => '/ponder/question/preview/', - 'content' => 'content', - 'preview' => 'question-preview', - 'question_id' => null - )); + $preview = id(new PHUIRemarkupPreviewPanel()) + ->setHeader(pht('Question Preview')) + ->setControlID('content') + ->setPreviewURI($this->getApplicationURI('preview/')); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/ponder/controller/PonderQuestionPreviewController.php b/src/applications/ponder/controller/PonderQuestionPreviewController.php deleted file mode 100644 index e09272e912..0000000000 --- a/src/applications/ponder/controller/PonderQuestionPreviewController.php +++ /dev/null @@ -1,35 +0,0 @@ -getRequest(); - - $user = $request->getUser(); - $author_phid = $user->getPHID(); - - $object_phids = array($author_phid); - $handles = $this->loadViewerHandles($object_phids); - - $question = new PonderQuestion(); - $question->setContent($request->getStr('content')); - $question->setAuthorPHID($author_phid); - - $view = new PonderPostBodyView(); - $view - ->setQuestion($question) - ->setTarget($question) - ->setPreview(true) - ->setUser($user) - ->setHandles($handles) - ->setAction(self::VERB_ASKED); - - return id(new AphrontAjaxResponse()) - ->setContent($view->render()); - } - -} diff --git a/src/applications/ponder/view/PonderAddAnswerView.php b/src/applications/ponder/view/PonderAddAnswerView.php index 04307bb72a..a5fb0109a4 100644 --- a/src/applications/ponder/view/PonderAddAnswerView.php +++ b/src/applications/ponder/view/PonderAddAnswerView.php @@ -41,8 +41,8 @@ final class PonderAddAnswerView extends AphrontView { ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($is_serious ? - pht('Submit') : - pht('Make it so'))); + pht('Add Answer') : + pht('Bequeath Wisdom'))); return id(new AphrontNullView()) ->appendChild( diff --git a/src/applications/ponder/view/PonderPostBodyView.php b/src/applications/ponder/view/PonderPostBodyView.php deleted file mode 100644 index 2d5c2be484..0000000000 --- a/src/applications/ponder/view/PonderPostBodyView.php +++ /dev/null @@ -1,103 +0,0 @@ -question = $question; - return $this; - } - - public function setTarget($target) { - $this->target = $target; - return $this; - } - - public function setAction($action) { - $this->action = $action; - return $this; - } - - public function setHandles(array $handles) { - assert_instances_of($handles, 'PhabricatorObjectHandle'); - $this->handles = $handles; - return $this; - } - - public function setPreview($preview) { - $this->preview = $preview; - return $this; - } - - public function render() { - - if (!$this->user) { - throw new Exception("Call setUser() before rendering!"); - } - - require_celerity_resource('phabricator-remarkup-css'); - require_celerity_resource('ponder-post-css'); - - $user = $this->user; - $question = $this->question; - $target = $this->target; - $content = $target->getContent(); - $info = array(); - - - $content = PhabricatorMarkupEngine::renderOneObject( - $target, - $target->getMarkupField(), - $this->user); - - $content = phutil_tag( - 'div', - array( - 'class' => 'phabricator-remarkup', - ), - $content); - - $author = $this->handles[$target->getAuthorPHID()]; - $actions = array(hsprintf('%s %s', $author->renderLink(), $this->action)); - $author_link = $author->renderLink(); - $xaction_view = id(new PhabricatorTransactionView()) - ->setUser($user) - ->setImageURI($author->getImageURI()) - ->setContentSource($target->getContentSource()) - ->setActions($actions); - - if ($this->target instanceof PonderAnswer) { - $xaction_view->addClass("ponder-answer"); - } else { - $xaction_view->addClass("ponder-question"); - } - - if ($this->preview) { - $xaction_view->setIsPreview($this->preview); - } else { - $xaction_view->setEpoch($target->getDateCreated()); - if ($this->target instanceof PonderAnswer) { - $anchor_text = 'Q' . $question->getID(). '#A' . $target->getID(); - $xaction_view->setAnchor('A'.$target->getID(), $anchor_text); - $xaction_view->addClass("ponder-answer"); - } - } - - $xaction_view->appendChild( - phutil_tag( - 'div', - array( - 'class' => 'ponder-post-core', - ), - $content)); - - return $xaction_view; - } - -} diff --git a/webroot/rsrc/js/application/ponder/behavior-comment-preview.js b/webroot/rsrc/js/application/ponder/behavior-comment-preview.js deleted file mode 100644 index 8a944411a2..0000000000 --- a/webroot/rsrc/js/application/ponder/behavior-comment-preview.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @provides javelin-behavior-ponder-feedback-preview - * @requires javelin-behavior - * javelin-dom - * javelin-util - * phabricator-shaped-request - */ - -JX.behavior('ponder-feedback-preview', function(config) { - - var content = JX.$(config.content); - var question_id = config.question_id; - - var callback = function(r) { - JX.DOM.setContent(JX.$(config.preview), JX.$H(r)); - }; - - var getdata = function() { - var data = { - content : content.value, - question_id : question_id - }; - return data; - }; - - var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); - var trigger = JX.bind(request, request.trigger); - - JX.DOM.listen(content, 'keydown', null, trigger); - - request.start(); -});