@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Flesh out "phriction.document.search" slightly and provide page text for content/documents

Summary: Depends on D19100. Ref T13077. Adds a "content" attachment to get the actual page text. This works on both "phriction.document.search" and "phriction.content.search".

Test Plan: Called both API methods with the attachment, saw proper text content returned.

Maniphest Tasks: T13077

Differential Revision: https://secure.phabricator.com/D19103

+75 -7
+3
src/__phutil_library_map__.php
··· 4849 4849 'PhrictionContentQuery' => 'applications/phriction/query/PhrictionContentQuery.php', 4850 4850 'PhrictionContentSearchConduitAPIMethod' => 'applications/phriction/conduit/PhrictionContentSearchConduitAPIMethod.php', 4851 4851 'PhrictionContentSearchEngine' => 'applications/phriction/query/PhrictionContentSearchEngine.php', 4852 + 'PhrictionContentSearchEngineAttachment' => 'applications/phriction/engineextension/PhrictionContentSearchEngineAttachment.php', 4852 4853 'PhrictionController' => 'applications/phriction/controller/PhrictionController.php', 4853 4854 'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php', 4854 4855 'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php', ··· 10768 10769 'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 10769 10770 'PhrictionContentSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 10770 10771 'PhrictionContentSearchEngine' => 'PhabricatorApplicationSearchEngine', 10772 + 'PhrictionContentSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 10771 10773 'PhrictionController' => 'PhabricatorController', 10772 10774 'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod', 10773 10775 'PhrictionDAO' => 'PhabricatorLiskDAO', ··· 10784 10786 'PhabricatorFerretInterface', 10785 10787 'PhabricatorProjectInterface', 10786 10788 'PhabricatorApplicationTransactionInterface', 10789 + 'PhabricatorConduitResultInterface', 10787 10790 ), 10788 10791 'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField', 10789 10792 'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
+31
src/applications/phriction/engineextension/PhrictionContentSearchEngineAttachment.php
··· 1 + <?php 2 + 3 + final class PhrictionContentSearchEngineAttachment 4 + extends PhabricatorSearchEngineAttachment { 5 + 6 + public function getAttachmentName() { 7 + return pht('Document Content'); 8 + } 9 + 10 + public function getAttachmentDescription() { 11 + return pht('Get the content of documents or document histories.'); 12 + } 13 + 14 + public function getAttachmentForObject($object, $data, $spec) { 15 + if ($object instanceof PhrictionDocument) { 16 + $content = $object->getContent(); 17 + } else { 18 + $content = $object; 19 + } 20 + 21 + return array( 22 + 'title' => $content->getTitle(), 23 + 'path' => $content->getSlug(), 24 + 'authorPHID' => $content->getAuthorPHID(), 25 + 'content' => array( 26 + 'raw' => $content->getContent(), 27 + ), 28 + ); 29 + } 30 + 31 + }
+4 -6
src/applications/phriction/storage/PhrictionContent.php
··· 118 118 ->setKey('version') 119 119 ->setType('int') 120 120 ->setDescription(pht('Content version.')), 121 - id(new PhabricatorConduitSearchFieldSpecification()) 122 - ->setKey('authorPHID') 123 - ->setType('phid') 124 - ->setDescription(pht('Author of this version of the content.')), 125 121 ); 126 122 } 127 123 ··· 129 125 return array( 130 126 'documentPHID' => $this->getDocument()->getPHID(), 131 127 'version' => (int)$this->getVersion(), 132 - 'authorPHID' => $this->getAuthorPHID(), 133 128 ); 134 129 } 135 130 136 131 public function getConduitSearchAttachments() { 137 - return array(); 132 + return array( 133 + id(new PhrictionContentSearchEngineAttachment()) 134 + ->setAttachmentKey('content'), 135 + ); 138 136 } 139 137 140 138 }
+37 -1
src/applications/phriction/storage/PhrictionDocument.php
··· 10 10 PhabricatorFulltextInterface, 11 11 PhabricatorFerretInterface, 12 12 PhabricatorProjectInterface, 13 - PhabricatorApplicationTransactionInterface { 13 + PhabricatorApplicationTransactionInterface, 14 + PhabricatorConduitResultInterface { 14 15 15 16 protected $slug; 16 17 protected $depth; ··· 288 289 return new PhrictionDocumentFerretEngine(); 289 290 } 290 291 292 + 293 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 294 + 295 + 296 + public function getFieldSpecificationsForConduit() { 297 + return array( 298 + id(new PhabricatorConduitSearchFieldSpecification()) 299 + ->setKey('path') 300 + ->setType('string') 301 + ->setDescription(pht('The path to the document.')), 302 + id(new PhabricatorConduitSearchFieldSpecification()) 303 + ->setKey('status') 304 + ->setType('map<string, wild>') 305 + ->setDescription(pht('Status information about the document.')), 306 + ); 307 + } 308 + 309 + public function getFieldValuesForConduit() { 310 + $status = array( 311 + 'value' => $this->getStatus(), 312 + 'name' => $this->getStatusDisplayName(), 313 + ); 314 + 315 + return array( 316 + 'path' => $this->getSlug(), 317 + 'status' => $status, 318 + ); 319 + } 320 + 321 + public function getConduitSearchAttachments() { 322 + return array( 323 + id(new PhrictionContentSearchEngineAttachment()) 324 + ->setAttachmentKey('content'), 325 + ); 326 + } 291 327 }