mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Use CommentEditEngine in PhamePost
Summary: Ref T9360. Moves PhamePost to CommentEditEngine. [x] HTTP Parameters dropdown on New Post goes to 404 [x] Implement EditEngine Comments Test Plan: Make Post, Make Comment, Laugh. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9360 Differential Revision: https://secure.phabricator.com/D16222
This commit is contained in:
parent
38c290a241
commit
15f9e0f6ea
11 changed files with 60 additions and 88 deletions
|
@ -81,7 +81,7 @@ return array(
|
|||
'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b',
|
||||
'rsrc/css/application/paste/paste.css' => '1898e534',
|
||||
'rsrc/css/application/people/people-profile.css' => '2473d929',
|
||||
'rsrc/css/application/phame/phame.css' => 'bf6a743f',
|
||||
'rsrc/css/application/phame/phame.css' => '8efb0729',
|
||||
'rsrc/css/application/pholio/pholio-edit.css' => '07676f51',
|
||||
'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49',
|
||||
'rsrc/css/application/pholio/pholio.css' => 'ca89d380',
|
||||
|
@ -811,7 +811,7 @@ return array(
|
|||
'phabricator-uiexample-reactor-sendclass' => '1def2711',
|
||||
'phabricator-uiexample-reactor-sendproperties' => 'b1f0ccee',
|
||||
'phabricator-zindex-css' => '5b6fcf3f',
|
||||
'phame-css' => 'bf6a743f',
|
||||
'phame-css' => '8efb0729',
|
||||
'pholio-css' => 'ca89d380',
|
||||
'pholio-edit-css' => '07676f51',
|
||||
'pholio-inline-comments-css' => '8e545e49',
|
||||
|
|
|
@ -3834,7 +3834,6 @@ phutil_register_library_map(array(
|
|||
'PhameNextPostView' => 'applications/phame/view/PhameNextPostView.php',
|
||||
'PhamePost' => 'applications/phame/storage/PhamePost.php',
|
||||
'PhamePostArchiveController' => 'applications/phame/controller/post/PhamePostArchiveController.php',
|
||||
'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php',
|
||||
'PhamePostController' => 'applications/phame/controller/post/PhamePostController.php',
|
||||
'PhamePostEditConduitAPIMethod' => 'applications/phame/conduit/PhamePostEditConduitAPIMethod.php',
|
||||
'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php',
|
||||
|
@ -3848,6 +3847,7 @@ phutil_register_library_map(array(
|
|||
'PhamePostMoveController' => 'applications/phame/controller/post/PhamePostMoveController.php',
|
||||
'PhamePostPublishController' => 'applications/phame/controller/post/PhamePostPublishController.php',
|
||||
'PhamePostQuery' => 'applications/phame/query/PhamePostQuery.php',
|
||||
'PhamePostRemarkupRule' => 'applications/phame/remarkup/PhamePostRemarkupRule.php',
|
||||
'PhamePostReplyHandler' => 'applications/phame/mail/PhamePostReplyHandler.php',
|
||||
'PhamePostSearchConduitAPIMethod' => 'applications/phame/conduit/PhamePostSearchConduitAPIMethod.php',
|
||||
'PhamePostSearchEngine' => 'applications/phame/query/PhamePostSearchEngine.php',
|
||||
|
@ -8760,7 +8760,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFulltextInterface',
|
||||
),
|
||||
'PhamePostArchiveController' => 'PhamePostController',
|
||||
'PhamePostCommentController' => 'PhamePostController',
|
||||
'PhamePostController' => 'PhameController',
|
||||
'PhamePostEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
||||
'PhamePostEditController' => 'PhamePostController',
|
||||
|
@ -8774,6 +8773,7 @@ phutil_register_library_map(array(
|
|||
'PhamePostMoveController' => 'PhamePostController',
|
||||
'PhamePostPublishController' => 'PhamePostController',
|
||||
'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhamePostRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'PhamePostReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||
'PhamePostSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||
'PhamePostSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
|
|
@ -37,7 +37,8 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
|
|||
|
||||
public function getRoutes() {
|
||||
return array(
|
||||
'/phame/' => array(
|
||||
'/J(?P<id>[1-9]\d*)' => 'PhamePostViewController',
|
||||
'/phame/' => array(
|
||||
'' => 'PhameHomeController',
|
||||
|
||||
// NOTE: The live routes include an initial "/", so leave it off
|
||||
|
@ -46,17 +47,16 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
|
|||
'post/' => array(
|
||||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhamePostListController',
|
||||
'blogger/(?P<bloggername>[\w\.-_]+)/' => 'PhamePostListController',
|
||||
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
|
||||
$this->getEditRoutePattern('edit/')
|
||||
=> 'PhamePostEditController',
|
||||
'history/(?P<id>\d+)/' => 'PhamePostHistoryController',
|
||||
'view/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController',
|
||||
'(?P<action>publish|unpublish)/(?P<id>\d+)/'
|
||||
=> 'PhamePostPublishController',
|
||||
'preview/(?P<id>\d+)/' => 'PhamePostPreviewController',
|
||||
'preview/' => 'PhabricatorMarkupPreviewController',
|
||||
'framed/(?P<id>\d+)/' => 'PhamePostFramedController',
|
||||
'move/(?P<id>\d+)/' => 'PhamePostMoveController',
|
||||
'archive/(?P<id>\d+)/' => 'PhamePostArchiveController',
|
||||
'comment/(?P<id>[1-9]\d*)/' => 'PhamePostCommentController',
|
||||
),
|
||||
'blog/' => array(
|
||||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhameBlogListController',
|
||||
|
@ -107,6 +107,13 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
|
|||
);
|
||||
}
|
||||
|
||||
public function getRemarkupRules() {
|
||||
return array(
|
||||
new PhamePostRemarkupRule(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function getCustomCapabilities() {
|
||||
return array(
|
||||
PhameBlogCreateCapability::CAPABILITY => array(
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostCommentController
|
||||
extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if (!$request->isFormPost()) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$post) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$is_preview = $request->isPreviewRequest();
|
||||
$draft = PhabricatorDraft::buildFromRequest($request);
|
||||
|
||||
$view_uri = $this->getApplicationURI('post/view/'.$post->getID().'/');
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhamePostTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||
->attachComment(
|
||||
id(new PhamePostTransactionComment())
|
||||
->setContent($request->getStr('comment')));
|
||||
|
||||
$editor = id(new PhamePostEditor())
|
||||
->setActor($viewer)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSourceFromRequest($request)
|
||||
->setIsPreview($is_preview);
|
||||
|
||||
try {
|
||||
$xactions = $editor->applyTransactions($post, $xactions);
|
||||
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
||||
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
||||
->setCancelURI($view_uri)
|
||||
->setException($ex);
|
||||
}
|
||||
|
||||
if ($draft) {
|
||||
$draft->replaceOrDelete();
|
||||
}
|
||||
|
||||
if ($request->isAjax() && $is_preview) {
|
||||
return id(new PhabricatorApplicationTransactionResponse())
|
||||
->setViewer($viewer)
|
||||
->setTransactions($xactions)
|
||||
->setIsPreview($is_preview);
|
||||
} else {
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($view_uri);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -123,19 +123,22 @@ final class PhamePostViewController
|
|||
->setImage($blogger->getProfileImageURI())
|
||||
->setImageHref($author_uri);
|
||||
|
||||
$monogram = $post->getMonogram();
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$post,
|
||||
id(new PhamePostTransactionQuery())
|
||||
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)));
|
||||
$timeline = phutil_tag_div('phui-document-view-pro-box', $timeline);
|
||||
$timeline->setQuoteRef($monogram);
|
||||
|
||||
if ($is_external) {
|
||||
$add_comment = null;
|
||||
} else {
|
||||
$add_comment = $this->buildCommentForm($post);
|
||||
$add_comment = phutil_tag_div('mlb mlt', $add_comment);
|
||||
$add_comment = $this->buildCommentForm($post, $timeline);
|
||||
$add_comment = phutil_tag_div('mlb mlt phame-comment-view', $add_comment);
|
||||
}
|
||||
|
||||
$timeline = phutil_tag_div('phui-document-view-pro-box', $timeline);
|
||||
|
||||
list($prev, $next) = $this->loadAdjacentPosts($post);
|
||||
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
|
@ -273,19 +276,13 @@ final class PhamePostViewController
|
|||
return $actions;
|
||||
}
|
||||
|
||||
private function buildCommentForm(PhamePost $post) {
|
||||
private function buildCommentForm(PhamePost $post, $timeline) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$draft = PhabricatorDraft::newFromUserAndKey(
|
||||
$viewer, $post->getPHID());
|
||||
|
||||
$box = id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($post->getPHID())
|
||||
->setDraft($draft)
|
||||
->setHeaderText(pht('Add Comment'))
|
||||
->setAction($this->getApplicationURI('post/comment/'.$post->getID().'/'))
|
||||
->setSubmitButtonName(pht('Add Comment'));
|
||||
$box = id(new PhamePostEditEngine())
|
||||
->setViewer($viewer)
|
||||
->buildEditEngineCommentView($post)
|
||||
->setTransactionTimeline($timeline);
|
||||
|
||||
return phutil_tag_div('phui-document-view-pro-box', $box);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,10 @@ final class PhamePostEditEngine
|
|||
return $object->getViewURI();
|
||||
}
|
||||
|
||||
protected function getEditorURI() {
|
||||
return $this->getApplication()->getApplicationURI('post/edit/');
|
||||
}
|
||||
|
||||
protected function buildCustomEditFields($object) {
|
||||
$blog_phid = $object->getBlog()->getPHID();
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ final class PhamePostMailReceiver
|
|||
}
|
||||
|
||||
protected function getObjectPattern() {
|
||||
return 'POST[1-9]\d*';
|
||||
return 'J[1-9]\d*';
|
||||
}
|
||||
|
||||
protected function loadObject($pattern, PhabricatorUser $viewer) {
|
||||
|
|
|
@ -32,8 +32,8 @@ final class PhabricatorPhamePostPHIDType extends PhabricatorPHIDType {
|
|||
foreach ($handles as $phid => $handle) {
|
||||
$post = $objects[$phid];
|
||||
$handle->setName($post->getTitle());
|
||||
$handle->setFullName($post->getTitle());
|
||||
$handle->setURI('/phame/post/view/'.$post->getID().'/');
|
||||
$handle->setFullName(pht('Blog Post: ').$post->getTitle());
|
||||
$handle->setURI('/J'.$post->getID());
|
||||
|
||||
if ($post->isArchived()) {
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
|
|
19
src/applications/phame/remarkup/PhamePostRemarkupRule.php
Normal file
19
src/applications/phame/remarkup/PhamePostRemarkupRule.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostRemarkupRule
|
||||
extends PhabricatorObjectRemarkupRule {
|
||||
|
||||
protected function getObjectNamePrefix() {
|
||||
return 'J';
|
||||
}
|
||||
|
||||
protected function loadObjects(array $ids) {
|
||||
$viewer = $this->getEngine()->getConfig('viewer');
|
||||
|
||||
return id(new PhamePostQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs($ids)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
|
@ -51,6 +51,10 @@ final class PhamePost extends PhameDAO
|
|||
return $this->assertAttached($this->blog);
|
||||
}
|
||||
|
||||
public function getMonogram() {
|
||||
return 'J'.$this->getID();
|
||||
}
|
||||
|
||||
public function getLiveURI() {
|
||||
$blog = $this->getBlog();
|
||||
$is_draft = $this->isDraft();
|
||||
|
|
|
@ -308,3 +308,7 @@
|
|||
font-family: 'Aleo', {$fontfamily};
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.phame-comment-view .aphront-form-control.aphront-form-control-select {
|
||||
display: none;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue