diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 71113b0984..3b99b07090 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -345,6 +345,7 @@ phutil_register_library_map(array( 'PhabricatorFeedStory' => 'applications/feed/story/base', 'PhabricatorFeedStoryData' => 'applications/feed/storage/story', 'PhabricatorFeedStoryDifferential' => 'applications/feed/story/differential', + 'PhabricatorFeedStoryPhriction' => 'applications/feed/story/phriction', 'PhabricatorFeedStoryPublisher' => 'applications/feed/publisher', 'PhabricatorFeedStoryReference' => 'applications/feed/storage/storyreference', 'PhabricatorFeedStoryStatus' => 'applications/feed/story/status', @@ -581,6 +582,8 @@ phutil_register_library_map(array( 'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile', 'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol', 'PhabricatorXHProfProfileTopLevelView' => 'applications/xhprof/view/toplevel', + 'PhrictionActionConstants' => 'applications/phriction/constants/action', + 'PhrictionConstants' => 'applications/phriction/constants/base', 'PhrictionContent' => 'applications/phriction/storage/content', 'PhrictionController' => 'applications/phriction/controller/base', 'PhrictionDAO' => 'applications/phriction/storage/base', @@ -874,6 +877,7 @@ phutil_register_library_map(array( 'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController', 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory', + 'PhabricatorFeedStoryPhriction' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants', @@ -1081,6 +1085,7 @@ phutil_register_library_map(array( 'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController', 'PhabricatorXHProfProfileSymbolView' => 'AphrontView', 'PhabricatorXHProfProfileTopLevelView' => 'AphrontView', + 'PhrictionActionConstants' => 'PhrictionConstants', 'PhrictionContent' => 'PhrictionDAO', 'PhrictionController' => 'PhabricatorController', 'PhrictionDAO' => 'PhabricatorLiskDAO', diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index a669d5fe69..a46d7191ff 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -368,7 +368,7 @@ class DifferentialRevisionEditor { ? DifferentialAction::ACTION_CREATE : DifferentialAction::ACTION_UPDATE, 'feedback_content' => $is_new - ? '' + ? phutil_utf8_shorten($revision->getSummary(), 140) : $this->getComments(), 'actor_phid' => $revision->getAuthorPHID(), ); diff --git a/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php b/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php index 867e535068..0ac7f802e8 100644 --- a/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php +++ b/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php @@ -19,8 +19,9 @@ final class PhabricatorFeedStoryTypeConstants extends PhabricatorFeedConstants { - const STORY_UNKNOWN = 'PhabricatorFeedStoryUnknown'; - const STORY_STATUS = 'PhabricatorFeedStoryStatus'; - const STORY_DIFFERENTIAL = 'PhabricatorFeedStoryDifferential'; + const STORY_UNKNOWN = 'PhabricatorFeedStoryUnknown'; + const STORY_STATUS = 'PhabricatorFeedStoryStatus'; + const STORY_DIFFERENTIAL = 'PhabricatorFeedStoryDifferential'; + const STORY_PHRICTION = 'PhabricatorFeedStoryPhriction'; } diff --git a/src/applications/feed/story/phriction/PhabricatorFeedStoryPhriction.php b/src/applications/feed/story/phriction/PhabricatorFeedStoryPhriction.php new file mode 100644 index 0000000000..8ab7289914 --- /dev/null +++ b/src/applications/feed/story/phriction/PhabricatorFeedStoryPhriction.php @@ -0,0 +1,82 @@ +getStoryData()->getAuthorPHID(), + $this->getStoryData()->getValue('phid'), + ); + } + + public function getRequiredObjectPHIDs() { + return array( + $this->getStoryData()->getAuthorPHID(), + ); + } + + public function renderView() { + $data = $this->getStoryData(); + + $handles = $this->getHandles(); + $author_phid = $data->getAuthorPHID(); + $document_phid = $data->getValue('phid'); + + $objects = $this->getObjects(); + + $view = new PhabricatorFeedStoryView(); + + $action = $data->getValue('action'); + $verb = PhrictionActionConstants::getActionPastTenseVerb($action); + + $view->setTitle( + ''.$handles[$author_phid]->renderLink().''. + ' '.$verb.' the document '. + ''.$handles[$document_phid]->renderLink().'.'); + $view->setEpoch($data->getEpoch()); + + $action = $data->getValue('action'); + switch ($action) { + case PhrictionActionConstants::ACTION_CREATE: + $full_size = true; + break; + default: + $full_size = false; + break; + } + + if ($full_size) { + if (!empty($objects[$author_phid])) { + $image_phid = $objects[$author_phid]->getProfileImagePHID(); + $image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid); + $view->setImage($image_uri); + } + + $content = phutil_escape_html($data->getValue('content')); + $content = str_replace("\n", '
', $content); + + $view->appendChild($content); + } else { + $view->setOneLineStory(true); + } + + return $view; + } + +} diff --git a/src/applications/feed/story/phriction/__init__.php b/src/applications/feed/story/phriction/__init__.php new file mode 100644 index 0000000000..22e9dabeb5 --- /dev/null +++ b/src/applications/feed/story/phriction/__init__.php @@ -0,0 +1,17 @@ + 'created', + self::ACTION_EDIT => 'edited', + ); + + return idx($map, $action, "brazenly {$action}'d"); + } + +} diff --git a/src/applications/phriction/constants/action/__init__.php b/src/applications/phriction/constants/action/__init__.php new file mode 100644 index 0000000000..2ac9c97919 --- /dev/null +++ b/src/applications/phriction/constants/action/__init__.php @@ -0,0 +1,14 @@ +getID()) { + $is_new = true; $document->save(); } @@ -98,6 +100,25 @@ class PhrictionEditController $document->attachContent($new_content); PhabricatorSearchPhrictionIndexer::indexDocument($document); + id(new PhabricatorFeedStoryPublisher()) + ->setRelatedPHIDs( + array( + $document->getPHID(), + $user->getPHID(), + )) + ->setStoryAuthorPHID($user->getPHID()) + ->setStoryTime(time()) + ->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_PHRICTION) + ->setStoryData( + array( + 'phid' => $document->getPHID(), + 'action' => $is_new + ? PhrictionActionConstants::ACTION_CREATE + : PhrictionActionConstants::ACTION_EDIT, + 'content' => phutil_utf8_shorten($new_content->getContent(), 140), + )) + ->publish(); + $uri = PhrictionDocument::getSlugURI($document->getSlug()); return id(new AphrontRedirectResponse())->setURI($uri); } diff --git a/src/applications/phriction/controller/edit/__init__.php b/src/applications/phriction/controller/edit/__init__.php index 50d25f580d..612ae43191 100644 --- a/src/applications/phriction/controller/edit/__init__.php +++ b/src/applications/phriction/controller/edit/__init__.php @@ -8,6 +8,9 @@ phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/feed/constants/story'); +phutil_require_module('phabricator', 'applications/feed/publisher'); +phutil_require_module('phabricator', 'applications/phriction/constants/action'); phutil_require_module('phabricator', 'applications/phriction/controller/base'); phutil_require_module('phabricator', 'applications/phriction/storage/content'); phutil_require_module('phabricator', 'applications/phriction/storage/document');