Page MenuHomePhabricator

D14095.id34065.diff
No OneTemporary

D14095.id34065.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -99,7 +99,7 @@
'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5',
'rsrc/css/application/releeph/releeph-request-differential-create-dialog.css' => '8d8b92cd',
'rsrc/css/application/releeph/releeph-request-typeahead.css' => '667a48ae',
- 'rsrc/css/application/search/search-results.css' => '7dea472c',
+ 'rsrc/css/application/search/search-results.css' => '586db3a4',
'rsrc/css/application/slowvote/slowvote.css' => '475b4bd2',
'rsrc/css/application/tokens/tokens.css' => '3d0f239e',
'rsrc/css/application/uiexample/example.css' => '528b19de',
@@ -738,7 +738,7 @@
'phabricator-phtize' => 'd254d646',
'phabricator-prefab' => '6920d200',
'phabricator-remarkup-css' => '1c4ac273',
- 'phabricator-search-results-css' => '7dea472c',
+ 'phabricator-search-results-css' => '586db3a4',
'phabricator-shaped-request' => '7cbe244b',
'phabricator-side-menu-view-css' => 'bec2458e',
'phabricator-slowvote-css' => '475b4bd2',
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
@@ -2834,6 +2834,7 @@
'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php',
'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php',
'PhabricatorSearchSelectField' => 'applications/search/field/PhabricatorSearchSelectField.php',
+ 'PhabricatorSearchSnippetInterface' => 'applications/search/interface/PhabricatorSearchSnippetInterface.php',
'PhabricatorSearchStringListField' => 'applications/search/field/PhabricatorSearchStringListField.php',
'PhabricatorSearchSubscribersField' => 'applications/search/field/PhabricatorSearchSubscribersField.php',
'PhabricatorSearchTextField' => 'applications/search/field/PhabricatorSearchTextField.php',
@@ -4126,6 +4127,7 @@
'PhabricatorMentionableInterface',
'PhabricatorDestructibleInterface',
'PhabricatorProjectInterface',
+ 'PhabricatorSearchSnippetInterface',
),
'DifferentialRevisionAffectedFilesHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField',
@@ -5019,6 +5021,7 @@
'PhabricatorApplicationTransactionInterface',
'PhabricatorProjectInterface',
'PhabricatorSpacesInterface',
+ 'PhabricatorSearchSnippetInterface',
),
'ManiphestTaskAssignHeraldAction' => 'HeraldAction',
'ManiphestTaskAssignOtherHeraldAction' => 'ManiphestTaskAssignHeraldAction',
@@ -7607,6 +7610,7 @@
'PhabricatorTokenReceiverInterface',
'PhabricatorDestructibleInterface',
'PhabricatorApplicationTransactionInterface',
+ 'PhabricatorSearchSnippetInterface',
),
'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -13,7 +13,8 @@
PhabricatorApplicationTransactionInterface,
PhabricatorMentionableInterface,
PhabricatorDestructibleInterface,
- PhabricatorProjectInterface {
+ PhabricatorProjectInterface,
+ PhabricatorSearchSnippetInterface {
protected $title = '';
protected $originalTitle;
@@ -629,4 +630,18 @@
$this->saveTransaction();
}
+
+/* -( PhabricatorSearchSnippetInterface )---------------------------------- */
+
+
+ public function renderSearchResultSnippet(PhabricatorUser $viewer) {
+ $content = $this->getSummary();
+ $content = PhabricatorMarkupEngine::summarize($content);
+ $content = PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())->setContent($content),
+ 'default',
+ $viewer);
+ return $content;
+ }
+
}
diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php
--- a/src/applications/maniphest/storage/ManiphestTask.php
+++ b/src/applications/maniphest/storage/ManiphestTask.php
@@ -13,7 +13,8 @@
PhabricatorDestructibleInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorProjectInterface,
- PhabricatorSpacesInterface {
+ PhabricatorSpacesInterface,
+ PhabricatorSearchSnippetInterface {
const MARKUP_FIELD_DESCRIPTION = 'markup:desc';
@@ -390,4 +391,18 @@
return $this->spacePHID;
}
+
+/* -( PhabricatorSearchSnippetInterface )---------------------------------- */
+
+
+ public function renderSearchResultSnippet(PhabricatorUser $viewer) {
+ $content = $this->getDescription();
+ $content = PhabricatorMarkupEngine::summarize($content);
+ $content = PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())->setContent($content),
+ 'default',
+ $viewer);
+ return $content;
+ }
+
}
diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php
--- a/src/applications/phriction/storage/PhrictionDocument.php
+++ b/src/applications/phriction/storage/PhrictionDocument.php
@@ -7,7 +7,8 @@
PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorDestructibleInterface,
- PhabricatorApplicationTransactionInterface {
+ PhabricatorApplicationTransactionInterface,
+ PhabricatorSearchSnippetInterface {
protected $slug;
protected $depth;
@@ -252,4 +253,19 @@
$this->saveTransaction();
}
+
+/* -( PhabricatorSearchSnippetInterface )---------------------------------- */
+
+
+ public function renderSearchResultSnippet(PhabricatorUser $viewer) {
+ $content = $this->getContent()->getContent();
+ $content = PhabricatorMarkupEngine::summarize($content);
+ $content = PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())->setContent($content),
+ 'default',
+ $viewer);
+ return $content;
+ }
+
+
}
diff --git a/src/applications/search/interface/PhabricatorSearchSnippetInterface.php b/src/applications/search/interface/PhabricatorSearchSnippetInterface.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/interface/PhabricatorSearchSnippetInterface.php
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * Objects can implement this interface to provide text snippets in search
+ * result views.
+ */
+interface PhabricatorSearchSnippetInterface {
+
+ public function renderSearchResultSnippet(PhabricatorUser $viewer);
+
+}
diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
--- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
+++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
@@ -251,6 +251,7 @@
foreach ($results as $phid => $handle) {
$view = id(new PhabricatorSearchResultView())
+ ->setUser($viewer)
->setHandle($handle)
->setQuery($query)
->setObject(idx($objects, $phid))
diff --git a/src/applications/search/view/PhabricatorSearchResultView.php b/src/applications/search/view/PhabricatorSearchResultView.php
--- a/src/applications/search/view/PhabricatorSearchResultView.php
+++ b/src/applications/search/view/PhabricatorSearchResultView.php
@@ -21,7 +21,13 @@
return $this;
}
+ public function getObject() {
+ return $this->object;
+ }
+
public function render() {
+ $viewer = $this->getUser();
+
$handle = $this->handle;
if (!$handle->isComplete()) {
return;
@@ -46,6 +52,18 @@
$item->addAttribute(pht('Closed'));
}
+ $object = $this->getObject();
+ if ($object instanceof PhabricatorSearchSnippetInterface) {
+ $snippet = $object->renderSearchResultSnippet($viewer);
+ $snippet = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'phui-search-snippet',
+ ),
+ $snippet);
+ $item->appendChild($snippet);
+ }
+
return $item;
}
diff --git a/webroot/rsrc/css/application/search/search-results.css b/webroot/rsrc/css/application/search/search-results.css
--- a/webroot/rsrc/css/application/search/search-results.css
+++ b/webroot/rsrc/css/application/search/search-results.css
@@ -16,3 +16,8 @@
font-weight: normal;
color: #000;
}
+
+.phui-search-snippet {
+ margin: 0 8px;
+ color: {$greytext};
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 9, 7:58 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705009
Default Alt Text
D14095.id34065.diff (8 KB)

Event Timeline