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:
@@ -33,6 +33,19 @@ class DifferentialChangesetViewController extends DifferentialController {
|
||||
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)) {
|
||||
$vs_changeset = id(new DifferentialChangeset())->load($vs);
|
||||
if (!$vs_changeset) {
|
||||
@@ -177,6 +190,26 @@ class DifferentialChangesetViewController extends DifferentialController {
|
||||
$detail = new DifferentialChangesetDetailView();
|
||||
$detail->setChangeset($changeset);
|
||||
$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'));
|
||||
|
||||
$output =
|
||||
@@ -202,5 +235,10 @@ class DifferentialChangesetViewController extends DifferentialController {
|
||||
$author_phid);
|
||||
}
|
||||
|
||||
private function buildRawFileResponse($text) {
|
||||
return id(new AphrontFileResponse())
|
||||
->setMimeType('text/plain')
|
||||
->setContent($text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user