public function processRequest()
 {
     require_celerity_resource('phabricator-profile-css');
     $viewer = $this->getRequest()->getUser();
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withUsernames(array($this->username))->needProfileImage(true)->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($user->getPHID()));
     $query->setLimit(100);
     $query->setViewer($viewer);
     $stories = $query->execute();
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($viewer);
     $builder->setShowHovercards(true);
     $builder->setNoDataString(pht('To begin on such a grand journey, requires but just a single step.'));
     $view = $builder->buildView();
     $feed = phutil_tag_div('phabricator-project-feed', $view->render());
     $name = $user->getUsername();
     $nav = $this->buildIconNavView($user);
     $nav->selectFilter("{$name}/feed/");
     $nav->appendChild($feed);
     return $this->buildApplicationPage($nav, array('title' => pht('Feed')));
 }
 private function renderStories(array $stories)
 {
     assert_instances_of($stories, 'PhabricatorFeedStory');
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($this->getRequest()->getUser());
     $builder->setShowHovercards(true);
     $view = $builder->buildView();
     return $view;
 }
 protected function renderResultList(array $objects, PhabricatorSavedQuery $query, array $handles)
 {
     $builder = new PhabricatorFeedBuilder($objects);
     if ($this->isPanelContext()) {
         $builder->setShowHovercards(false);
     } else {
         $builder->setShowHovercards(true);
     }
     $builder->setUser($this->requireViewer());
     $view = $builder->buildView();
     return phutil_tag_div('phabricator-feed-frame', $view);
 }
 private function renderUserFeed(PhabricatorUser $user)
 {
     $viewer = $this->getRequest()->getUser();
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($user->getPHID()));
     $query->setLimit(100);
     $query->setViewer($viewer);
     $stories = $query->execute();
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($viewer);
     $builder->setShowHovercards(true);
     $view = $builder->buildView();
     return phutil_tag_div('profile-feed', $view->render());
 }
 private function buildPeopleFeed(PhabricatorUser $user, $viewer)
 {
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($user->getPHID()));
     $query->setLimit(100);
     $query->setViewer($viewer);
     $stories = $query->execute();
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($viewer);
     $builder->setShowHovercards(true);
     $builder->setNoDataString(pht('To begin on such a grand journey, ' . 'requires but just a single step.'));
     $view = $builder->buildView();
     return $view->render();
 }
 public function processRequest()
 {
     if (!PhabricatorEnv::getEnvConfig('feed.public')) {
         return new Aphront404Response();
     }
     // TODO: Profile images won't render correctly for logged-out users.
     $request = $this->getRequest();
     $query = new PhabricatorFeedQuery();
     $stories = $query->execute();
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($request->getUser());
     $view = $builder->buildView();
     return $this->buildStandardPageResponse($view, array('title' => 'Public Feed', 'public' => true));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $story = id(new PhabricatorFeedQuery())->setViewer($viewer)->withChronologicalKeys(array($id))->executeOne();
     if (!$story) {
         return new Aphront404Response();
     }
     if ($request->getStr('text')) {
         $text = $story->renderText();
         return id(new AphrontPlainTextResponse())->setContent($text);
     }
     $feed = array($story);
     $builder = new PhabricatorFeedBuilder($feed);
     $builder->setUser($viewer);
     $feed_view = $builder->buildView();
     $title = pht('Story');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($title);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($feed_view);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $story = id(new PhabricatorFeedQuery())->setViewer($user)->withChronologicalKeys(array($this->id))->executeOne();
     if (!$story) {
         return new Aphront404Response();
     }
     if ($request->getStr('text')) {
         $text = $story->renderText();
         return id(new AphrontPlainTextResponse())->setContent($text);
     }
     $feed = array($story);
     $builder = new PhabricatorFeedBuilder($feed);
     $builder->setUser($user);
     $feed_view = $builder->buildView();
     $title = pht('Story');
     $feed_view = phutil_tag_div('phabricator-feed-frame', $feed_view);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($title);
     return $this->buildApplicationPage(array($crumbs, $feed_view), array('title' => $title));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     if ($request->isFormPost()) {
         $story = id(new PhabricatorFeedStoryPublisher())->setRelatedPHIDs(array($viewer->getPHID()))->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_STATUS)->setStoryTime(time())->setStoryAuthorPHID($viewer->getPHID())->setStoryData(array('content' => $request->getStr('status')))->publish();
         return id(new AphrontRedirectResponse())->setURI($request->getRequestURI());
     }
     $query = new PhabricatorFeedQuery();
     $stories = $query->execute();
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($request->getUser());
     $view = $builder->buildView();
     $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[] = $view;
     return $this->buildStandardPageResponse($page, array('title' => 'Feed'));
 }
 private function buildFeedView(array $phids)
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $user_phid = $user->getPHID();
     $feed_query = new PhabricatorFeedQuery();
     $feed_query->setViewer($user);
     if ($phids) {
         $feed_query->setFilterPHIDs($phids);
     }
     $pager = new AphrontCursorPagerView();
     $pager->readFromRequest($request);
     $pager->setPageSize(200);
     $feed = $feed_query->executeWithCursorPager($pager);
     $builder = new PhabricatorFeedBuilder($feed);
     $builder->setUser($user);
     $feed_view = $builder->buildView();
     return '<div style="padding: 1em 3em;">' . '<div style="margin: 0 1em;">' . '<h1 style="font-size: 18px; ' . 'border-bottom: 1px solid #aaaaaa; ' . 'padding: 0;">Feed</h1>' . '</div>' . $feed_view->render() . '<div class="phabricator-feed-frame">' . $pager->render() . '</div>' . '</div>';
 }
 private function buildFeedView(array $phids)
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $user_phid = $user->getPHID();
     $feed_query = new PhabricatorFeedQuery();
     if ($phids) {
         $feed_query->setFilterPHIDs($phids);
     }
     // TODO: All this limit stuff should probably be consolidated into the
     // feed query?
     $old_link = null;
     $new_link = null;
     $feed_query->setAfter($request->getStr('after'));
     $feed_query->setBefore($request->getStr('before'));
     $limit = 500;
     // Grab one more story than we intend to display so we can figure out
     // if we need to render an "Older Posts" link or not (with reasonable
     // accuracy, at least).
     $feed_query->setLimit($limit + 1);
     $feed = $feed_query->execute();
     $extra_row = count($feed) == $limit + 1;
     $have_new = $request->getStr('before') || $request->getStr('after') && $extra_row;
     $have_old = $request->getStr('after') || $request->getStr('before') && $extra_row || !$request->getStr('before') && !$request->getStr('after') && $extra_row;
     $feed = array_slice($feed, 0, $limit, $preserve_keys = true);
     if ($have_old) {
         $old_link = phutil_render_tag('a', array('href' => '?before=' . end($feed)->getChronologicalKey(), 'class' => 'phabricator-feed-older-link'), "Older Stories »");
     }
     if ($have_new) {
         $new_link = phutil_render_tag('a', array('href' => '?after=' . reset($feed)->getChronologicalKey(), 'class' => 'phabricator-feed-newer-link'), "« Newer Stories");
     }
     $builder = new PhabricatorFeedBuilder($feed);
     $builder->setUser($user);
     $feed_view = $builder->buildView();
     return '<div style="padding: 1em 3em;">' . '<div style="margin: 0 1em;">' . '<h1 style="font-size: 18px; ' . 'border-bottom: 1px solid #aaaaaa; ' . 'padding: 0;">Feed</h1>' . '</div>' . $feed_view->render() . '<div class="phabricator-feed-frame">' . $new_link . $old_link . '</div>' . '</div>';
 }
 private function renderStories(array $stories)
 {
     assert_instances_of($stories, 'PhabricatorFeedStory');
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($this->getRequest()->getUser());
     $view = $builder->buildView();
     return '<div class="phabricator-profile-info-group">' . '<h1 class="phabricator-profile-info-header">Activity Feed</h1>' . '<div class="phabricator-profile-info-pane">' . $view->render() . '</div>' . '</div>';
 }
 private function renderUserFeed(PhabricatorUser $user)
 {
     $viewer = $this->getRequest()->getUser();
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($user->getPHID()));
     $query->setLimit(100);
     $query->setViewer($viewer);
     $stories = $query->execute();
     $builder = new PhabricatorFeedBuilder($stories);
     $builder->setUser($viewer);
     $view = $builder->buildView();
     return '<div class="phabricator-profile-info-group">
     <h1 class="phabricator-profile-info-header">Activity Feed</h1>
     <div class="phabricator-profile-info-pane">
       ' . $view->render() . '
     </div>
   </div>';
 }