mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Publish Phriction edits to feed
Summary: Basic integration between Phriction and feed. Test Plan: Created and edited some documents, they published to feed. Reviewed By: hsb Reviewers: hsb, codeblock, jungejason, tuomaspelkonen, aran CC: aran, hsb Differential Revision: 653
This commit is contained in:
parent
d28326446d
commit
f761ee91d3
11 changed files with 211 additions and 4 deletions
|
@ -345,6 +345,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFeedStory' => 'applications/feed/story/base',
|
'PhabricatorFeedStory' => 'applications/feed/story/base',
|
||||||
'PhabricatorFeedStoryData' => 'applications/feed/storage/story',
|
'PhabricatorFeedStoryData' => 'applications/feed/storage/story',
|
||||||
'PhabricatorFeedStoryDifferential' => 'applications/feed/story/differential',
|
'PhabricatorFeedStoryDifferential' => 'applications/feed/story/differential',
|
||||||
|
'PhabricatorFeedStoryPhriction' => 'applications/feed/story/phriction',
|
||||||
'PhabricatorFeedStoryPublisher' => 'applications/feed/publisher',
|
'PhabricatorFeedStoryPublisher' => 'applications/feed/publisher',
|
||||||
'PhabricatorFeedStoryReference' => 'applications/feed/storage/storyreference',
|
'PhabricatorFeedStoryReference' => 'applications/feed/storage/storyreference',
|
||||||
'PhabricatorFeedStoryStatus' => 'applications/feed/story/status',
|
'PhabricatorFeedStoryStatus' => 'applications/feed/story/status',
|
||||||
|
@ -581,6 +582,8 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
||||||
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
||||||
'PhabricatorXHProfProfileTopLevelView' => 'applications/xhprof/view/toplevel',
|
'PhabricatorXHProfProfileTopLevelView' => 'applications/xhprof/view/toplevel',
|
||||||
|
'PhrictionActionConstants' => 'applications/phriction/constants/action',
|
||||||
|
'PhrictionConstants' => 'applications/phriction/constants/base',
|
||||||
'PhrictionContent' => 'applications/phriction/storage/content',
|
'PhrictionContent' => 'applications/phriction/storage/content',
|
||||||
'PhrictionController' => 'applications/phriction/controller/base',
|
'PhrictionController' => 'applications/phriction/controller/base',
|
||||||
'PhrictionDAO' => 'applications/phriction/storage/base',
|
'PhrictionDAO' => 'applications/phriction/storage/base',
|
||||||
|
@ -874,6 +877,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController',
|
'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController',
|
||||||
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
|
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
|
||||||
'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory',
|
'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory',
|
||||||
|
'PhabricatorFeedStoryPhriction' => 'PhabricatorFeedStory',
|
||||||
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
|
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
|
||||||
'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory',
|
'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory',
|
||||||
'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants',
|
'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants',
|
||||||
|
@ -1081,6 +1085,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
||||||
'PhabricatorXHProfProfileSymbolView' => 'AphrontView',
|
'PhabricatorXHProfProfileSymbolView' => 'AphrontView',
|
||||||
'PhabricatorXHProfProfileTopLevelView' => 'AphrontView',
|
'PhabricatorXHProfProfileTopLevelView' => 'AphrontView',
|
||||||
|
'PhrictionActionConstants' => 'PhrictionConstants',
|
||||||
'PhrictionContent' => 'PhrictionDAO',
|
'PhrictionContent' => 'PhrictionDAO',
|
||||||
'PhrictionController' => 'PhabricatorController',
|
'PhrictionController' => 'PhabricatorController',
|
||||||
'PhrictionDAO' => 'PhabricatorLiskDAO',
|
'PhrictionDAO' => 'PhabricatorLiskDAO',
|
||||||
|
|
|
@ -368,7 +368,7 @@ class DifferentialRevisionEditor {
|
||||||
? DifferentialAction::ACTION_CREATE
|
? DifferentialAction::ACTION_CREATE
|
||||||
: DifferentialAction::ACTION_UPDATE,
|
: DifferentialAction::ACTION_UPDATE,
|
||||||
'feedback_content' => $is_new
|
'feedback_content' => $is_new
|
||||||
? ''
|
? phutil_utf8_shorten($revision->getSummary(), 140)
|
||||||
: $this->getComments(),
|
: $this->getComments(),
|
||||||
'actor_phid' => $revision->getAuthorPHID(),
|
'actor_phid' => $revision->getAuthorPHID(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
final class PhabricatorFeedStoryTypeConstants
|
final class PhabricatorFeedStoryTypeConstants
|
||||||
extends PhabricatorFeedConstants {
|
extends PhabricatorFeedConstants {
|
||||||
|
|
||||||
const STORY_UNKNOWN = 'PhabricatorFeedStoryUnknown';
|
const STORY_UNKNOWN = 'PhabricatorFeedStoryUnknown';
|
||||||
const STORY_STATUS = 'PhabricatorFeedStoryStatus';
|
const STORY_STATUS = 'PhabricatorFeedStoryStatus';
|
||||||
const STORY_DIFFERENTIAL = 'PhabricatorFeedStoryDifferential';
|
const STORY_DIFFERENTIAL = 'PhabricatorFeedStoryDifferential';
|
||||||
|
const STORY_PHRICTION = 'PhabricatorFeedStoryPhriction';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
|
||||||
|
|
||||||
|
public function getRequiredHandlePHIDs() {
|
||||||
|
return array(
|
||||||
|
$this->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(
|
||||||
|
'<strong>'.$handles[$author_phid]->renderLink().'</strong>'.
|
||||||
|
' '.$verb.' the document '.
|
||||||
|
'<strong>'.$handles[$document_phid]->renderLink().'</strong>.');
|
||||||
|
$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", '<br />', $content);
|
||||||
|
|
||||||
|
$view->appendChild($content);
|
||||||
|
} else {
|
||||||
|
$view->setOneLineStory(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
src/applications/feed/story/phriction/__init__.php
Normal file
17
src/applications/feed/story/phriction/__init__.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/feed/story/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/feed/view/story');
|
||||||
|
phutil_require_module('phabricator', 'applications/files/uri');
|
||||||
|
phutil_require_module('phabricator', 'applications/phriction/constants/action');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorFeedStoryPhriction.php');
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhrictionActionConstants extends PhrictionConstants {
|
||||||
|
|
||||||
|
const ACTION_CREATE = 'create';
|
||||||
|
const ACTION_EDIT = 'edit';
|
||||||
|
|
||||||
|
public static function getActionPastTenseVerb($action) {
|
||||||
|
static $map = array(
|
||||||
|
self::ACTION_CREATE => 'created',
|
||||||
|
self::ACTION_EDIT => 'edited',
|
||||||
|
);
|
||||||
|
|
||||||
|
return idx($map, $action, "brazenly {$action}'d");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
src/applications/phriction/constants/action/__init__.php
Normal file
14
src/applications/phriction/constants/action/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/phriction/constants/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhrictionActionConstants.php');
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class PhrictionConstants {
|
||||||
|
|
||||||
|
}
|
10
src/applications/phriction/constants/base/__init__.php
Normal file
10
src/applications/phriction/constants/base/__init__.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhrictionConstants.php');
|
|
@ -77,7 +77,9 @@ class PhrictionEditController
|
||||||
|
|
||||||
// TODO: This should all be transactional.
|
// TODO: This should all be transactional.
|
||||||
|
|
||||||
|
$is_new = false;
|
||||||
if (!$document->getID()) {
|
if (!$document->getID()) {
|
||||||
|
$is_new = true;
|
||||||
$document->save();
|
$document->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +100,25 @@ class PhrictionEditController
|
||||||
$document->attachContent($new_content);
|
$document->attachContent($new_content);
|
||||||
PhabricatorSearchPhrictionIndexer::indexDocument($document);
|
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());
|
$uri = PhrictionDocument::getSlugURI($document->getSlug());
|
||||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
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/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/phriction/storage/content');
|
phutil_require_module('phabricator', 'applications/phriction/storage/content');
|
||||||
phutil_require_module('phabricator', 'applications/phriction/storage/document');
|
phutil_require_module('phabricator', 'applications/phriction/storage/document');
|
||||||
|
|
Loading…
Reference in a new issue