Page MenuHomePhabricator

D14477.id35017.diff
No OneTemporary

D14477.id35017.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2668,6 +2668,7 @@
'PhabricatorPhurlShortURLDefaultController' => 'applications/phurl/controller/PhabricatorPhurlShortURLDefaultController.php',
'PhabricatorPhurlURL' => 'applications/phurl/storage/PhabricatorPhurlURL.php',
'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php',
+ 'PhabricatorPhurlURLCommentController' => 'applications/phurl/controller/PhabricatorPhurlURLCommentController.php',
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
'PhabricatorPhurlURLEditor' => 'applications/phurl/editor/PhabricatorPhurlURLEditor.php',
'PhabricatorPhurlURLListController' => 'applications/phurl/controller/PhabricatorPhurlURLListController.php',
@@ -6842,6 +6843,7 @@
'PhabricatorSpacesInterface',
),
'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController',
+ 'PhabricatorPhurlURLCommentController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorPhurlURLListController' => 'PhabricatorPhurlController',
diff --git a/src/applications/config/option/PhabricatorPhurlConfigOptions.php b/src/applications/config/option/PhabricatorPhurlConfigOptions.php
--- a/src/applications/config/option/PhabricatorPhurlConfigOptions.php
+++ b/src/applications/config/option/PhabricatorPhurlConfigOptions.php
@@ -16,7 +16,7 @@
}
public function getGroup() {
- return 'phurl';
+ return 'apps';
}
public function getOptions() {
diff --git a/src/applications/phurl/application/PhabricatorPhurlApplication.php b/src/applications/phurl/application/PhabricatorPhurlApplication.php
--- a/src/applications/phurl/application/PhabricatorPhurlApplication.php
+++ b/src/applications/phurl/application/PhabricatorPhurlApplication.php
@@ -46,6 +46,8 @@
=> 'PhabricatorPhurlURLEditController',
'edit/(?P<id>[1-9]\d*)/'
=> 'PhabricatorPhurlURLEditController',
+ 'comment/(?P<id>[1-9]\d*)/'
+ => 'PhabricatorPhurlURLCommentController',
),
),
);
diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLCommentController.php b/src/applications/phurl/controller/PhabricatorPhurlURLCommentController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phurl/controller/PhabricatorPhurlURLCommentController.php
@@ -0,0 +1,63 @@
+<?php
+
+final class PhabricatorPhurlURLCommentController
+ extends PhabricatorPhurlController {
+
+ public function handleRequest(AphrontRequest $request) {
+ if (!$request->isFormPost()) {
+ return new Aphront400Response();
+ }
+
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ $is_preview = $request->isPreviewRequest();
+ $draft = PhabricatorDraft::buildFromRequest($request);
+
+ $phurl = id(new PhabricatorPhurlURLQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$phurl) {
+ return new Aphront404Response();
+ }
+
+ $view_uri = '/'.$phurl->getMonogram();
+
+ $xactions = array();
+ $xactions[] = id(new PhabricatorPhurlURLTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+ ->attachComment(
+ id(new PhabricatorPhurlURLTransactionComment())
+ ->setContent($request->getStr('comment')));
+
+ $editor = id(new PhabricatorPhurlURLEditor())
+ ->setActor($viewer)
+ ->setContinueOnNoEffect($request->isContinueRequest())
+ ->setContentSourceFromRequest($request)
+ ->setIsPreview($is_preview);
+
+ try {
+ $xactions = $editor->applyTransactions($phurl, $xactions);
+ } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
+ return id(new PhabricatorApplicationTransactionNoEffectResponse())
+ ->setCancelURI($view_uri)
+ ->setException($ex);
+ }
+
+ if ($draft) {
+ $draft->replaceOrDelete();
+ }
+
+ if ($request->isAjax() && $is_preview) {
+ return id(new PhabricatorApplicationTransactionResponse())
+ ->setViewer($viewer)
+ ->setTransactions($xactions)
+ ->setIsPreview($is_preview);
+ } else {
+ return id(new AphrontRedirectResponse())
+ ->setURI($view_uri);
+ }
+ }
+
+}
diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php b/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php
--- a/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php
+++ b/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php
@@ -9,7 +9,6 @@
$viewer = $this->getViewer();
$user_phid = $viewer->getPHID();
- $error_name = true;
$error_long_url = true;
$error_alias = null;
$validation_exception = null;
@@ -131,8 +130,6 @@
->setURI($url->getURI());
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
- $error_name = $ex->getShortMessage(
- PhabricatorPhurlURLTransaction::TYPE_NAME);
$error_long_url = $ex->getShortMessage(
PhabricatorPhurlURLTransaction::TYPE_URL);
$error_alias = $ex->getShortMessage(
@@ -148,8 +145,7 @@
$name = id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
- ->setValue($name)
- ->setError($error_name);
+ ->setValue($name);
$long_url = id(new AphrontFormTextControl())
->setLabel(pht('URL'))
diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php
--- a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php
+++ b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php
@@ -49,7 +49,7 @@
: pht('More Cowbell');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $url->getPHID());
$comment_uri = $this->getApplicationURI(
- '/phurl/comment/'.$url->getID().'/');
+ '/url/comment/'.$url->getID().'/');
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
->setObjectPHID($url->getPHID())
diff --git a/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php b/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php
--- a/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php
+++ b/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php
@@ -106,22 +106,6 @@
$errors = parent::validateTransaction($object, $type, $xactions);
switch ($type) {
- case PhabricatorPhurlURLTransaction::TYPE_NAME:
- $missing = $this->validateIsEmptyTextField(
- $object->getName(),
- $xactions);
-
- if ($missing) {
- $error = new PhabricatorApplicationTransactionValidationError(
- $type,
- pht('Required'),
- pht('URL name is required.'),
- nonempty(last($xactions), null));
-
- $error->setIsMissingFieldError(true);
- $errors[] = $error;
- }
- break;
case PhabricatorPhurlURLTransaction::TYPE_ALIAS:
$overdrawn = $this->validateIsTextFieldTooLong(
$object->getName(),
diff --git a/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php b/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php
--- a/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php
+++ b/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php
@@ -7,7 +7,7 @@
}
public function apply($text) {
- // `((U123))` remarkup link to `/u/123`
+ // `((123))` remarkup link to `/u/123`
// `((alias))` remarkup link to `/u/alias`
return preg_replace_callback(
'/\(\(([^ )]+)\)\)/',
@@ -41,17 +41,19 @@
$phurl = head($phurls);
if ($phurl) {
+ $title = $phurl->getName() ? $phurl->getName() : $phurl->getMonogram();
+ $redirect = '/u/'.$phurl->getID();
if ($text_mode) {
- return $phurl->getName().' <'.$phurl->getLongURL().'>';
+ return $title.' <'.$redirect.'>';
}
$link = phutil_tag(
'a',
array(
- 'href' => $phurl->getLongURL(),
+ 'href' => $redirect,
'target' => '_blank',
),
- $phurl->getName());
+ $title);
return $this->getEngine()->storeText($link);
} else {

File Metadata

Mime Type
text/plain
Expires
Wed, May 22, 10:43 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6305792
Default Alt Text
D14477.id35017.diff (8 KB)

Event Timeline