Page MenuHomePhabricator

D13090.diff
No OneTemporary

D13090.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
@@ -642,12 +642,14 @@
'DivinerAtomQuery' => 'applications/diviner/query/DivinerAtomQuery.php',
'DivinerAtomRef' => 'applications/diviner/atom/DivinerAtomRef.php',
'DivinerAtomSearchEngine' => 'applications/diviner/query/DivinerAtomSearchEngine.php',
+ 'DivinerAtomSearchIndexer' => 'applications/diviner/search/DivinerAtomSearchIndexer.php',
'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php',
'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php',
'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php',
'DivinerBookItemView' => 'applications/diviner/view/DivinerBookItemView.php',
'DivinerBookPHIDType' => 'applications/diviner/phid/DivinerBookPHIDType.php',
'DivinerBookQuery' => 'applications/diviner/query/DivinerBookQuery.php',
+ 'DivinerBookSearchIndexer' => 'applications/diviner/search/DivinerBookSearchIndexer.php',
'DivinerController' => 'applications/diviner/controller/DivinerController.php',
'DivinerDAO' => 'applications/diviner/storage/DivinerDAO.php',
'DivinerDefaultRenderer' => 'applications/diviner/renderer/DivinerDefaultRenderer.php',
@@ -3884,11 +3886,13 @@
'DivinerAtomPHIDType' => 'PhabricatorPHIDType',
'DivinerAtomQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DivinerAtomSearchEngine' => 'PhabricatorApplicationSearchEngine',
+ 'DivinerAtomSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'DivinerAtomizeWorkflow' => 'DivinerWorkflow',
'DivinerBookController' => 'DivinerController',
'DivinerBookItemView' => 'AphrontTagView',
'DivinerBookPHIDType' => 'PhabricatorPHIDType',
'DivinerBookQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'DivinerBookSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'DivinerController' => 'PhabricatorController',
'DivinerDAO' => 'PhabricatorLiskDAO',
'DivinerDefaultRenderer' => 'DivinerRenderer',
@@ -3899,6 +3903,7 @@
'DivinerLiveBook' => array(
'DivinerDAO',
'PhabricatorPolicyInterface',
+ 'PhabricatorProjectInterface',
'PhabricatorDestructibleInterface',
),
'DivinerLivePublisher' => 'DivinerPublisher',
diff --git a/src/applications/diviner/application/PhabricatorDivinerApplication.php b/src/applications/diviner/application/PhabricatorDivinerApplication.php
--- a/src/applications/diviner/application/PhabricatorDivinerApplication.php
+++ b/src/applications/diviner/application/PhabricatorDivinerApplication.php
@@ -58,4 +58,11 @@
);
}
+ public function getApplicationSearchDocumentTypes() {
+ return array(
+ DivinerAtomPHIDType::TYPECONST,
+ DivinerBookPHIDType::TYPECONST,
+ );
+ }
+
}
diff --git a/src/applications/diviner/phid/DivinerAtomPHIDType.php b/src/applications/diviner/phid/DivinerAtomPHIDType.php
--- a/src/applications/diviner/phid/DivinerAtomPHIDType.php
+++ b/src/applications/diviner/phid/DivinerAtomPHIDType.php
@@ -5,7 +5,7 @@
const TYPECONST = 'ATOM';
public function getTypeName() {
- return pht('Atom');
+ return pht('Diviner Atom');
}
public function newObject() {
@@ -28,8 +28,17 @@
foreach ($handles as $phid => $handle) {
$atom = $objects[$phid];
- $handle->setName($atom->getTitle());
- $handle->setURI($atom->getName());
+ $book = $atom->getBook()->getName();
+ $name = $atom->getName();
+ $type = $atom->getType();
+
+ $handle
+ ->setName($atom->getName())
+ ->setTitle($atom->getTitle())
+ ->setURI("/book/{$book}/{$type}/{$name}/")
+ ->setStatus($atom->getGraphHash()
+ ? PhabricatorObjectHandle::STATUS_OPEN
+ : PhabricatorObjectHandle::STATUS_CLOSED);
}
}
diff --git a/src/applications/diviner/phid/DivinerBookPHIDType.php b/src/applications/diviner/phid/DivinerBookPHIDType.php
--- a/src/applications/diviner/phid/DivinerBookPHIDType.php
+++ b/src/applications/diviner/phid/DivinerBookPHIDType.php
@@ -5,7 +5,7 @@
const TYPECONST = 'BOOK';
public function getTypeName() {
- return pht('Book');
+ return pht('Diviner Book');
}
public function newObject() {
@@ -30,9 +30,10 @@
$name = $book->getName();
- $handle->setName($book->getShortTitle());
- $handle->setFullName($book->getTitle());
- $handle->setURI("/diviner/book/{$name}/");
+ $handle
+ ->setName($book->getShortTitle())
+ ->setFullName($book->getTitle())
+ ->setURI("/book/{$name}/");
}
}
diff --git a/src/applications/diviner/publisher/DivinerLivePublisher.php b/src/applications/diviner/publisher/DivinerLivePublisher.php
--- a/src/applications/diviner/publisher/DivinerLivePublisher.php
+++ b/src/applications/diviner/publisher/DivinerLivePublisher.php
@@ -18,6 +18,9 @@
$book->setConfigurationData($this->getConfigurationData())->save();
$this->book = $book;
+
+ id(new PhabricatorSearchIndexer())
+ ->queueDocumentForIndexing($book->getPHID());
}
return $this->book;
@@ -122,6 +125,9 @@
$symbol->save();
+ id(new PhabricatorSearchIndexer())
+ ->queueDocumentForIndexing($symbol->getPHID());
+
// TODO: We probably need a finer-grained sense of what "documentable"
// atoms are. Neither files nor methods are currently considered
// documentable, but for different reasons: files appear nowhere, while
diff --git a/src/applications/diviner/search/DivinerAtomSearchIndexer.php b/src/applications/diviner/search/DivinerAtomSearchIndexer.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diviner/search/DivinerAtomSearchIndexer.php
@@ -0,0 +1,31 @@
+<?php
+
+final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
+
+ public function getIndexableObject() {
+ return new DivinerLiveSymbol();
+ }
+
+ protected function buildAbstractDocumentByPHID($phid) {
+ $atom = $this->loadDocumentByPHID($phid);
+ $book = $atom->getBook();
+
+ $doc = $this->newDocument($phid)
+ ->setDocumentTitle($atom->getTitle())
+ ->setDocumentCreated($book->getDateCreated())
+ ->setDocumentModified($book->getDateModified());
+
+ $doc->addField(
+ PhabricatorSearchField::FIELD_BODY,
+ $atom->getSummary());
+
+ $doc->addRelationship(
+ PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
+ $atom->getBookPHID(),
+ DivinerBookPHIDType::TYPECONST,
+ $book->getDateCreated());
+
+ return $doc;
+ }
+
+}
diff --git a/src/applications/diviner/search/DivinerBookSearchIndexer.php b/src/applications/diviner/search/DivinerBookSearchIndexer.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diviner/search/DivinerBookSearchIndexer.php
@@ -0,0 +1,25 @@
+<?php
+
+final class DivinerBookSearchIndexer extends PhabricatorSearchDocumentIndexer {
+
+ public function getIndexableObject() {
+ return new DivinerLiveBook();
+ }
+
+ protected function buildAbstractDocumentByPHID($phid) {
+ $book = $this->loadDocumentByPHID($phid);
+
+ $doc = $this->newDocument($phid)
+ ->setDocumentTitle($book->getTitle())
+ ->setDocumentCreated($book->getDateCreated())
+ ->setDocumentModified($book->getDateModified());
+
+ $doc->addField(
+ PhabricatorSearchField::FIELD_BODY,
+ $book->getPreface());
+
+ return $doc;
+ }
+
+
+}
diff --git a/src/applications/diviner/storage/DivinerLiveBook.php b/src/applications/diviner/storage/DivinerLiveBook.php
--- a/src/applications/diviner/storage/DivinerLiveBook.php
+++ b/src/applications/diviner/storage/DivinerLiveBook.php
@@ -42,8 +42,7 @@
}
public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(
- DivinerBookPHIDType::TYPECONST);
+ return PhabricatorPHID::generateNewPHID(DivinerBookPHIDType::TYPECONST);
}
public function getTitle() {
diff --git a/src/applications/search/constants/PhabricatorSearchRelationship.php b/src/applications/search/constants/PhabricatorSearchRelationship.php
--- a/src/applications/search/constants/PhabricatorSearchRelationship.php
+++ b/src/applications/search/constants/PhabricatorSearchRelationship.php
@@ -3,6 +3,7 @@
final class PhabricatorSearchRelationship {
const RELATIONSHIP_AUTHOR = 'auth';
+ const RELATIONSHIP_BOOK = 'book';
const RELATIONSHIP_REVIEWER = 'revw';
const RELATIONSHIP_SUBSCRIBER = 'subs';
const RELATIONSHIP_COMMENTER = 'comm';

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 8:48 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6730911
Default Alt Text
D13090.diff (8 KB)

Event Timeline