mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
"Paste" application tweaks
Summary: Tweaks to the paste app: - I realized that unlike all the other apps, it makes more sense for the default view of this one to be "create paste" instead of "list pastes" since when you access the application directly you are most often wanting to share something. Swap list out of the default slot and make edit the default. - Make the textarea bigger (usability). - Allow you to copy an existing paste. - Implement 'raw view'. - Tweak/adjust list view (usability, formatting). - Tweak page titles. Test Plan: Created, copied, and listed pastes. Viewed raw paste. Created an invalid paste. Tried to create a copy of a nonexistant paste. Reviewed By: codeblock Reviewers: codeblock, jungejason, aran, tuomaspelkonen CC: aran, epriestley, codeblock Differential Revision: 456
This commit is contained in:
parent
c87886c750
commit
555464c4a7
9 changed files with 70 additions and 36 deletions
|
@ -409,7 +409,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPasteController' => 'applications/paste/controller/base',
|
||||
'PhabricatorPasteCreateController' => 'applications/paste/controller/create',
|
||||
'PhabricatorPasteDAO' => 'applications/paste/storage/base',
|
||||
'PhabricatorPasteHomeController' => 'applications/paste/controller/home',
|
||||
'PhabricatorPasteListController' => 'applications/paste/controller/list',
|
||||
'PhabricatorPasteViewController' => 'applications/paste/controller/view',
|
||||
'PhabricatorPeopleController' => 'applications/people/controller/base',
|
||||
'PhabricatorPeopleEditController' => 'applications/people/controller/edit',
|
||||
|
@ -866,7 +866,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPasteController' => 'PhabricatorController',
|
||||
'PhabricatorPasteCreateController' => 'PhabricatorPasteController',
|
||||
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorPasteHomeController' => 'PhabricatorPasteController',
|
||||
'PhabricatorPasteListController' => 'PhabricatorPasteController',
|
||||
'PhabricatorPasteViewController' => 'PhabricatorPasteController',
|
||||
'PhabricatorPeopleController' => 'PhabricatorController',
|
||||
'PhabricatorPeopleEditController' => 'PhabricatorPeopleController',
|
||||
|
|
|
@ -307,8 +307,8 @@ class AphrontDefaultApplicationConfiguration
|
|||
'/status/$' => 'PhabricatorStatusController',
|
||||
|
||||
'/paste/' => array(
|
||||
'$' => 'PhabricatorPasteHomeController',
|
||||
'create/' => 'PhabricatorPasteCreateController',
|
||||
'$' => 'PhabricatorPasteCreateController',
|
||||
'list/' => 'PhabricatorPasteListController',
|
||||
),
|
||||
|
||||
'/P(?P<id>\d+)$' => 'PhabricatorPasteViewController',
|
||||
|
|
|
@ -28,9 +28,9 @@ abstract class PhabricatorPasteController extends PhabricatorController {
|
|||
$page->setGlyph("\xE2\x9C\x8E");
|
||||
$page->setTabs(
|
||||
array(
|
||||
'create' => array(
|
||||
'href' => '/paste/create',
|
||||
'name' => 'Create a Paste',
|
||||
'list' => array(
|
||||
'href' => '/paste/list/',
|
||||
'name' => 'Paste List',
|
||||
),
|
||||
),
|
||||
idx($data, 'tab'));
|
||||
|
|
|
@ -27,6 +27,7 @@ class PhabricatorPasteCreateController extends PhabricatorPasteController {
|
|||
$error_view = null;
|
||||
$e_text = true;
|
||||
|
||||
$paste_text = null;
|
||||
if ($request->isFormPost()) {
|
||||
$errors = array();
|
||||
$title = $request->getStr('title');
|
||||
|
@ -59,6 +60,19 @@ class PhabricatorPasteCreateController extends PhabricatorPasteController {
|
|||
$error_view->setErrors($errors);
|
||||
$error_view->setTitle('A problem has occurred!');
|
||||
}
|
||||
} else {
|
||||
$copy = $request->getInt('copy');
|
||||
if ($copy) {
|
||||
$copy_paste = id(new PhabricatorPaste())->load($copy);
|
||||
if ($copy_paste) {
|
||||
$title = nonempty($copy_paste->getTitle(), 'P'.$copy_paste->getID());
|
||||
$paste->setTitle('Copy of '.$title);
|
||||
$copy_file = id(new PhabricatorFile())->loadOneWhere(
|
||||
'phid = %s',
|
||||
$copy_paste->getFilePHID());
|
||||
$paste_text = $copy_file->loadFileData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form = new AphrontFormView();
|
||||
|
@ -74,6 +88,8 @@ class PhabricatorPasteCreateController extends PhabricatorPasteController {
|
|||
id(new AphrontFormTextAreaControl())
|
||||
->setLabel('Text')
|
||||
->setError($e_text)
|
||||
->setValue($paste_text)
|
||||
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
|
||||
->setName('text'))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorPasteHomeController extends PhabricatorPasteController {
|
||||
class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
|
@ -45,8 +45,7 @@ class PhabricatorPasteHomeController extends PhabricatorPasteController {
|
|||
$handle = $handles[$paste->getAuthorPHID()];
|
||||
|
||||
$rows[] = array(
|
||||
phutil_escape_html($paste->getPHID()),
|
||||
phutil_escape_html($paste->getTitle()),
|
||||
phutil_escape_html('P'.$paste->getID()),
|
||||
|
||||
// TODO: Make this filter by user instead of going to their profile.
|
||||
phutil_render_tag(
|
||||
|
@ -59,42 +58,52 @@ class PhabricatorPasteHomeController extends PhabricatorPasteController {
|
|||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => PhabricatorFileURI::getViewURIForPHID(
|
||||
$paste->getFilePHID()),
|
||||
'href' => '/P'.$paste->getID(),
|
||||
),
|
||||
phutil_escape_html($paste->getFilePHID())),
|
||||
phutil_escape_html(
|
||||
nonempty(
|
||||
$paste->getTitle(),
|
||||
'Untitled Masterwork P'.$paste->getID()))),
|
||||
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'small button grey',
|
||||
'href' => '/P'.$paste->getID(),
|
||||
'href' => PhabricatorFileURI::getViewURIForPHID(
|
||||
$paste->getFilePHID()),
|
||||
),
|
||||
'View'),
|
||||
phutil_escape_html($paste->getFilePHID())),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'PHID',
|
||||
'Title',
|
||||
'Paste ID',
|
||||
'Author',
|
||||
'File PHID',
|
||||
'View'
|
||||
'Title',
|
||||
'File',
|
||||
));
|
||||
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
null,
|
||||
'wide pri',
|
||||
null,
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||
$panel->setHeader("Paste");
|
||||
$panel->setCreateButton('Paste Something', '/paste/create/');
|
||||
$panel->setCreateButton('Paste Something', '/paste/');
|
||||
$panel->appendChild($table);
|
||||
$panel->appendChild($pager);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array(
|
||||
'title' => 'Paste',
|
||||
'title' => 'Paste List',
|
||||
'tab' => 'list',
|
||||
)
|
||||
);
|
||||
}
|
|
@ -18,4 +18,4 @@ phutil_require_module('phutil', 'markup');
|
|||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorPasteHomeController.php');
|
||||
phutil_require_source('PhabricatorPasteListController.php');
|
|
@ -43,16 +43,6 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
|
|||
|
||||
$corpus = $this->buildCorpus($paste, $file);
|
||||
|
||||
/* TODO
|
||||
$raw_button = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'small button grey',
|
||||
'href' => '/P'.$paste->getId().'/raw/',
|
||||
),
|
||||
'Raw Paste');
|
||||
*/
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
|
||||
if (strlen($paste->getTitle())) {
|
||||
|
@ -64,14 +54,31 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
|
|||
}
|
||||
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||
$panel->setCreateButton('Paste Something', '/paste/create/');
|
||||
$panel->addButton(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/paste/?copy='.$paste->getID(),
|
||||
'class' => 'green button',
|
||||
),
|
||||
'Copy This'));
|
||||
|
||||
$raw_uri = PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID());
|
||||
$panel->addButton(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $raw_uri,
|
||||
'class' => 'button',
|
||||
),
|
||||
'View Raw Text'));
|
||||
|
||||
$panel->appendChild($corpus);
|
||||
// $panel->appendChild($raw_button);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array(
|
||||
'title' => 'Viewing Paste '.$this->id,
|
||||
'title' => 'Paste: '.nonempty($paste->getTitle(), 'P'.$paste->getID()),
|
||||
'tab' => 'view',
|
||||
));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
phutil_require_module('phabricator', 'aphront/response/400');
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'applications/files/uri');
|
||||
phutil_require_module('phabricator', 'applications/paste/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/paste/storage/paste');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
phutil_require_module('phabricator', 'infrastructure/daemon/control/reference');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'conduit/client');
|
||||
phutil_require_module('phutil', 'console');
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
|
Loading…
Reference in a new issue