Display links to editor in Differential and Diffusion
Summary: It is possible to open a file in editor by registering a custom URI scheme (pseudo-protocol). Some editors register it by default. Having links to open the file in external editor is productivity booster although it is a little bit harder to set up. There are several other tools using file_link_format configuration directive (XDebug, Symfony) to bind to this protocol. I've added the example with editor: protocol which can be used as a proxy to actual editor (used by Nette Framework: http://wiki.nette.org/en/howto-editor-link). Test Plan: Configure Editor Link in User Preferences. Register URI scheme in OS. Open a file in Diffusion. Click on the Edit button. Open a revision in Differential. Click on the Edit button. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1422
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,6 +44,7 @@ class DiffusionChangeController extends DiffusionController {
|
||||
'/diffusion/'.$drequest->getRepository()->getCallsign().'/diff/');
|
||||
$changeset_view->setWhitespace(
|
||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
||||
$changeset_view->setUser($this->getRequest()->getUser());
|
||||
|
||||
$content[] = $this->buildCrumbs(
|
||||
array(
|
||||
|
||||
@@ -200,6 +200,7 @@ class DiffusionCommitController extends DiffusionController {
|
||||
$change_list->setChangesets($changesets);
|
||||
$change_list->setRenderingReferences($references);
|
||||
$change_list->setRenderURI('/diffusion/'.$callsign.'/diff/');
|
||||
$change_list->setUser($user);
|
||||
|
||||
// TODO: This is pretty awkward, unify the CSS between Diffusion and
|
||||
// Differential better.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,6 +95,25 @@ class DiffusionBrowseFileController extends DiffusionController {
|
||||
$select.
|
||||
'<button>View</button>');
|
||||
$view_select_panel->appendChild($view_select_form);
|
||||
|
||||
$user = $request->getUser();
|
||||
if ($user) {
|
||||
$line = 1;
|
||||
$repository = $this->getDiffusionRequest()->getRepository();
|
||||
$editor_link = $user->loadEditorLink($path, $line, $repository);
|
||||
if ($editor_link) {
|
||||
$view_select_panel->addButton(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $editor_link,
|
||||
'class' => 'button',
|
||||
),
|
||||
'Edit'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$view_select_panel->appendChild('<div style="clear: both;"></div>');
|
||||
|
||||
// Build the content of the file.
|
||||
|
||||
Reference in New Issue
Block a user