1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Rough version of DiffusionHomeController

Summary: My strategy here is to synthesize Diffusion + Confusion (jwilson's
git support for Diffusion) + Repository/Commit stuff into Phabricator and
kill all birds with one stone. This probably involves the least total work
since we have to do this port step anyway and a lot of the Phabricator
primitives are in better shape than the trunk primitives.

Test Plan: Looked at it in my sandbox, which has some parsed commits.

Reviewers: jwilson, aran, jungejason

CC:

Differential Revision: 57
This commit is contained in:
epriestley 2011-03-07 15:13:36 -08:00
parent 57495c4287
commit 7c413fc580
6 changed files with 170 additions and 0 deletions

View file

@ -142,6 +142,8 @@ phutil_register_library_map(array(
'DifferentialRevisionViewController' => 'applications/differential/controller/revisionview',
'DifferentialSubscribeController' => 'applications/differential/controller/subscribe',
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
'DiffusionController' => 'applications/diffusion/controller/base',
'DiffusionHomeController' => 'applications/diffusion/controller/home',
'Javelin' => 'infrastructure/javelin/api',
'LiskDAO' => 'storage/lisk/dao',
'ManiphestController' => 'applications/maniphest/controller/base',
@ -420,6 +422,8 @@ phutil_register_library_map(array(
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
'DifferentialRevisionViewController' => 'DifferentialController',
'DifferentialSubscribeController' => 'DifferentialController',
'DiffusionController' => 'PhabricatorController',
'DiffusionHomeController' => 'DiffusionController',
'ManiphestController' => 'PhabricatorController',
'ManiphestDAO' => 'PhabricatorLiskDAO',
'ManiphestTask' => 'ManiphestDAO',

View file

@ -183,6 +183,10 @@ class AphrontDefaultApplicationConfiguration
=> 'PhabricatorProjectAffiliationEditController',
),
'/diffusion/' => array(
'$' => 'DiffusionHomeController',
),
);
}

View file

@ -0,0 +1,35 @@
<?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 DiffusionController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
$page->setApplicationName('Diffusion');
$page->setBaseURI('/diffusion/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x89\x88");
$page->appendChild($view);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
}

View file

@ -0,0 +1,15 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/webpage');
phutil_require_module('phabricator', 'applications/base/controller/base');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionController.php');

View file

@ -0,0 +1,91 @@
<?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 DiffusionHomeController extends DiffusionController {
public function processRequest() {
// TODO: Restore "shortcuts" feature.
$repositories = id(new PhabricatorRepository())->loadAll();
$commit = new PhabricatorRepositoryCommit();
$conn_r = $commit->establishConnection('r');
// TODO: Both these queries are basically bogus and have total trash for
// query plans, and don't return the right results. Build a cache instead.
// These are just pulling data with approximately the right look to it.
$commits = $commit->loadAllWhere(
'1 = 1 GROUP BY repositoryPHID');
$commits = mpull($commits, null, 'getRepositoryPHID');
$commit_counts = queryfx_all(
$conn_r,
'SELECT repositoryPHID, count(*) N FROM %T
GROUP BY repositoryPHID',
$commit->getTableName());
$commit_counts = ipull($commit_counts, 'N', 'repositoryPHID');
$rows = array();
foreach ($repositories as $repository) {
$phid = $repository->getPHID();
$commit = idx($commits, $phid);
$rows[] = array(
phutil_render_tag(
'a',
array(
'href' => '#', // TODO: Link
),
phutil_escape_html($repository->getName())),
$repository->getVersionControlSystem(),
idx($commit_counts, $phid, 0),
$commit
? $commit->getCommitIdentifier()
: null, // TODO: Link/format
$commit
? phabricator_format_timestamp($commit->getEpoch())
: null,
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Repository',
'VCS',
'Size',
'Last',
'Committed',
));
$table->setColumnClasses(
array(
'wide',
));
$panel = new AphrontPanelView();
$panel->setHeader('Browse Repositories');
$panel->appendChild($table);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Diffusion',
));
}
}

View file

@ -0,0 +1,21 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
phutil_require_module('phabricator', 'applications/repository/storage/commit');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionHomeController.php');