1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Improve feed stories with "style", and build basic status update stories.

Summary: Straightfoward iteration on feed.
Test Plan:
https://secure.phabricator.com/file/view/PHID-FILE-d07077119dc834e76618/
Reviewed By: codeblock
Reviewers: jungejason, aran, tuomaspelkonen, codeblock
CC: aran, codeblock, epriestley
Differential Revision: 631
This commit is contained in:
epriestley 2011-07-09 13:28:09 -07:00
parent f8c541b819
commit d665268074
14 changed files with 358 additions and 63 deletions

View file

@ -293,6 +293,17 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/javelin/lib/behavior.js', 'disk' => '/rsrc/js/javelin/lib/behavior.js',
), ),
0 =>
array(
'uri' => '/res/1da00bfe/rsrc/js/javelin/lib/__tests__/URI.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-uri',
1 => 'javelin-php-serializer',
),
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
),
'javelin-behavior-aphront-basic-tokenizer' => 'javelin-behavior-aphront-basic-tokenizer' =>
array( array(
'uri' => '/res/5e183bd5/rsrc/js/application/core/behavior-tokenizer.js', 'uri' => '/res/5e183bd5/rsrc/js/application/core/behavior-tokenizer.js',
@ -476,17 +487,6 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/application/differential/behavior-show-all-comments.js', 'disk' => '/rsrc/js/application/differential/behavior-show-all-comments.js',
), ),
0 =>
array(
'uri' => '/res/1da00bfe/rsrc/js/javelin/lib/__tests__/URI.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-uri',
1 => 'javelin-php-serializer',
),
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
),
'javelin-behavior-differential-show-more' => 'javelin-behavior-differential-show-more' =>
array( array(
'uri' => '/res/a766c717/rsrc/js/application/differential/behavior-show-more.js', 'uri' => '/res/a766c717/rsrc/js/application/differential/behavior-show-more.js',
@ -1024,6 +1024,15 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/application/core/DragAndDropFileUpload.js', 'disk' => '/rsrc/js/application/core/DragAndDropFileUpload.js',
), ),
'phabricator-feed-css' =>
array(
'uri' => '/res/80952af2/rsrc/css/application/feed/feed.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/feed/feed.css',
),
'phabricator-keyboard-shortcut' => 'phabricator-keyboard-shortcut' =>
array( array(
'uri' => '/res/beed38cd/rsrc/js/application/core/KeyboardShortcut.js', 'uri' => '/res/beed38cd/rsrc/js/application/core/KeyboardShortcut.js',
@ -1071,7 +1080,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-remarkup-css' => 'phabricator-remarkup-css' =>
array( array(
'uri' => '/res/a6acb5f0/rsrc/css/core/remarkup.css', 'uri' => '/res/e0c44a00/rsrc/css/core/remarkup.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -1101,7 +1110,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-slowvote-css' => 'phabricator-slowvote-css' =>
array( array(
'uri' => '/res/0a95e217/rsrc/css/application/slowvote/slowvote.css', 'uri' => '/res/94d20443/rsrc/css/application/slowvote/slowvote.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -1183,6 +1192,30 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/307df223/javelin.pkg.js', 'uri' => '/res/pkg/307df223/javelin.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'8e9024dc' =>
array (
'name' => 'core.pkg.css',
'symbols' =>
array (
0 => 'phabricator-core-css',
1 => 'phabricator-core-buttons-css',
2 => 'phabricator-standard-page-view',
3 => 'aphront-dialog-view-css',
4 => 'aphront-form-view-css',
5 => 'aphront-panel-view-css',
6 => 'aphront-side-nav-view-css',
7 => 'aphront-table-view-css',
8 => 'aphront-crumbs-view-css',
9 => 'aphront-tokenizer-control-css',
10 => 'aphront-typeahead-control-css',
11 => 'aphront-list-filter-view-css',
12 => 'phabricator-directory-css',
13 => 'phabricator-remarkup-css',
14 => 'syntax-highlighting-css',
),
'uri' => '/res/pkg/8e9024dc/core.pkg.css',
'type' => 'css',
),
'95b66c1a' => '95b66c1a' =>
array ( array (
'name' => 'differential.pkg.css', 'name' => 'differential.pkg.css',
@ -1230,42 +1263,18 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/da416e1c/differential.pkg.js', 'uri' => '/res/pkg/da416e1c/differential.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'fd3dc470' =>
array (
'name' => 'core.pkg.css',
'symbols' =>
array (
0 => 'phabricator-core-css',
1 => 'phabricator-core-buttons-css',
2 => 'phabricator-standard-page-view',
3 => 'aphront-dialog-view-css',
4 => 'aphront-form-view-css',
5 => 'aphront-panel-view-css',
6 => 'aphront-side-nav-view-css',
7 => 'aphront-table-view-css',
8 => 'aphront-crumbs-view-css',
9 => 'aphront-tokenizer-control-css',
10 => 'aphront-typeahead-control-css',
11 => 'aphront-list-filter-view-css',
12 => 'phabricator-directory-css',
13 => 'phabricator-remarkup-css',
14 => 'syntax-highlighting-css',
),
'uri' => '/res/pkg/fd3dc470/core.pkg.css',
'type' => 'css',
),
), ),
'reverse' => 'reverse' =>
array ( array (
'aphront-crumbs-view-css' => 'fd3dc470', 'aphront-crumbs-view-css' => '8e9024dc',
'aphront-dialog-view-css' => 'fd3dc470', 'aphront-dialog-view-css' => '8e9024dc',
'aphront-form-view-css' => 'fd3dc470', 'aphront-form-view-css' => '8e9024dc',
'aphront-list-filter-view-css' => 'fd3dc470', 'aphront-list-filter-view-css' => '8e9024dc',
'aphront-panel-view-css' => 'fd3dc470', 'aphront-panel-view-css' => '8e9024dc',
'aphront-side-nav-view-css' => 'fd3dc470', 'aphront-side-nav-view-css' => '8e9024dc',
'aphront-table-view-css' => 'fd3dc470', 'aphront-table-view-css' => '8e9024dc',
'aphront-tokenizer-control-css' => 'fd3dc470', 'aphront-tokenizer-control-css' => '8e9024dc',
'aphront-typeahead-control-css' => 'fd3dc470', 'aphront-typeahead-control-css' => '8e9024dc',
'differential-changeset-view-css' => '95b66c1a', 'differential-changeset-view-css' => '95b66c1a',
'differential-core-view-css' => '95b66c1a', 'differential-core-view-css' => '95b66c1a',
'differential-revision-add-comment-css' => '95b66c1a', 'differential-revision-add-comment-css' => '95b66c1a',
@ -1302,13 +1311,13 @@ celerity_register_resource_map(array(
'javelin-util' => '307df223', 'javelin-util' => '307df223',
'javelin-vector' => '307df223', 'javelin-vector' => '307df223',
'javelin-workflow' => 'd0713563', 'javelin-workflow' => 'd0713563',
'phabricator-core-buttons-css' => 'fd3dc470', 'phabricator-core-buttons-css' => '8e9024dc',
'phabricator-core-css' => 'fd3dc470', 'phabricator-core-css' => '8e9024dc',
'phabricator-directory-css' => 'fd3dc470', 'phabricator-directory-css' => '8e9024dc',
'phabricator-keyboard-shortcut' => 'd0713563', 'phabricator-keyboard-shortcut' => 'd0713563',
'phabricator-keyboard-shortcut-manager' => 'd0713563', 'phabricator-keyboard-shortcut-manager' => 'd0713563',
'phabricator-remarkup-css' => 'fd3dc470', 'phabricator-remarkup-css' => '8e9024dc',
'phabricator-standard-page-view' => 'fd3dc470', 'phabricator-standard-page-view' => '8e9024dc',
'syntax-highlighting-css' => 'fd3dc470', 'syntax-highlighting-css' => '8e9024dc',
), ),
)); ));

View file

@ -345,6 +345,7 @@ phutil_register_library_map(array(
'PhabricatorFeedStoryData' => 'applications/feed/storage/story', 'PhabricatorFeedStoryData' => 'applications/feed/storage/story',
'PhabricatorFeedStoryPublisher' => 'applications/feed/publisher', 'PhabricatorFeedStoryPublisher' => 'applications/feed/publisher',
'PhabricatorFeedStoryReference' => 'applications/feed/storage/storyreference', 'PhabricatorFeedStoryReference' => 'applications/feed/storage/storyreference',
'PhabricatorFeedStoryStatus' => 'applications/feed/story/status',
'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',
@ -426,7 +427,6 @@ phutil_register_library_map(array(
'PhabricatorOwnersPackage' => 'applications/owners/storage/package', 'PhabricatorOwnersPackage' => 'applications/owners/storage/package',
'PhabricatorOwnersPath' => 'applications/owners/storage/path', 'PhabricatorOwnersPath' => 'applications/owners/storage/path',
'PhabricatorPHID' => 'applications/phid/storage/phid', 'PhabricatorPHID' => 'applications/phid/storage/phid',
'PhabricatorPHIDAllocateController' => 'applications/phid/controller/allocate',
'PhabricatorPHIDConstants' => 'applications/phid/constants', 'PhabricatorPHIDConstants' => 'applications/phid/constants',
'PhabricatorPHIDController' => 'applications/phid/controller/base', 'PhabricatorPHIDController' => 'applications/phid/controller/base',
'PhabricatorPHIDDAO' => 'applications/phid/storage/base', 'PhabricatorPHIDDAO' => 'applications/phid/storage/base',
@ -858,6 +858,7 @@ phutil_register_library_map(array(
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO', 'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryUnknown' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryUnknown' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryView' => 'PhabricatorFeedView', 'PhabricatorFeedStoryView' => 'PhabricatorFeedView',
'PhabricatorFeedStreamController' => 'PhabricatorFeedController', 'PhabricatorFeedStreamController' => 'PhabricatorFeedController',
@ -927,7 +928,6 @@ phutil_register_library_map(array(
'PhabricatorOwnersPackage' => 'PhabricatorOwnersDAO', 'PhabricatorOwnersPackage' => 'PhabricatorOwnersDAO',
'PhabricatorOwnersPath' => 'PhabricatorOwnersDAO', 'PhabricatorOwnersPath' => 'PhabricatorOwnersDAO',
'PhabricatorPHID' => 'PhabricatorPHIDDAO', 'PhabricatorPHID' => 'PhabricatorPHIDDAO',
'PhabricatorPHIDAllocateController' => 'PhabricatorPHIDController',
'PhabricatorPHIDController' => 'PhabricatorController', 'PhabricatorPHIDController' => 'PhabricatorController',
'PhabricatorPHIDDAO' => 'PhabricatorLiskDAO', 'PhabricatorPHIDDAO' => 'PhabricatorLiskDAO',
'PhabricatorPHIDListController' => 'PhabricatorPHIDController', 'PhabricatorPHIDListController' => 'PhabricatorPHIDController',

View file

@ -20,16 +20,73 @@ final class PhabricatorFeedStreamController extends PhabricatorFeedController {
public function processRequest() { public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if ($request->isFormPost()) {
$story = id(new PhabricatorFeedStoryPublisher())
->setRelatedPHIDs(array($viewer->getPHID()))
->setStoryType('PhabricatorFeedStoryStatus')
->setStoryTime(time())
->setStoryAuthorPHID($viewer->getPHID())
->setStoryData(
array(
'content' => $request->getStr('status')
))
->publish();
return id(new AphrontRedirectResponse())->setURI(
$request->getRequestURI());
}
$query = new PhabricatorFeedQuery(); $query = new PhabricatorFeedQuery();
$stories = $query->execute(); $stories = $query->execute();
$views = array(); $handles = array();
foreach ($stories as $story) { $objects = array();
$views[] = $story->renderView(); if ($stories) {
$handle_phids = array_mergev(mpull($stories, 'getRequiredHandlePHIDs'));
$object_phids = array_mergev(mpull($stories, 'getRequiredObjectPHIDs'));
$handles = id(new PhabricatorObjectHandleData($handle_phids))
->loadHandles();
$objects = id(new PhabricatorObjectHandleData($object_phids))
->loadObjects();
} }
$views = array();
foreach ($stories as $story) {
$story->setHandles($handles);
$story->setObjects($objects);
$view = $story->renderView();
$view->setViewer($viewer);
$views[] = $view->render();
}
$post_form = id(new AphrontFormView())
->setUser($viewer)
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Pithy Wit')
->setName('status'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Publish'));
$post = new AphrontPanelView();
$post->setWidth(AphrontPanelView::WIDTH_FORM);
$post->setHeader('High Horse Soapbox');
$post->appendChild($post_form);
$page = array();
$page[] = $post;
$page[] = $views;
return $this->buildStandardPageResponse( return $this->buildStandardPageResponse(
$views, $page,
array( array(
'title' => 'Feed', 'title' => 'Feed',
)); ));

View file

@ -6,8 +6,17 @@
phutil_require_module('phabricator', 'aphront/response/redirect');
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/query'); phutil_require_module('phabricator', 'applications/feed/query');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorFeedStreamController.php'); phutil_require_source('PhabricatorFeedStreamController.php');

View file

@ -39,4 +39,12 @@ class PhabricatorFeedStoryData extends PhabricatorFeedDAO {
PhabricatorPHIDConstants::PHID_TYPE_STRY); PhabricatorPHIDConstants::PHID_TYPE_STRY);
} }
public function getEpoch() {
return $this->chronologicalKey >> 32;
}
public function getValue($key, $default = null) {
return idx($this->storyData, $key, $default);
}
} }

View file

@ -10,5 +10,7 @@ phutil_require_module('phabricator', 'applications/feed/storage/base');
phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/phid/storage/phid');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorFeedStoryData.php'); phutil_require_source('PhabricatorFeedStoryData.php');

View file

@ -20,10 +20,43 @@ abstract class PhabricatorFeedStory {
private $data; private $data;
private $handles;
private $objects;
final public function __construct(PhabricatorFeedStoryData $data) { final public function __construct(PhabricatorFeedStoryData $data) {
$this->data = $data; $this->data = $data;
} }
abstract public function renderView(); abstract public function renderView();
public function getRequiredHandlePHIDs() {
return array();
}
public function getRequiredObjectPHIDs() {
return array();
}
final public function setHandles(array $handles) {
$this->handles = $handles;
return $this;
}
final public function setObjects(array $objects) {
$this->objects = $objects;
return $this;
}
final protected function getHandles() {
return $this->handles;
}
final protected function getObjects() {
return $this->objects;
}
final protected function getStoryData() {
return $this->data;
}
} }

View file

@ -0,0 +1,62 @@
<?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 PhabricatorFeedStoryStatus extends PhabricatorFeedStory {
public function getRequiredHandlePHIDs() {
return array(
$this->getStoryData()->getAuthorPHID(),
);
}
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();
$view->setTitle(
'<strong>'.$handles[$author_phid]->renderLink().'</strong>');
$view->setEpoch($data->getEpoch());
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);
return $view;
}
}

View file

@ -0,0 +1,16 @@
<?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('phutil', 'markup');
phutil_require_source('PhabricatorFeedStoryStatus.php');

View file

@ -19,7 +19,19 @@
class PhabricatorFeedStoryUnknown extends PhabricatorFeedStory { class PhabricatorFeedStoryUnknown extends PhabricatorFeedStory {
public function renderView() { public function renderView() {
return new PhabricatorFeedStoryView(); $data = $this->getStoryData();
$view = new PhabricatorFeedStoryView();
$view->setTitle('Unknown Story');
$view->setEpoch($data->getEpoch());
$view->appendChild(
'This is an unrenderable feed story of type '.
'"'.phutil_escape_html($data->getStoryType()).'".');
return $view;
} }
} }

View file

@ -9,5 +9,7 @@
phutil_require_module('phabricator', 'applications/feed/story/base'); phutil_require_module('phabricator', 'applications/feed/story/base');
phutil_require_module('phabricator', 'applications/feed/view/story'); phutil_require_module('phabricator', 'applications/feed/view/story');
phutil_require_module('phutil', 'markup');
phutil_require_source('PhabricatorFeedStoryUnknown.php'); phutil_require_source('PhabricatorFeedStoryUnknown.php');

View file

@ -18,15 +18,75 @@
class PhabricatorFeedStoryView extends PhabricatorFeedView { class PhabricatorFeedStoryView extends PhabricatorFeedView {
private $title;
private $image;
private $phid;
private $epoch;
private $viewer;
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function setEpoch($epoch) {
$this->epoch = $epoch;
return $this;
}
public function setImage($image) {
$this->image = $image;
return $this;
}
public function render() { public function render() {
$head = phutil_render_tag(
'div',
array(
'class' => 'phabricator-feed-story-head',
),
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);
$image_style = null;
if ($this->image) {
$image_style = 'background-image: url('.$this->image.')';
}
require_celerity_resource('phabricator-feed-css');
return phutil_render_tag( return phutil_render_tag(
'div', 'div',
array( array(
'style' => 'border: 1px dashed black; '. 'class' => 'phabricator-feed-story',
'padding: 1em; margin: 1em; '. 'style' => $image_style,
'background: #ffeedd;',
), ),
'This is a feed story!'); $head.$body.$foot);
} }
} }

View file

@ -7,8 +7,11 @@
phutil_require_module('phabricator', 'applications/feed/view/base'); phutil_require_module('phabricator', 'applications/feed/view/base');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorFeedStoryView.php'); phutil_require_source('PhabricatorFeedStoryView.php');

View file

@ -0,0 +1,22 @@
/**
* @provides phabricator-feed-css
*/
.phabricator-feed-story {
padding-left: 64px;
margin: .5em 0 1em;
background: 5px 2px no-repeat;
}
.phabricator-feed-story-head {
}
.phabricator-feed-story-body {
padding: .5em 0;
color: #444444;
}
.phabricator-feed-story-foot {
color: #888888;
font-size: 11px;
}