mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
DifferentialChangesetView
This commit is contained in:
parent
e85ecd03de
commit
a3df19976f
13 changed files with 1613 additions and 4 deletions
|
@ -58,6 +58,8 @@ phutil_register_library_map(array(
|
|||
'DifferentialChangeType' => 'applications/differential/constants/changetype',
|
||||
'DifferentialChangeset' => 'applications/differential/storage/changeset',
|
||||
'DifferentialChangesetDetailView' => 'applications/differential/view/changesetdetailview',
|
||||
'DifferentialChangesetParser' => 'applications/differential/parser/changeset',
|
||||
'DifferentialChangesetViewController' => 'applications/differential/controller/changesetview',
|
||||
'DifferentialController' => 'applications/differential/controller/base',
|
||||
'DifferentialDAO' => 'applications/differential/storage/base',
|
||||
'DifferentialDiff' => 'applications/differential/storage/diff',
|
||||
|
@ -95,6 +97,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFileDAO' => 'applications/files/storage/base',
|
||||
'PhabricatorFileListController' => 'applications/files/controller/list',
|
||||
'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob',
|
||||
'PhabricatorFileURI' => 'applications/files/uri',
|
||||
'PhabricatorFileUploadController' => 'applications/files/controller/upload',
|
||||
'PhabricatorFileViewController' => 'applications/files/controller/view',
|
||||
'PhabricatorLiskDAO' => 'applications/base/storage/lisk',
|
||||
|
@ -165,6 +168,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
||||
'DifferentialChangeset' => 'DifferentialDAO',
|
||||
'DifferentialChangesetDetailView' => 'AphrontView',
|
||||
'DifferentialChangesetViewController' => 'DifferentialController',
|
||||
'DifferentialController' => 'PhabricatorController',
|
||||
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
||||
'DifferentialDiff' => 'DifferentialDAO',
|
||||
|
|
|
@ -77,7 +77,8 @@ class AphrontDefaultApplicationConfiguration
|
|||
'/api/(?<method>[^/]+)$' => 'PhabricatorConduitAPIController',
|
||||
|
||||
'/differential/' => array(
|
||||
'diff/(?<id>\d+)/$' => 'DifferentialDiffViewController',
|
||||
'diff/(?<id>\d+)/$' => 'DifferentialDiffViewController',
|
||||
'changeset/(?<id>\d+)/$' => 'DifferentialChangesetViewController',
|
||||
),
|
||||
|
||||
'.*' => 'AphrontDefaultApplicationController',
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?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 DifferentialChangesetViewController extends DifferentialController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$changeset = id(new DifferentialChangeset())->load($this->id);
|
||||
if (!$changeset) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$changeset->attachHunks($changeset->loadHunks());
|
||||
|
||||
$parser = new DifferentialChangesetParser();
|
||||
$parser->setChangeset($changeset);
|
||||
|
||||
$output = $parser->render();
|
||||
|
||||
// TODO: This is a bit of a hacky mess.
|
||||
$output =
|
||||
'<div style="padding: 2em 1em;">'.
|
||||
'<div class="differential-primary-pane">'.
|
||||
'<div class="differential-review-stage">'.
|
||||
'<h1>'.phutil_escape_html($changeset->getDisplayFilename()).'</h1>'.
|
||||
'<br />'.
|
||||
$output.
|
||||
'</div>'.
|
||||
'</div>'.
|
||||
'</div>';
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array(
|
||||
$output
|
||||
),
|
||||
array(
|
||||
'title' => 'Changeset View',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?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/differential/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialChangesetViewController.php');
|
File diff suppressed because it is too large
Load diff
23
src/applications/differential/parser/changeset/__init__.php
Normal file
23
src/applications/differential/parser/changeset/__init__.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('arcanist', 'difference');
|
||||
phutil_require_module('arcanist', 'parser/diff');
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||
phutil_require_module('phabricator', 'applications/files/uri');
|
||||
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialChangesetParser.php');
|
|
@ -31,6 +31,7 @@ class DifferentialChangeset extends DifferentialDAO {
|
|||
protected $delLines;
|
||||
|
||||
private $unsavedHunks = array();
|
||||
private $hunks;
|
||||
|
||||
protected function getConfiguration() {
|
||||
return array(
|
||||
|
@ -54,6 +55,18 @@ class DifferentialChangeset extends DifferentialDAO {
|
|||
return $this->changeType;
|
||||
}
|
||||
|
||||
public function attachHunks(array $hunks) {
|
||||
$this->hunks = $hunks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHunks() {
|
||||
if ($this->hunks === null) {
|
||||
throw new Exception("Must load and attach hunks first!");
|
||||
}
|
||||
return $this->hunks;
|
||||
}
|
||||
|
||||
public function getDisplayFilename() {
|
||||
$name = $this->getFilename();
|
||||
if ($this->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
||||
|
@ -63,6 +76,10 @@ class DifferentialChangeset extends DifferentialDAO {
|
|||
}
|
||||
|
||||
public function addUnsavedHunk(DifferentialHunk $hunk) {
|
||||
if ($this->hunks === null) {
|
||||
$this->hunks = array();
|
||||
}
|
||||
$this->hunks[] = $hunk;
|
||||
$this->unsavedHunks[] = $hunk;
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -40,12 +40,29 @@ class DifferentialDiff extends DifferentialDAO {
|
|||
protected $creationMethod;
|
||||
|
||||
private $unsavedChangesets = array();
|
||||
private $changesets;
|
||||
|
||||
public function addUnsavedChangeset(DifferentialChangeset $changeset) {
|
||||
if ($this->changesets === null) {
|
||||
$this->changesets = array();
|
||||
}
|
||||
$this->unsavedChangesets[] = $changeset;
|
||||
$this->changesets[] = $changeset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function attachChangesets(array $changesets) {
|
||||
$this->changesets = $changesets;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChangesets() {
|
||||
if ($this->changesets === null) {
|
||||
throw new Exception("Must load and attach changesets first!");
|
||||
}
|
||||
return $this->changesets;
|
||||
}
|
||||
|
||||
public function loadChangesets() {
|
||||
if (!$this->getID()) {
|
||||
return array();
|
||||
|
|
|
@ -63,12 +63,13 @@ class DifferentialChangesetDetailView extends AphrontView {
|
|||
'whitespace' => $whitespace,
|
||||
));
|
||||
*/
|
||||
$detail_uri = '!';
|
||||
$detail_uri = '/differential/changeset/'.$changeset->getID().'/';
|
||||
|
||||
$detail = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'style' => 'float: right',
|
||||
'class' => 'button small grey',
|
||||
'href' => $detail_uri,
|
||||
'target' => '_blank',
|
||||
),
|
||||
|
@ -79,7 +80,7 @@ class DifferentialChangesetDetailView extends AphrontView {
|
|||
$display_filename = $changeset->getDisplayFilename();
|
||||
$output[] =
|
||||
'<div>'.
|
||||
'<h1>'.phutil_escape_html($display_filename).'</h1>'.
|
||||
'<h1>'.$detail.phutil_escape_html($display_filename).'</h1>'.
|
||||
'<div>Loading...</div>'.
|
||||
'</div>';
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||
phutil_require_module('phabricator', 'view/base');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialChangesetDetailView.php');
|
25
src/applications/files/uri/PhabricatorFileURI.php
Normal file
25
src/applications/files/uri/PhabricatorFileURI.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?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 PhabricatorFileURI {
|
||||
|
||||
public static function getViewURIForPHID($phid) {
|
||||
return '/file/view/'.$phid.'/';
|
||||
}
|
||||
|
||||
}
|
10
src/applications/files/uri/__init__.php
Normal file
10
src/applications/files/uri/__init__.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorFileURI.php');
|
|
@ -635,4 +635,115 @@ th.aphront-side-nav-navigation a.aphront-side-nav-selected:hover {
|
|||
border-bottom: 1px solid #aaaa99;
|
||||
padding-bottom: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* changeset view */
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
.differential-diff {
|
||||
background: #ffffff;
|
||||
font-family: "Menlo", "Consolas", "Monaco", monospace;
|
||||
font-size: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.differential-diff td {
|
||||
/* using monospace fonts makes ex/em most useful:
|
||||
*
|
||||
* Unfortunately, firefox 3.6 renders diffs columns for added and removed
|
||||
* files "way-too-wide" when given em as the dimension measurement, so we
|
||||
* use an eyeballed ex equivalent and reset it to the ch character width
|
||||
* measurement for browsers that support that css3 measurement.
|
||||
*/
|
||||
width: 88ex;
|
||||
width: 81ch;
|
||||
/*
|
||||
Disable ligatures in Firefox. Firefox 3 has fancypants ligature support, but
|
||||
it gets applied to monospaced fonts, which sucks because it means that the
|
||||
"fi" ligature only takes up one character, e.g. It's probably the font's
|
||||
fault that it even specifies ligatures (seriously, what the hell?) but
|
||||
that's hard to fix and this is "easy" to "fix": custom letter spacing
|
||||
disables ligatures, as long as it's at least 0.008333-repeating pixels of
|
||||
custom letter spacing. I have no idea where this number comes from, but note
|
||||
that .83333.. = 5/6. -epriestley
|
||||
*/
|
||||
letter-spacing: 0.0083334px;
|
||||
vertical-align: top;
|
||||
white-space: pre;
|
||||
padding: 0 8px 1px;
|
||||
line-height: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.differential-diff th {
|
||||
text-align: right;
|
||||
padding: 2px 6px;
|
||||
width: 44px;
|
||||
vertical-align: top;
|
||||
background: #eeeeee;
|
||||
color: #888888;
|
||||
cursor: pointer;
|
||||
border-style: solid;
|
||||
border-width: 0px 1px;
|
||||
border-color: #eeeeee #999999 #eeeeee #dddddd;
|
||||
font-weight: bold;
|
||||
font-family: "Verdana";
|
||||
font-size: 11px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.differential-diff td.old {
|
||||
background: #ffd0d0;
|
||||
color: #161111;
|
||||
}
|
||||
|
||||
.differential-diff td.new {
|
||||
background: #d0ffd0;
|
||||
color: #111611;
|
||||
}
|
||||
|
||||
.differential-diff td.old-full,
|
||||
.differential-diff td.old span.bright {
|
||||
background: #ffaaaa;
|
||||
color: #221111;
|
||||
}
|
||||
|
||||
.differential-diff td.new-full,
|
||||
.differential-diff td.new span.bright {
|
||||
background: #aaffaa;
|
||||
color: #112211;
|
||||
}
|
||||
|
||||
.differential-diff td.show-more,
|
||||
.differential-diff td.differential-shield {
|
||||
background: #ffffee;
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
font-family: "Verdana";
|
||||
font-size: 11px;
|
||||
border: 1px solid #ccccaa;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.differential-diff td.show-more {
|
||||
color: #999966;
|
||||
}
|
||||
|
||||
.differential-diff td.differential-shield {
|
||||
text-align: center;
|
||||
max-width: 1160px;
|
||||
}
|
||||
|
||||
.differential-diff td.differential-shield a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.differential-primary-pane {
|
||||
margin: 0 40px;
|
||||
max-width: 1162px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue