mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Provide a web interface to view raw source text in Differential
Summary: Add links to the 'standalone view' to grab the raw source text. I think this operation is rare enough that it's okay to hide it like this. I changed 'Standalone View' to 'View Standalone / Raw' to improve discoverability. This also fixes the broken Standalone View links in Diffusion by no longer rendering them. Test Plan: viewed old and new sources for a changeset Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, jungejason, aran CC: aran, tuomaspelkonen Differential Revision: 243
This commit is contained in:
parent
7566f50d8f
commit
7ebd0d1efe
7 changed files with 94 additions and 28 deletions
|
@ -136,7 +136,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'differential-changeset-view-css' =>
|
'differential-changeset-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/f26ca6f9/rsrc/css/application/differential/changeset-view.css',
|
'uri' => '/res/32a8bac6/rsrc/css/application/differential/changeset-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -690,7 +690,7 @@ celerity_register_resource_map(array(
|
||||||
'uri' => '/res/pkg/6c786373/differential.pkg.js',
|
'uri' => '/res/pkg/6c786373/differential.pkg.js',
|
||||||
'type' => 'js',
|
'type' => 'js',
|
||||||
),
|
),
|
||||||
'8d8a971a' =>
|
'8e4ef51b' =>
|
||||||
array (
|
array (
|
||||||
'name' => 'differential.pkg.css',
|
'name' => 'differential.pkg.css',
|
||||||
'symbols' =>
|
'symbols' =>
|
||||||
|
@ -704,7 +704,7 @@ celerity_register_resource_map(array(
|
||||||
6 => 'differential-revision-add-comment-css',
|
6 => 'differential-revision-add-comment-css',
|
||||||
7 => 'differential-revision-comment-list-css',
|
7 => 'differential-revision-comment-list-css',
|
||||||
),
|
),
|
||||||
'uri' => '/res/pkg/8d8a971a/differential.pkg.css',
|
'uri' => '/res/pkg/8e4ef51b/differential.pkg.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
),
|
),
|
||||||
'eadf6ec3' =>
|
'eadf6ec3' =>
|
||||||
|
@ -728,14 +728,14 @@ celerity_register_resource_map(array(
|
||||||
'aphront-table-view-css' => '4270730a',
|
'aphront-table-view-css' => '4270730a',
|
||||||
'aphront-tokenizer-control-css' => '4270730a',
|
'aphront-tokenizer-control-css' => '4270730a',
|
||||||
'aphront-typeahead-control-css' => '4270730a',
|
'aphront-typeahead-control-css' => '4270730a',
|
||||||
'differential-changeset-view-css' => '8d8a971a',
|
'differential-changeset-view-css' => '8e4ef51b',
|
||||||
'differential-core-view-css' => '8d8a971a',
|
'differential-core-view-css' => '8e4ef51b',
|
||||||
'differential-revision-add-comment-css' => '8d8a971a',
|
'differential-revision-add-comment-css' => '8e4ef51b',
|
||||||
'differential-revision-comment-css' => '8d8a971a',
|
'differential-revision-comment-css' => '8e4ef51b',
|
||||||
'differential-revision-comment-list-css' => '8d8a971a',
|
'differential-revision-comment-list-css' => '8e4ef51b',
|
||||||
'differential-revision-detail-css' => '8d8a971a',
|
'differential-revision-detail-css' => '8e4ef51b',
|
||||||
'differential-revision-history-css' => '8d8a971a',
|
'differential-revision-history-css' => '8e4ef51b',
|
||||||
'differential-table-of-contents-css' => '8d8a971a',
|
'differential-table-of-contents-css' => '8e4ef51b',
|
||||||
'diffusion-commit-view-css' => 'eadf6ec3',
|
'diffusion-commit-view-css' => 'eadf6ec3',
|
||||||
'javelin-behavior-differential-diff-radios' => '6c786373',
|
'javelin-behavior-differential-diff-radios' => '6c786373',
|
||||||
'javelin-behavior-differential-edit-inline-comments' => '6c786373',
|
'javelin-behavior-differential-edit-inline-comments' => '6c786373',
|
||||||
|
|
|
@ -33,6 +33,19 @@ class DifferentialChangesetViewController extends DifferentialController {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$view = $request->getStr('view');
|
||||||
|
if ($view) {
|
||||||
|
$changeset->attachHunks($changeset->loadHunks());
|
||||||
|
switch ($view) {
|
||||||
|
case 'new':
|
||||||
|
return $this->buildRawFileResponse($changeset->makeNewFile());
|
||||||
|
case 'old':
|
||||||
|
return $this->buildRawFileResponse($changeset->makeOldFile());
|
||||||
|
default:
|
||||||
|
return new Aphront400Response();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($vs && ($vs != -1)) {
|
if ($vs && ($vs != -1)) {
|
||||||
$vs_changeset = id(new DifferentialChangeset())->load($vs);
|
$vs_changeset = id(new DifferentialChangeset())->load($vs);
|
||||||
if (!$vs_changeset) {
|
if (!$vs_changeset) {
|
||||||
|
@ -177,6 +190,26 @@ class DifferentialChangesetViewController extends DifferentialController {
|
||||||
$detail = new DifferentialChangesetDetailView();
|
$detail = new DifferentialChangesetDetailView();
|
||||||
$detail->setChangeset($changeset);
|
$detail->setChangeset($changeset);
|
||||||
$detail->appendChild($output);
|
$detail->appendChild($output);
|
||||||
|
|
||||||
|
if (!$vs) {
|
||||||
|
$detail->addButton(
|
||||||
|
phutil_render_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $request->getRequestURI()->alter('view', 'old'),
|
||||||
|
'class' => 'grey button small',
|
||||||
|
),
|
||||||
|
'View Raw File (Old Version)'));
|
||||||
|
$detail->addButton(
|
||||||
|
phutil_render_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $request->getRequestURI()->alter('view', 'new'),
|
||||||
|
'class' => 'grey button small',
|
||||||
|
),
|
||||||
|
'View Raw File (New Version)'));
|
||||||
|
}
|
||||||
|
|
||||||
$detail->setRevisionID($request->getInt('revision_id'));
|
$detail->setRevisionID($request->getInt('revision_id'));
|
||||||
|
|
||||||
$output =
|
$output =
|
||||||
|
@ -202,5 +235,10 @@ class DifferentialChangesetViewController extends DifferentialController {
|
||||||
$author_phid);
|
$author_phid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildRawFileResponse($text) {
|
||||||
|
return id(new AphrontFileResponse())
|
||||||
|
->setMimeType('text/plain')
|
||||||
|
->setContent($text);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
|
|
||||||
phutil_require_module('arcanist', 'parser/diff');
|
phutil_require_module('arcanist', 'parser/diff');
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/400');
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'aphront/response/ajax');
|
phutil_require_module('phabricator', 'aphront/response/ajax');
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/file');
|
||||||
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
||||||
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
||||||
|
@ -23,6 +25,7 @@ phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||||
phutil_require_module('phutil', 'filesystem');
|
phutil_require_module('phutil', 'filesystem');
|
||||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||||
phutil_require_module('phutil', 'future/exec');
|
phutil_require_module('phutil', 'future/exec');
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||||
$changeset_view = new DifferentialChangesetListView();
|
$changeset_view = new DifferentialChangesetListView();
|
||||||
$changeset_view->setChangesets($visible_changesets);
|
$changeset_view->setChangesets($visible_changesets);
|
||||||
$changeset_view->setEditable(true);
|
$changeset_view->setEditable(true);
|
||||||
|
$changeset_view->setStandaloneViews(true);
|
||||||
$changeset_view->setRevision($revision);
|
$changeset_view->setRevision($revision);
|
||||||
$changeset_view->setVsMap($vs_map);
|
$changeset_view->setVsMap($vs_map);
|
||||||
$changeset_view->setWhitespace($whitespace);
|
$changeset_view->setWhitespace($whitespace);
|
||||||
|
|
|
@ -53,6 +53,14 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
$class .= ' differential-changeset-immutable';
|
$class .= ' differential-changeset-immutable';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$buttons = null;
|
||||||
|
if ($this->buttons) {
|
||||||
|
$buttons =
|
||||||
|
'<div class="differential-changeset-buttons">'.
|
||||||
|
implode('', $this->buttons).
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
$display_filename = $changeset->getDisplayFilename();
|
$display_filename = $changeset->getDisplayFilename();
|
||||||
$output = javelin_render_tag(
|
$output = javelin_render_tag(
|
||||||
'div',
|
'div',
|
||||||
|
@ -70,7 +78,7 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
'name' => $changeset->getAnchorName(),
|
'name' => $changeset->getAnchorName(),
|
||||||
),
|
),
|
||||||
'').
|
'').
|
||||||
implode('', $this->buttons).
|
$buttons.
|
||||||
'<h1>'.phutil_escape_html($display_filename).'</h1>'.
|
'<h1>'.phutil_escape_html($display_filename).'</h1>'.
|
||||||
'<div style="clear: both;"></div>'.
|
'<div style="clear: both;"></div>'.
|
||||||
$this->renderChildren());
|
$this->renderChildren());
|
||||||
|
|
|
@ -24,6 +24,7 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
private $renderURI = '/differential/changeset/';
|
private $renderURI = '/differential/changeset/';
|
||||||
private $vsMap = array();
|
private $vsMap = array();
|
||||||
private $whitespace;
|
private $whitespace;
|
||||||
|
private $standaloneViews;
|
||||||
|
|
||||||
public function setChangesets($changesets) {
|
public function setChangesets($changesets) {
|
||||||
$this->changesets = $changesets;
|
$this->changesets = $changesets;
|
||||||
|
@ -35,6 +36,11 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setStandaloneViews($has_standalone_views) {
|
||||||
|
$this->standaloneViews = $has_standalone_views;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setRevision(DifferentialRevision $revision) {
|
public function setRevision(DifferentialRevision $revision) {
|
||||||
$this->revision = $revision;
|
$this->revision = $revision;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -78,6 +84,8 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
|
|
||||||
$ref = $changeset->getRenderingReference();
|
$ref = $changeset->getRenderingReference();
|
||||||
|
|
||||||
|
$detail_button = null;
|
||||||
|
if ($this->standaloneViews) {
|
||||||
$detail_uri = new PhutilURI($this->renderURI);
|
$detail_uri = new PhutilURI($this->renderURI);
|
||||||
$detail_uri->setQueryParams(
|
$detail_uri->setQueryParams(
|
||||||
array(
|
array(
|
||||||
|
@ -89,12 +97,12 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
$detail_button = phutil_render_tag(
|
$detail_button = phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'style' => 'float: right',
|
|
||||||
'class' => 'button small grey',
|
'class' => 'button small grey',
|
||||||
'href' => $detail_uri,
|
'href' => $detail_uri,
|
||||||
'target' => '_blank',
|
'target' => '_blank',
|
||||||
),
|
),
|
||||||
'Standalone View');
|
'View Standalone / Raw');
|
||||||
|
}
|
||||||
|
|
||||||
$uniq_id = celerity_generate_unique_node_id();
|
$uniq_id = celerity_generate_unique_node_id();
|
||||||
|
|
||||||
|
|
|
@ -172,3 +172,11 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 12em;
|
height: 12em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.differential-changeset-buttons {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-changeset-buttons a.button {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue