1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +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:
epriestley 2011-07-09 15:44:49 -07:00
parent 4452239d61
commit f55c082e65
17 changed files with 255 additions and 26 deletions

View file

@ -1026,7 +1026,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-feed-css' => 'phabricator-feed-css' =>
array( array(
'uri' => '/res/617811ab/rsrc/css/application/feed/feed.css', 'uri' => '/res/32e5879b/rsrc/css/application/feed/feed.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -338,14 +338,17 @@ phutil_register_library_map(array(
'PhabricatorEmailLoginController' => 'applications/auth/controller/email', 'PhabricatorEmailLoginController' => 'applications/auth/controller/email',
'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken', 'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken',
'PhabricatorEnv' => 'infrastructure/env', 'PhabricatorEnv' => 'infrastructure/env',
'PhabricatorFeedConstants' => 'applications/feed/constants/base',
'PhabricatorFeedController' => 'applications/feed/controller/base', 'PhabricatorFeedController' => 'applications/feed/controller/base',
'PhabricatorFeedDAO' => 'applications/feed/storage/base', 'PhabricatorFeedDAO' => 'applications/feed/storage/base',
'PhabricatorFeedQuery' => 'applications/feed/query', 'PhabricatorFeedQuery' => 'applications/feed/query',
'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',
'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',
'PhabricatorFeedStoryTypeConstants' => 'applications/feed/constants/story',
'PhabricatorFeedStoryUnknown' => 'applications/feed/story/unknown', 'PhabricatorFeedStoryUnknown' => 'applications/feed/story/unknown',
'PhabricatorFeedStoryView' => 'applications/feed/view/story', 'PhabricatorFeedStoryView' => 'applications/feed/view/story',
'PhabricatorFeedStreamController' => 'applications/feed/controller/stream', 'PhabricatorFeedStreamController' => 'applications/feed/controller/stream',
@ -857,8 +860,10 @@ phutil_register_library_map(array(
'PhabricatorFeedController' => 'PhabricatorController', 'PhabricatorFeedController' => 'PhabricatorController',
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO', 'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants',
'PhabricatorFeedStoryUnknown' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryUnknown' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryView' => 'PhabricatorFeedView', 'PhabricatorFeedStoryView' => 'PhabricatorFeedView',
'PhabricatorFeedStreamController' => 'PhabricatorFeedController', 'PhabricatorFeedStreamController' => 'PhabricatorFeedController',

View file

@ -411,6 +411,20 @@ class DifferentialCommentEditor {
id(new PhabricatorTimelineEvent('difx', $event_data)) id(new PhabricatorTimelineEvent('difx', $event_data))
->recordEvent(); ->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? // TODO: Move to a daemon?
PhabricatorSearchDifferentialIndexer::indexRevision($revision); PhabricatorSearchDifferentialIndexer::indexRevision($revision);

View file

@ -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/changeset');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); 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/herald/storage/transcript/base');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/search/index/indexer/differential'); phutil_require_module('phabricator', 'applications/search/index/indexer/differential');

View file

@ -375,6 +375,18 @@ class DifferentialRevisionEditor {
id(new PhabricatorTimelineEvent('difx', $event_data)) id(new PhabricatorTimelineEvent('difx', $event_data))
->recordEvent(); ->recordEvent();
id(new PhabricatorFeedStoryPublisher())
->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_DIFFERENTIAL)
->setStoryData($event_data)
->setStoryTime(time())
->setStoryAuthorPHID($revision->getAuthorPHID())
->setRelatedPHIDs(
array(
$revision->getPHID(),
$revision->getAuthorPHID(),
))
->publish();
// TODO // TODO
// $revision->saveTransaction(); // $revision->saveTransaction();

View file

@ -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/mail/newdiff');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/revision'); 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/adapter/differential');
phutil_require_module('phabricator', 'applications/herald/engine/engine'); phutil_require_module('phabricator', 'applications/herald/engine/engine');
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base'); phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');

View file

@ -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 {
}

View file

@ -0,0 +1,10 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_source('PhabricatorFeedConstants.php');

View file

@ -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';
}

View 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');

View file

@ -26,7 +26,7 @@ final class PhabricatorFeedStreamController extends PhabricatorFeedController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
$story = id(new PhabricatorFeedStoryPublisher()) $story = id(new PhabricatorFeedStoryPublisher())
->setRelatedPHIDs(array($viewer->getPHID())) ->setRelatedPHIDs(array($viewer->getPHID()))
->setStoryType('PhabricatorFeedStoryStatus') ->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_STATUS)
->setStoryTime(time()) ->setStoryTime(time())
->setStoryAuthorPHID($viewer->getPHID()) ->setStoryAuthorPHID($viewer->getPHID())
->setStoryData( ->setStoryData(

View file

@ -7,6 +7,7 @@
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/controller/base'); phutil_require_module('phabricator', 'applications/feed/controller/base');
phutil_require_module('phabricator', 'applications/feed/publisher'); phutil_require_module('phabricator', 'applications/feed/publisher');
phutil_require_module('phabricator', 'applications/feed/query'); phutil_require_module('phabricator', 'applications/feed/query');

View file

@ -71,7 +71,7 @@ final class PhabricatorFeedStoryPublisher {
$sql = array(); $sql = array();
$conn = $ref->establishConnection('w'); $conn = $ref->establishConnection('w');
foreach ($this->relatedPHIDs as $phid) { foreach (array_unique($this->relatedPHIDs) as $phid) {
$sql[] = qsprintf( $sql[] = qsprintf(
$conn, $conn,
'(%s, %s)', '(%s, %s)',

View file

@ -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;
}
}

View 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');

View file

@ -24,6 +24,8 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
private $epoch; private $epoch;
private $viewer; private $viewer;
private $oneLine;
public function setViewer(PhabricatorUser $viewer) { public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer; $this->viewer = $viewer;
return $this; return $this;
@ -44,6 +46,11 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
return $this; return $this;
} }
public function setOneLineStory($one_line) {
$this->oneLine = $one_line;
return $this;
}
public function render() { public function render() {
$head = phutil_render_tag( $head = phutil_render_tag(
@ -53,6 +60,11 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
), ),
nonempty($this->title, 'Untitled Story')); nonempty($this->title, 'Untitled Story'));
$body = null;
$foot = null;
$image_style = null;
if (!$this->oneLine) {
$body = phutil_render_tag( $body = phutil_render_tag(
'div', 'div',
array( array(
@ -73,17 +85,19 @@ class PhabricatorFeedStoryView extends PhabricatorFeedView {
), ),
$foot); $foot);
$image_style = null;
if ($this->image) { if ($this->image) {
$image_style = 'background-image: url('.$this->image.')'; $image_style = 'background-image: url('.$this->image.')';
} }
}
require_celerity_resource('phabricator-feed-css'); require_celerity_resource('phabricator-feed-css');
return phutil_render_tag( return phutil_render_tag(
'div', 'div',
array( array(
'class' => 'phabricator-feed-story', 'class' => $this->oneLine
? 'phabricator-feed-story phabricator-feed-story-one-line'
: 'phabricator-feed-story',
'style' => $image_style, 'style' => $image_style,
), ),
$head.$body.$foot); $head.$body.$foot);

View file

@ -6,6 +6,13 @@
padding-left: 64px; padding-left: 64px;
margin: .5em 0 1em; margin: .5em 0 1em;
background: 5px 2px no-repeat; 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 { .phabricator-feed-story-head {