mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Publish Differential stories into feed
Summary: Basic hookup for Differential -> Feed. Also introduces "one-line" stories for less-important stuff. Test Plan: Interacted with some revisions, got feed stories out of it. Reviewed By: jungejason Reviewers: jungejason, aran, tuomaspelkonen, codeblock CC: aran, jungejason Differential Revision: 632
This commit is contained in:
parent
4452239d61
commit
f55c082e65
17 changed files with 255 additions and 26 deletions
|
@ -1026,7 +1026,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'phabricator-feed-css' =>
|
||||
array(
|
||||
'uri' => '/res/617811ab/rsrc/css/application/feed/feed.css',
|
||||
'uri' => '/res/32e5879b/rsrc/css/application/feed/feed.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
|
|
|
@ -338,14 +338,17 @@ phutil_register_library_map(array(
|
|||
'PhabricatorEmailLoginController' => 'applications/auth/controller/email',
|
||||
'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken',
|
||||
'PhabricatorEnv' => 'infrastructure/env',
|
||||
'PhabricatorFeedConstants' => 'applications/feed/constants/base',
|
||||
'PhabricatorFeedController' => 'applications/feed/controller/base',
|
||||
'PhabricatorFeedDAO' => 'applications/feed/storage/base',
|
||||
'PhabricatorFeedQuery' => 'applications/feed/query',
|
||||
'PhabricatorFeedStory' => 'applications/feed/story/base',
|
||||
'PhabricatorFeedStoryData' => 'applications/feed/storage/story',
|
||||
'PhabricatorFeedStoryDifferential' => 'applications/feed/story/differential',
|
||||
'PhabricatorFeedStoryPublisher' => 'applications/feed/publisher',
|
||||
'PhabricatorFeedStoryReference' => 'applications/feed/storage/storyreference',
|
||||
'PhabricatorFeedStoryStatus' => 'applications/feed/story/status',
|
||||
'PhabricatorFeedStoryTypeConstants' => 'applications/feed/constants/story',
|
||||
'PhabricatorFeedStoryUnknown' => 'applications/feed/story/unknown',
|
||||
'PhabricatorFeedStoryView' => 'applications/feed/view/story',
|
||||
'PhabricatorFeedStreamController' => 'applications/feed/controller/stream',
|
||||
|
@ -857,8 +860,10 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFeedController' => 'PhabricatorController',
|
||||
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
|
||||
'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory',
|
||||
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
|
||||
'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory',
|
||||
'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants',
|
||||
'PhabricatorFeedStoryUnknown' => 'PhabricatorFeedStory',
|
||||
'PhabricatorFeedStoryView' => 'PhabricatorFeedView',
|
||||
'PhabricatorFeedStreamController' => 'PhabricatorFeedController',
|
||||
|
|
|
@ -411,6 +411,20 @@ class DifferentialCommentEditor {
|
|||
id(new PhabricatorTimelineEvent('difx', $event_data))
|
||||
->recordEvent();
|
||||
|
||||
// TODO: Move to a daemon?
|
||||
id(new PhabricatorFeedStoryPublisher())
|
||||
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL)
|
||||
->setStoryData($event_data)
|
||||
->setStoryTime(time())
|
||||
->setStoryAuthorPHID($this->actorPHID)
|
||||
->setRelatedPHIDs(
|
||||
array(
|
||||
$revision->getPHID(),
|
||||
$this->actorPHID,
|
||||
$revision->getAuthorPHID(),
|
||||
))
|
||||
->publish();
|
||||
|
||||
// TODO: Move to a daemon?
|
||||
PhabricatorSearchDifferentialIndexer::indexRevision($revision);
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
|||
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
|
||||
phutil_require_module('phabricator', 'applications/feed/constants/story');
|
||||
phutil_require_module('phabricator', 'applications/feed/publisher');
|
||||
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'applications/search/index/indexer/differential');
|
||||
|
|
|
@ -375,6 +375,18 @@ class DifferentialRevisionEditor {
|
|||
id(new PhabricatorTimelineEvent('difx', $event_data))
|
||||
->recordEvent();
|
||||
|
||||
id(new PhabricatorFeedStoryPublisher())
|
||||
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL)
|
||||
->setStoryData($event_data)
|
||||
->setStoryTime(time())
|
||||
->setStoryAuthorPHID($revision->getAuthorPHID())
|
||||
->setRelatedPHIDs(
|
||||
array(
|
||||
$revision->getPHID(),
|
||||
$revision->getAuthorPHID(),
|
||||
))
|
||||
->publish();
|
||||
|
||||
// TODO
|
||||
// $revision->saveTransaction();
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ phutil_require_module('phabricator', 'applications/differential/mail/ccwelcome')
|
|||
phutil_require_module('phabricator', 'applications/differential/mail/newdiff');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
phutil_require_module('phabricator', 'applications/feed/constants/story');
|
||||
phutil_require_module('phabricator', 'applications/feed/publisher');
|
||||
phutil_require_module('phabricator', 'applications/herald/adapter/differential');
|
||||
phutil_require_module('phabricator', 'applications/herald/engine/engine');
|
||||
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');
|
||||
|
|
|
@ -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 PhabricatorFeedConstants {
|
||||
|
||||
}
|
10
src/applications/feed/constants/base/__init__.php
Normal file
10
src/applications/feed/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('PhabricatorFeedConstants.php');
|
|
@ -0,0 +1,26 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
final class PhabricatorFeedStoryTypeConstants
|
||||
extends PhabricatorFeedConstants {
|
||||
|
||||
const STORY_UNKNOWN = 'PhabricatorFeedStoryUnknown';
|
||||
const STORY_STATUS = 'PhabricatorFeedStoryStatus';
|
||||
const STORY_DIFFERENTIAL = 'PhabricatorFeedStoryDifferential';
|
||||
|
||||
}
|
12
src/applications/feed/constants/story/__init__.php
Normal file
12
src/applications/feed/constants/story/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/feed/constants/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorFeedStoryTypeConstants.php');
|
|
@ -26,7 +26,7 @@ final class PhabricatorFeedStreamController extends PhabricatorFeedController {
|
|||
if ($request->isFormPost()) {
|
||||
$story = id(new PhabricatorFeedStoryPublisher())
|
||||
->setRelatedPHIDs(array($viewer->getPHID()))
|
||||
->setStoryType('PhabricatorFeedStoryStatus')
|
||||
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_STATUS)
|
||||
->setStoryTime(time())
|
||||
->setStoryAuthorPHID($viewer->getPHID())
|
||||
->setStoryData(
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/feed/constants/story');
|
||||
phutil_require_module('phabricator', 'applications/feed/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/feed/publisher');
|
||||
phutil_require_module('phabricator', 'applications/feed/query');
|
||||
|
|
|
@ -71,7 +71,7 @@ final class PhabricatorFeedStoryPublisher {
|
|||
|
||||
$sql = array();
|
||||
$conn = $ref->establishConnection('w');
|
||||
foreach ($this->relatedPHIDs as $phid) {
|
||||
foreach (array_unique($this->relatedPHIDs) as $phid) {
|
||||
$sql[] = qsprintf(
|
||||
$conn,
|
||||
'(%s, %s)',
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<?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 PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
||||
|
||||
public function getRequiredHandlePHIDs() {
|
||||
$data = $this->getStoryData();
|
||||
return array(
|
||||
$this->getStoryData()->getAuthorPHID(),
|
||||
$data->getValue('revision_phid'),
|
||||
$data->getValue('revision_author_phid'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getRequiredObjectPHIDs() {
|
||||
return array(
|
||||
$this->getStoryData()->getAuthorPHID(),
|
||||
);
|
||||
}
|
||||
|
||||
public function renderView() {
|
||||
$data = $this->getStoryData();
|
||||
|
||||
$handles = $this->getHandles();
|
||||
$author_phid = $data->getAuthorPHID();
|
||||
|
||||
$objects = $this->getObjects();
|
||||
|
||||
$view = new PhabricatorFeedStoryView();
|
||||
|
||||
$revision_phid = $data->getValue('revision_phid');
|
||||
|
||||
$action = $data->getValue('action');
|
||||
$verb = DifferentialAction::getActionPastTenseVerb($action);
|
||||
|
||||
$view->setTitle(
|
||||
'<strong>'.$handles[$author_phid]->renderLink().'</strong>'.
|
||||
' '.$verb.' '.
|
||||
'<strong>'.$handles[$revision_phid]->renderLink().'</strong>.');
|
||||
$view->setEpoch($data->getEpoch());
|
||||
|
||||
$action = $data->getValue('action');
|
||||
switch ($action) {
|
||||
case DifferentialAction::ACTION_CREATE:
|
||||
case DifferentialAction::ACTION_COMMIT:
|
||||
$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('feedback_content'));
|
||||
$content = str_replace("\n", '<br />', $content);
|
||||
|
||||
$view->appendChild($content);
|
||||
} else {
|
||||
$view->setOneLineStory(true);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
17
src/applications/feed/story/differential/__init__.php
Normal file
17
src/applications/feed/story/differential/__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/differential/constants/action');
|
||||
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('phutil', 'markup');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorFeedStoryDifferential.php');
|
|
@ -24,6 +24,8 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
|
|||
private $epoch;
|
||||
private $viewer;
|
||||
|
||||
private $oneLine;
|
||||
|
||||
public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
return $this;
|
||||
|
@ -44,6 +46,11 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setOneLineStory($one_line) {
|
||||
$this->oneLine = $one_line;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$head = phutil_render_tag(
|
||||
|
@ -53,29 +60,34 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
|
|||
),
|
||||
nonempty($this->title, 'Untitled Story'));
|
||||
|
||||
$body = phutil_render_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-feed-story-body',
|
||||
),
|
||||
$this->renderChildren());
|
||||
|
||||
if ($this->epoch) {
|
||||
$foot = phabricator_datetime($this->epoch, $this->viewer);
|
||||
} else {
|
||||
$foot = '';
|
||||
}
|
||||
|
||||
$foot = phutil_render_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-feed-story-foot',
|
||||
),
|
||||
$foot);
|
||||
|
||||
$body = null;
|
||||
$foot = null;
|
||||
$image_style = null;
|
||||
if ($this->image) {
|
||||
$image_style = 'background-image: url('.$this->image.')';
|
||||
|
||||
if (!$this->oneLine) {
|
||||
$body = phutil_render_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-feed-story-body',
|
||||
),
|
||||
$this->renderChildren());
|
||||
|
||||
if ($this->epoch) {
|
||||
$foot = phabricator_datetime($this->epoch, $this->viewer);
|
||||
} else {
|
||||
$foot = '';
|
||||
}
|
||||
|
||||
$foot = phutil_render_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-feed-story-foot',
|
||||
),
|
||||
$foot);
|
||||
|
||||
if ($this->image) {
|
||||
$image_style = 'background-image: url('.$this->image.')';
|
||||
}
|
||||
}
|
||||
|
||||
require_celerity_resource('phabricator-feed-css');
|
||||
|
@ -83,7 +95,9 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
|
|||
return phutil_render_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-feed-story',
|
||||
'class' => $this->oneLine
|
||||
? 'phabricator-feed-story phabricator-feed-story-one-line'
|
||||
: 'phabricator-feed-story',
|
||||
'style' => $image_style,
|
||||
),
|
||||
$head.$body.$foot);
|
||||
|
|
|
@ -6,6 +6,13 @@
|
|||
padding-left: 64px;
|
||||
margin: .5em 0 1em;
|
||||
background: 5px 2px no-repeat;
|
||||
min-height: 64px;
|
||||
}
|
||||
|
||||
.phabricator-feed-story-one-line {
|
||||
min-height: 0;
|
||||
font-size: 11px;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.phabricator-feed-story-head {
|
||||
|
|
Loading…
Reference in a new issue