Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15409968
D19107.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D19107.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -10,7 +10,7 @@
'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => 'e4f098a5',
- 'core.pkg.js' => '3ac6e174',
+ 'core.pkg.js' => 'bd19de1c',
'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '113e692c',
'differential.pkg.js' => 'f6d809c0',
@@ -506,7 +506,7 @@
'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e',
'rsrc/js/core/behavior-reveal-content.js' => '60821bc7',
'rsrc/js/core/behavior-scrollbar.js' => '834a1173',
- 'rsrc/js/core/behavior-search-typeahead.js' => 'd0a99ab4',
+ 'rsrc/js/core/behavior-search-typeahead.js' => 'c3e917d9',
'rsrc/js/core/behavior-select-content.js' => 'bf5374ef',
'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6',
'rsrc/js/core/behavior-setup-check-https.js' => '491416b3',
@@ -663,7 +663,7 @@
'javelin-behavior-phabricator-oncopy' => '2926fff2',
'javelin-behavior-phabricator-remarkup-assist' => 'acd29eee',
'javelin-behavior-phabricator-reveal-content' => '60821bc7',
- 'javelin-behavior-phabricator-search-typeahead' => 'd0a99ab4',
+ 'javelin-behavior-phabricator-search-typeahead' => 'c3e917d9',
'javelin-behavior-phabricator-show-older-transactions' => '8f29b364',
'javelin-behavior-phabricator-tooltips' => 'c420b0b9',
'javelin-behavior-phabricator-transaction-comment-form' => 'b23b49e6',
@@ -1918,6 +1918,17 @@
'javelin-dom',
'javelin-vector',
),
+ 'c3e917d9' => array(
+ 'javelin-behavior',
+ 'javelin-typeahead-ondemand-source',
+ 'javelin-typeahead',
+ 'javelin-dom',
+ 'javelin-uri',
+ 'javelin-util',
+ 'javelin-stratcom',
+ 'phabricator-prefab',
+ 'phuix-icon-view',
+ ),
'c420b0b9' => array(
'javelin-behavior',
'javelin-behavior-device',
@@ -1969,17 +1980,6 @@
'phabricator-notification',
'conpherence-thread-manager',
),
- 'd0a99ab4' => array(
- 'javelin-behavior',
- 'javelin-typeahead-ondemand-source',
- 'javelin-typeahead',
- 'javelin-dom',
- 'javelin-uri',
- 'javelin-util',
- 'javelin-stratcom',
- 'phabricator-prefab',
- 'phuix-icon-view',
- ),
'd0c516d5' => array(
'javelin-behavior',
'javelin-dom',
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
@@ -4855,6 +4855,7 @@
'PhrictionController' => 'applications/phriction/controller/PhrictionController.php',
'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php',
'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php',
+ 'PhrictionDatasourceEngineExtension' => 'applications/phriction/engineextension/PhrictionDatasourceEngineExtension.php',
'PhrictionDeleteController' => 'applications/phriction/controller/PhrictionDeleteController.php',
'PhrictionDiffController' => 'applications/phriction/controller/PhrictionDiffController.php',
'PhrictionDocument' => 'applications/phriction/storage/PhrictionDocument.php',
@@ -4862,6 +4863,7 @@
'PhrictionDocumentContentHeraldField' => 'applications/phriction/herald/PhrictionDocumentContentHeraldField.php',
'PhrictionDocumentContentTransaction' => 'applications/phriction/xaction/PhrictionDocumentContentTransaction.php',
'PhrictionDocumentController' => 'applications/phriction/controller/PhrictionDocumentController.php',
+ 'PhrictionDocumentDatasource' => 'applications/phriction/typeahead/PhrictionDocumentDatasource.php',
'PhrictionDocumentDeleteTransaction' => 'applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php',
'PhrictionDocumentFerretEngine' => 'applications/phriction/search/PhrictionDocumentFerretEngine.php',
'PhrictionDocumentFulltextEngine' => 'applications/phriction/search/PhrictionDocumentFulltextEngine.php',
@@ -10777,6 +10779,7 @@
'PhrictionController' => 'PhabricatorController',
'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod',
'PhrictionDAO' => 'PhabricatorLiskDAO',
+ 'PhrictionDatasourceEngineExtension' => 'PhabricatorDatasourceEngineExtension',
'PhrictionDeleteController' => 'PhrictionController',
'PhrictionDiffController' => 'PhrictionController',
'PhrictionDocument' => array(
@@ -10796,6 +10799,7 @@
'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentContentTransaction' => 'PhrictionDocumentTransactionType',
'PhrictionDocumentController' => 'PhrictionController',
+ 'PhrictionDocumentDatasource' => 'PhabricatorTypeaheadDatasource',
'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentTransactionType',
'PhrictionDocumentFerretEngine' => 'PhabricatorFerretEngine',
'PhrictionDocumentFulltextEngine' => 'PhabricatorFulltextEngine',
diff --git a/src/applications/phriction/engineextension/PhrictionDatasourceEngineExtension.php b/src/applications/phriction/engineextension/PhrictionDatasourceEngineExtension.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/engineextension/PhrictionDatasourceEngineExtension.php
@@ -0,0 +1,56 @@
+<?php
+
+final class PhrictionDatasourceEngineExtension
+ extends PhabricatorDatasourceEngineExtension {
+
+ public function newQuickSearchDatasources() {
+ return array(
+ new PhrictionDocumentDatasource(),
+ );
+ }
+
+ public function newJumpURI($query) {
+ $viewer = $this->getViewer();
+
+ // Send "w" to Phriction.
+ if (preg_match('/^w\z/i', $query)) {
+ return '/w/';
+ }
+
+ // Send "w <string>" to a search for similar wiki documents.
+ $matches = null;
+ if (preg_match('/^w\s+(.+)\z/i', $query, $matches)) {
+ $raw_query = $matches[1];
+
+ $engine = id(new PhrictionDocument())
+ ->newFerretEngine();
+
+ $compiler = id(new PhutilSearchQueryCompiler())
+ ->setEnableFunctions(true);
+
+ $raw_tokens = $compiler->newTokens($raw_query);
+
+ $fulltext_tokens = array();
+ foreach ($raw_tokens as $raw_token) {
+ $fulltext_token = id(new PhabricatorFulltextToken())
+ ->setToken($raw_token);
+ $fulltext_tokens[] = $fulltext_token;
+ }
+
+ $documents = id(new PhrictionDocumentQuery())
+ ->setViewer($viewer)
+ ->withFerretConstraint($engine, $fulltext_tokens)
+ ->execute();
+ if (count($documents) == 1) {
+ return head($documents)->getURI();
+ } else {
+ // More than one match, jump to search.
+ return urisprintf(
+ '/phriction/?order=relevance&query=%s#R',
+ $raw_query);
+ }
+ }
+
+ return null;
+ }
+}
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
@@ -149,6 +149,10 @@
return $this;
}
+ public function getURI() {
+ return self::getSlugURI($this->getSlug());
+ }
+
/* -( Status )------------------------------------------------------------- */
diff --git a/src/applications/phriction/typeahead/PhrictionDocumentDatasource.php b/src/applications/phriction/typeahead/PhrictionDocumentDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/typeahead/PhrictionDocumentDatasource.php
@@ -0,0 +1,88 @@
+<?php
+
+final class PhrictionDocumentDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Documents');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a document name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorPhrictionApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+
+ $raw_query = $this->getRawQuery();
+
+ $engine = id(new PhrictionDocument())
+ ->newFerretEngine();
+
+ $compiler = id(new PhutilSearchQueryCompiler())
+ ->setEnableFunctions(true);
+
+ $raw_tokens = $compiler->newTokens($raw_query);
+
+ $fulltext_tokens = array();
+ foreach ($raw_tokens as $raw_token) {
+
+ // This is a little hacky and could maybe be cleaner. We're treating
+ // every search term as though the user had entered "title:dog" insead
+ // of "dog".
+
+ $alternate_token = PhutilSearchQueryToken::newFromDictionary(
+ array(
+ 'quoted' => $raw_token->isQuoted(),
+ 'value' => $raw_token->getValue(),
+ 'operator' => PhutilSearchQueryCompiler::OPERATOR_SUBSTRING,
+ 'function' => 'title',
+ ));
+
+ $fulltext_token = id(new PhabricatorFulltextToken())
+ ->setToken($alternate_token);
+ $fulltext_tokens[] = $fulltext_token;
+ }
+
+ $documents = id(new PhrictionDocumentQuery())
+ ->setViewer($viewer)
+ ->withFerretConstraint($engine, $fulltext_tokens)
+ ->needContent(true)
+ ->execute();
+
+ $results = array();
+ foreach ($documents as $document) {
+ $content = $document->getContent();
+
+ if (!$document->isActive()) {
+ $closed = $document->getStatusDisplayName();
+ } else {
+ $closed = null;
+ }
+
+ $slug = $document->getSlug();
+ $title = $content->getTitle();
+
+ $sprite = 'phabricator-search-icon phui-font-fa phui-icon-view fa-book';
+
+ $result = id(new PhabricatorTypeaheadResult())
+ ->setName($title)
+ ->setDisplayName($title)
+ ->setURI($document->getURI())
+ ->setPHID($document->getPHID())
+ ->setDisplayType($slug)
+ ->setPriorityType('wiki')
+ ->setImageSprite($sprite)
+ ->setClosed($closed);
+
+ $results[] = $result;
+ }
+
+ return $results;
+ }
+
+}
diff --git a/webroot/rsrc/js/core/behavior-search-typeahead.js b/webroot/rsrc/js/core/behavior-search-typeahead.js
--- a/webroot/rsrc/js/core/behavior-search-typeahead.js
+++ b/webroot/rsrc/js/core/behavior-search-typeahead.js
@@ -70,6 +70,7 @@
'proj',
'user',
'repo',
+ 'wiki',
'symb',
'misc'
];
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 6:16 AM (15 h, 35 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225572
Default Alt Text
D19107.diff (10 KB)
Attached To
Mode
D19107: Add a rough Quick Search datasource for Phriction documents
Attached
Detach File
Event Timeline
Log In to Comment