mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 00:10:57 +01:00
Provide a public view of feed
Summary: Depends on D628. Provides a config option so you can set up a public feed, which you can iframe. This needs some work but sort of works. Test Plan: Loaded the public feed as a logged-out user. Reviewed By: codeblock Reviewers: jungejason, tuomaspelkonen, aran, codeblock CC: aran, codeblock Differential Revision: 635
This commit is contained in:
parent
c33eecf438
commit
a20e46b061
6 changed files with 110 additions and 0 deletions
|
@ -416,6 +416,15 @@ return array(
|
|||
'gcdaemon.ttl.differential-parse-cache' => 14 * (24 * 60 * 60),
|
||||
|
||||
|
||||
// -- Feed ------------------------------------------------------------------ //
|
||||
|
||||
// If you set this to true, you can embed Phabricator activity feeds in other
|
||||
// pages using iframes. These feeds are completely public, and a login is not
|
||||
// required to view them! This is intended for things like open source
|
||||
// projects that want to expose an activity feed on the project homepage.
|
||||
'feed.public' => false,
|
||||
|
||||
|
||||
// -- Customization --------------------------------------------------------- //
|
||||
|
||||
// Paths to additional phutil libraries to load.
|
||||
|
|
|
@ -341,6 +341,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFeedConstants' => 'applications/feed/constants/base',
|
||||
'PhabricatorFeedController' => 'applications/feed/controller/base',
|
||||
'PhabricatorFeedDAO' => 'applications/feed/storage/base',
|
||||
'PhabricatorFeedPublicStreamController' => 'applications/feed/controller/publicstream',
|
||||
'PhabricatorFeedQuery' => 'applications/feed/query',
|
||||
'PhabricatorFeedStory' => 'applications/feed/story/base',
|
||||
'PhabricatorFeedStoryData' => 'applications/feed/storage/story',
|
||||
|
@ -863,6 +864,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorEmailTokenController' => 'PhabricatorAuthController',
|
||||
'PhabricatorFeedController' => 'PhabricatorController',
|
||||
'PhabricatorFeedDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController',
|
||||
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
|
||||
'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory',
|
||||
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
|
||||
|
|
|
@ -332,6 +332,7 @@ class AphrontDefaultApplicationConfiguration
|
|||
|
||||
'/feed/' => array(
|
||||
'$' => 'PhabricatorFeedStreamController',
|
||||
'public/$' => 'PhabricatorFeedPublicStreamController',
|
||||
),
|
||||
|
||||
'/V(?P<id>\d+)$' => 'PhabricatorSlowvotePollController',
|
||||
|
|
|
@ -28,6 +28,13 @@ abstract class PhabricatorFeedController extends PhabricatorController {
|
|||
$page->appendChild($view);
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
|
||||
if (!empty($data['public'])) {
|
||||
$page->setFrameable(true);
|
||||
$page->setShowChrome(false);
|
||||
$response->setFrameable(true);
|
||||
}
|
||||
|
||||
return $response->setContent($page->render());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<?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 PhabricatorFeedPublicStreamController
|
||||
extends PhabricatorFeedController {
|
||||
|
||||
public function shouldRequireLogin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$handles = array();
|
||||
$objects = array();
|
||||
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();
|
||||
}
|
||||
|
||||
// TODO: We need this for timezones but should develop some more general
|
||||
// solution for logged-out pages.
|
||||
$dummy_user = new PhabricatorUser();
|
||||
|
||||
$views = array();
|
||||
foreach ($stories as $story) {
|
||||
$story->setHandles($handles);
|
||||
$story->setObjects($objects);
|
||||
|
||||
$view = $story->renderView();
|
||||
$view->setViewer($dummy_user);
|
||||
|
||||
$views[] = $view->render();
|
||||
}
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$views,
|
||||
array(
|
||||
'title' => 'Public Feed',
|
||||
'public' => true,
|
||||
));
|
||||
}
|
||||
}
|
19
src/applications/feed/controller/publicstream/__init__.php
Normal file
19
src/applications/feed/controller/publicstream/__init__.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'applications/feed/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/feed/query');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorFeedPublicStreamController.php');
|
Loading…
Reference in a new issue