diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-01-08 15:13:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-08 15:13:12 +0300 |
commit | c569d792b9e98d2ad9b59f0a1c0e217e9fb56558 (patch) | |
tree | 39cb3d1c2c380d1fd18ede60dfb7c643fff7b812 | |
parent | 6c756306de1a74aed3f16570d92a7b0f97861de1 (diff) | |
parent | 394dcf8c6e593045e91d0ab60fc89844cb39eb95 (diff) |
Merge pull request #230 from nextcloud/0.4v0.4.0
0.4
86 files changed, 1529 insertions, 814 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b60f29e..db1ab70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,21 @@ # Changelog +### v0.4.0 + +- fullnextsearch -> fulltextsearch +- Pagination +- settings panel + + + ### v0.3.2 - UI: remove personal settings - DB: fill err field on new indexes + + ### v0.3.1 - bugfixes. @@ -1,4 +1,4 @@ -app_name=fullnextsearch +app_name=fulltextsearch project_dir=$(CURDIR)/../$(app_name) build_dir=$(CURDIR)/build/artifacts @@ -8,7 +8,7 @@ sign_dir=$(build_dir)/sign package_name=$(app_name) cert_dir=$(HOME)/.nextcloud/certificates codecov_token_dir=$(HOME)/.nextcloud/codecov_token -version+=0.3.2 +version+=0.4.0 all: appstore @@ -1,10 +1,10 @@ -# FullNextSearch +# FullTextSearch -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nextcloud/fullnextsearch/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/fullnextsearch/?b=master) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nextcloud/fulltextsearch/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/fulltextsearch/?b=master) **BETA VERSION** -_FullNextSearch_ is the core App of a full-text search framework for your Nextcloud. +_FullTextSearch_ is the core App of a full-text search framework for your Nextcloud. To have it operate, and get content indexed, some other Apps are needed: - Some **Providers Apps** to extract content from your Nextcloud. @@ -15,5 +15,5 @@ _Note: There is no limit to the number of Platform-App to be installed, however ### Documentation -[Can be found on the Wiki](https://github.com/nextcloud/fullnextsearch/wiki) +[Can be found on the Wiki](https://github.com/nextcloud/fulltextsearch/wiki) diff --git a/appinfo/app.php b/appinfo/app.php index c59124a..a6a971e 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\AppInfo; +namespace OCA\FullTextSearch\AppInfo; use OCP\AppFramework\QueryException; diff --git a/appinfo/database.xml b/appinfo/database.xml index 67cad02..2e18279 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- - ~ FullNextSearch - Full Text Search your Nextcloud. + ~ FullTextSearch - Full text search framework for Nextcloud ~ ~ This file is licensed under the Affero General Public License version 3 or ~ later. See the COPYING file. ~ ~ @author Maxence Lange <maxence@artificial-owl.com> - ~ @copyright 2017 + ~ @copyright 2018 ~ @license GNU AGPL version 3 or any later version ~ ~ This program is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ <charset>utf8</charset> <table> - <name>*dbprefix*fullnextsearch_indexes</name> + <name>*dbprefix*fulltextsearch_indexes</name> <declaration> <field> @@ -94,7 +94,7 @@ </table> <table> - <name>*dbprefix*fullnextsearch_ticks</name> + <name>*dbprefix*fulltextsearch_ticks</name> <declaration> <field> diff --git a/appinfo/info.xml b/appinfo/info.xml index 88d3c5f..9ba561f 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -1,46 +1,46 @@ <?xml version="1.0"?> <info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd"> - <id>fullnextsearch</id> - <name>Full Next Search (BETA)</name> - <summary>Core App of the modular content indexer.</summary> + <id>fulltextsearch</id> + <name>Full text search (BETA)</name> + <summary>Core of the full-text search framework for Nextcloud</summary> <description><![CDATA[ -FullNextSearch is the core App of a full-text search framework for your Nextcloud. +Core App of the full-text search framework for your Nextcloud. ]]> </description> - <version>0.3.2</version> + <version>0.4.0</version> <licence>agpl</licence> <author>Maxence Lange</author> - <namespace>FullNextSearch</namespace> + <namespace>FullTextSearch</namespace> <documentation> - <admin>https://github.com/nextcloud/fullnextsearch/wiki</admin> + <admin>https://github.com/nextcloud/fulltextsearch/wiki</admin> </documentation> <category>tools</category> - <website>https://github.com/nextcloud/fullnextsearch</website> - <bugs>https://github.com/nextcloud/fullnextsearch/issues</bugs> - <repository>https://github.com/nextcloud/fullnextsearch.git</repository> - <screenshot>https://raw.githubusercontent.com/nextcloud/fullnextsearch/master/screenshots/0.3.0.png</screenshot> + <website>https://github.com/nextcloud/fulltextsearch</website> + <bugs>https://github.com/nextcloud/fulltextsearch/issues</bugs> + <repository>https://github.com/nextcloud/fulltextsearch.git</repository> + <screenshot>https://raw.githubusercontent.com/nextcloud/fulltextsearch/master/screenshots/0.3.0.png</screenshot> <dependencies> <nextcloud min-version="12" max-version="14"/> </dependencies> <background-jobs> - <job>OCA\FullNextSearch\Cron\Index</job> + <job>OCA\FullTextSearch\Cron\Index</job> </background-jobs> <commands> - <command>OCA\FullNextSearch\Command\Stop</command> - <command>OCA\FullNextSearch\Command\Index</command> - <command>OCA\FullNextSearch\Command\Live</command> - <command>OCA\FullNextSearch\Command\Reset</command> - <command>OCA\FullNextSearch\Command\Search</command> + <command>OCA\FullTextSearch\Command\Stop</command> + <command>OCA\FullTextSearch\Command\Index</command> + <command>OCA\FullTextSearch\Command\Live</command> + <command>OCA\FullTextSearch\Command\Reset</command> + <command>OCA\FullTextSearch\Command\Search</command> </commands> <settings> - <admin>OCA\FullNextSearch\Settings\Admin</admin> - <admin-section>OCA\FullNextSearch\Settings\AdminSection</admin-section> + <admin>OCA\FullTextSearch\Settings\Admin</admin> + <admin-section>OCA\FullTextSearch\Settings\AdminSection</admin-section> </settings> </info> diff --git a/appinfo/routes.php b/appinfo/routes.php index 1633a66..89789f5 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,7 +22,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ return [ @@ -30,8 +29,9 @@ return [ ['name' => 'Navigation#navigate', 'url' => '/', 'verb' => 'GET'], ['name' => 'Settings#getSettingsAdmin', 'url' => '/admin/settings', 'verb' => 'GET'], ['name' => 'Settings#setSettingsAdmin', 'url' => '/admin/settings', 'verb' => 'POST'], - ['name' => 'Api#search', 'url' => '/v1/search/{providerId}/', 'verb' => 'GET'], - ['name' => 'Api#searchFromRemote', 'url' => '/v1/remote/{providerId}/', 'verb' => 'GET'] + ['name' => 'Api#search', 'url' => '/v1/search', 'verb' => 'GET'], + ['name' => 'Api#searchFromRemote', 'url' => '/v1/remote', 'verb' => 'GET'], + ['name' => 'Templates#getOptionsPanel', 'url' => '/options/{providerId}/', 'verb' => 'GET'], ] ]; diff --git a/css/fulltextsearch.css b/css/fulltextsearch.css new file mode 100644 index 0000000..d4da377 --- /dev/null +++ b/css/fulltextsearch.css @@ -0,0 +1,160 @@ + +.provider_result { + font-style: italic; +} + +.provider_navigation_right { + position: absolute; + right: 0; + top: 0; + height: 15px; + margin: auto 20px auto 0; + bottom: 0; +} + +.provider_navigation_prev, .provider_navigation_curr, .provider_navigation_next { + float: left; +} + +.provider_navigation_curr { + font-weight: normal; + font-size: 15px; + letter-spacing: 6px; + margin: -3px 0 0 11px; +} + +.provider_navigation_prev, .provider_navigation_next { + cursor: pointer; +} + +.result_entry_default { + height: 50px; + width: 100%; + display: inline-block; + background: #eeeeee; + padding-bottom: 2px; +} + +.result_entry_left { + float: left; + position: relative; + top: 50%; + margin-left: 10px; + transform: perspective(1px) translateY(-50%); +} + +.result_entry_right { + float: right; + margin-right: 10px; + position: relative; + top: 50%; + transform: perspective(1px) translateY(-50%); +} + +.result_entry_default #title { + font-weight: bold; + height: 14px; +} + +.result_entry_default #line1, .result_entry_default #line2 { + color: #333333; + font-size: 11px; + height: 12px; + font-style: italic; +} + +.result_entry_default #score { + font-weight: bold; + font-style: italic; +} + +.next_search_div { + position: relative; + width: 286px; + height: 36px; + margin-right: 20px; +} + +.provider_navigation { + position: relative; + font-size: 15px; + font-weight: bold; + color: #444; + background: #ddd; + margin-bottom: 16px; + padding-top: 10px; + padding-left: 20px; + padding-bottom: 10px; + margin-top: 40px; +} + +.search_more { + background: #fbfbfb; + width: 400px; + padding: 15px; + right: 30px; + position: absolute; + top: 41px; + border-radius: 3px; + border: solid #cecece 1px; +} + +.icon-page-prev { + background-image: url('/apps/fulltextsearch/img/page-prev.svg'); +} + +.icon-page-next { + background-image: url('/apps/fulltextsearch/img/page-next.svg'); +} + +.icon-page-next, .icon-page-prev { + background-repeat: no-repeat; + background-position: center; + width: 16px; + height: 16px; +} + +.icon-fulltextsearch, .icon-close-fulltextsearch { + position: absolute; + right: 10px; + top: 10px; + cursor: pointer; +} + +.icon-more-fulltextsearch { + position: absolute; + right: 40px; + top: 10px; + cursor: pointer; +} + +#next_search_input { + background: #fffc; + width: 212px; + height: 30px; + margin: 2px !important; +} + + +.div-table { + display: table; + width: auto; + border-spacing: 5px; +} + +.div-table-row { + display: table-row; + width: auto; + clear: both; +} + +.div-table-col { + float: left; + display: table-column; +} + + +.div-table-col-left { + width: 220px; + margin-top: 8px; +} diff --git a/css/fullnextsearch.css b/css/navigate.css index e8e8004..b1cb132 100644 --- a/css/fullnextsearch.css +++ b/css/navigate.css @@ -27,11 +27,3 @@ left: 100px; } -.provider_name { - font-size: 16px; - font-weight: bold; - letter-spacing: 5px; - color: #8b8b8b; - margin-bottom: 8px; -} - diff --git a/css/nextsearch.css b/css/nextsearch.css deleted file mode 100644 index 123b9e5..0000000 --- a/css/nextsearch.css +++ /dev/null @@ -1,68 +0,0 @@ - -.provider_result { - font-style: italic; -} - -.result_entry_default { - height: 50px; - width: 100%; - display: inline-block; - background: #eeeeee; - padding-bottom: 2px; -} - -.result_entry_left { - float: left; - position: relative; - top: 50%; - margin-left: 10px; - transform: perspective(1px) translateY(-50%); -} - -.result_entry_right { - float: right; - margin-right: 10px; - position: relative; - top: 50%; - transform: perspective(1px) translateY(-50%); -} - -.result_entry_default #title { - font-weight: bold; - height: 14px; -} - -.result_entry_default #line1, .result_entry_default #line2 { - color: #333333; - font-size: 11px; - height: 12px; - font-style: italic; -} - -.result_entry_default #score { - font-weight: bold; - font-style: italic; -} - -.next_search_div { - position: relative; - width: 250px; - height: 36px; - margin-right: 20px; -} - -.icon-fullnextsearch, .icon-close-fullnextsearch { - position: absolute; - right: 10px; - top: 10px; - cursor: pointer; -} - -#next_search_input { - background: #fffc; - width: 212px; - height: 30px; - margin: 2px !important; -} - - diff --git a/css/personal.css b/css/personal.css deleted file mode 100644 index e69de29..0000000 --- a/css/personal.css +++ /dev/null diff --git a/img/fullnextsearch.svg b/img/fulltextsearch.svg index 0724ed2..0724ed2 100644 --- a/img/fullnextsearch.svg +++ b/img/fulltextsearch.svg diff --git a/img/fullnextsearch_black.svg b/img/fulltextsearch_black.svg index 28595aa..28595aa 100644 --- a/img/fullnextsearch_black.svg +++ b/img/fulltextsearch_black.svg diff --git a/img/page-next.svg b/img/page-next.svg new file mode 100644 index 0000000..102b9cf --- /dev/null +++ b/img/page-next.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewbox="0 0 16 16"><path d="m10.5 8-6-6v-1l7 7-7 7v-1z"/></svg> diff --git a/img/page-prev.svg b/img/page-prev.svg new file mode 100644 index 0000000..34b2fda --- /dev/null +++ b/img/page-prev.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewbox="0 0 16 16"><path d="m5.5 8 6 6v1l-7-7 7-7v1z"/></svg> diff --git a/js/admin.elements.js b/js/admin.elements.js index 777e255..884930f 100644 --- a/js/admin.elements.js +++ b/js/admin.elements.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,33 +21,32 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ -/** global: fns_admin_settings */ +/** global: fts_admin_settings */ -var fns_admin_elements = { - fns_div: null, - fns_platforms: null, - fns_chunkSize: null, - fns_providers: null, +var fts_admin_elements = { + fts_div: null, + fts_platforms: null, + fts_chunkSize: null, + fts_providers: null, init: function () { - fns_admin_elements.fns_div = $('#fns'); - fns_admin_elements.fns_platforms = $('#fns_platforms'); - fns_admin_elements.fns_chunkSize = $('#fns_chunk_size'); + fts_admin_elements.fts_div = $('#fns'); + fts_admin_elements.fts_platforms = $('#fts_platforms'); + fts_admin_elements.fts_chunkSize = $('#fts_chunk_size'); - fns_admin_elements.fns_platforms.on('change', function () { - fns_admin_settings.tagSettingsAsNotSaved($(this)); - fns_admin_settings.saveSettings(); + fts_admin_elements.fts_platforms.on('change', function () { + fts_admin_settings.tagSettingsAsNotSaved($(this)); + fts_admin_settings.saveSettings(); }); - fns_admin_elements.fns_chunkSize.on('input', function () { - fns_admin_settings.tagSettingsAsNotSaved($(this)); + fts_admin_elements.fts_chunkSize.on('input', function () { + fts_admin_settings.tagSettingsAsNotSaved($(this)); }).blur(function () { - fns_admin_settings.saveSettings(); + fts_admin_settings.saveSettings(); }); } }; diff --git a/js/admin.js b/js/admin.js index 611d3d7..4e86549 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,12 +21,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ -/** global: fns_admin_settings */ -/** global: fns_admin_elements */ +/** global: fts_admin_settings */ +/** global: fts_admin_elements */ @@ -34,17 +33,17 @@ $(document).ready(function () { /** - * @constructs NextSearchAdmin + * @constructs FullTextSearchAdmin */ - var NextSearchAdmin = function () { - $.extend(NextSearchAdmin.prototype, fns_admin_elements); - $.extend(NextSearchAdmin.prototype, fns_admin_settings); + var FullTextSearchAdmin = function () { + $.extend(FullTextSearchAdmin.prototype, fts_admin_elements); + $.extend(FullTextSearchAdmin.prototype, fts_admin_settings); - fns_admin_elements.init(); - fns_admin_settings.refreshSettingPage(); + fts_admin_elements.init(); + fts_admin_settings.refreshSettingPage(); }; - OCA.NextSearchAdmin = NextSearchAdmin; - OCA.NextSearchAdmin.settings = new NextSearchAdmin(); + OCA.FullTextSearchAdmin = FullTextSearchAdmin; + OCA.FullTextSearchAdmin.settings = new FullTextSearchAdmin(); }); diff --git a/js/admin.settings.js b/js/admin.settings.js index 11e83d0..5870572 100644 --- a/js/admin.settings.js +++ b/js/admin.settings.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ */ /** global: OC */ -/** global: fns_admin_elements */ +/** global: fts_admin_elements */ /** @namespace result.index_chunk */ /** @namespace result.platforms_all */ @@ -34,7 +34,7 @@ -var fns_admin_settings = { +var fts_admin_settings = { config: null, @@ -42,9 +42,9 @@ var fns_admin_settings = { $.ajax({ method: 'GET', - url: OC.generateUrl('/apps/fullnextsearch/admin/settings') + url: OC.generateUrl('/apps/fulltextsearch/admin/settings') }).done(function (res) { - fns_admin_settings.updateSettingPage(res); + fts_admin_settings.updateSettingPage(res); }); }, @@ -52,19 +52,19 @@ var fns_admin_settings = { updateSettingPage: function (result) { - fns_admin_settings.updateSettingPagePlatforms(result); - fns_admin_settings.updateSettingPageChunkSize(result); + fts_admin_settings.updateSettingPagePlatforms(result); + fts_admin_settings.updateSettingPageChunkSize(result); - fns_admin_settings.updateCurrentPlatform(result); - fns_admin_settings.updateEnabledProviders(result); + fts_admin_settings.updateCurrentPlatform(result); + fts_admin_settings.updateEnabledProviders(result); - fns_admin_settings.tagSettingsAsSaved(fns_admin_elements.fns_div); + fts_admin_settings.tagSettingsAsSaved(fts_admin_elements.fts_div); }, updateSettingPagePlatforms: function (result) { - fns_admin_elements.fns_platforms.empty(); - fns_admin_elements.fns_platforms.append($('<option>', { + fts_admin_elements.fts_platforms.empty(); + fts_admin_elements.fts_platforms.append($('<option>', { value: '', text: '' })); @@ -73,7 +73,7 @@ var fns_admin_settings = { var classes = Object.keys(platforms); for (var i = 0; i < classes.length; i++) { var platformClass = classes[i]; - fns_admin_elements.fns_platforms.append($('<option>', { + fts_admin_elements.fts_platforms.append($('<option>', { value: platformClass, selected: (result.search_platform === platformClass), text: platforms[platformClass].name @@ -83,13 +83,13 @@ var fns_admin_settings = { }); } - fns_admin_elements.fns_platforms.fadeTo(300, 1); + fts_admin_elements.fts_platforms.fadeTo(300, 1); }, updateSettingPageChunkSize: function (result) { - fns_admin_elements.fns_chunkSize.val(result.index_chunk); - fns_admin_elements.fns_chunkSize.fadeTo(300, 1); + fts_admin_elements.fts_chunkSize.val(result.index_chunk); + fts_admin_elements.fts_chunkSize.fadeTo(300, 1); }, @@ -138,18 +138,18 @@ var fns_admin_settings = { saveSettings: function () { var data = { - search_platform: fns_admin_elements.fns_platforms.val(), - index_chunk: fns_admin_elements.fns_chunkSize.val() + search_platform: fts_admin_elements.fts_platforms.val(), + index_chunk: fts_admin_elements.fts_chunkSize.val() }; $.ajax({ method: 'POST', - url: OC.generateUrl('/apps/fullnextsearch/admin/settings'), + url: OC.generateUrl('/apps/fulltextsearch/admin/settings'), data: { data: data } }).done(function (res) { - fns_admin_settings.updateSettingPage(res); + fts_admin_settings.updateSettingPage(res); }); } diff --git a/js/nextsearch.v1.api.js b/js/fulltextsearch.v1.api.js index 43dbd1a..1cc826e 100644 --- a/js/nextsearch.v1.api.js +++ b/js/fulltextsearch.v1.api.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,12 +21,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OC */ -/** global: next_settings */ +/** global: settings */ /** global: result */ /** global: search */ /** global: nav */ @@ -35,16 +34,34 @@ var api = { - search: function (type, search, callback) { + search: function (request, callback) { var res = {status: -1}; + $.ajax({ method: 'GET', - url: OC.generateUrl('/apps/fullnextsearch/v1/search/' + type), + url: OC.generateUrl('/apps/fulltextsearch/v1/search'), data: { - search: search + request: JSON.stringify(request) } }).done(function (res) { result.displayResult(res); + nav.onResultDisplayed(res); + api.onCallback(callback, res); + }).fail(function () { + nav.failedToAjax(); + api.onCallback(callback, res); + }); + }, + + + options: function (providerId, callback) { + var res = {status: -1}; + + $.ajax({ + method: 'GET', + url: OC.generateUrl('/apps/fulltextsearch/options/' + providerId) + }).done(function (res) { + searchbar.onOptionsLoaded(res); api.onCallback(callback, res); }).fail(function () { nav.failedToAjax(); diff --git a/js/nextsearch.v1.js b/js/fulltextsearch.v1.js index 5c742c9..d956088 100644 --- a/js/nextsearch.v1.js +++ b/js/fulltextsearch.v1.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,11 +21,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ -/** global: next_settings */ +/** global: settings */ /** global: searchbar */ /** global: result */ /** global: nav */ @@ -35,20 +34,20 @@ (function () { /** - * @constructs NextSearch + * @constructs FullTextSearch */ - var NextSearch = function () { - $.extend(NextSearch.prototype, next_settings); - $.extend(NextSearch.prototype, result); - $.extend(NextSearch.prototype, searchbar); - $.extend(NextSearch.prototype, nav); - $.extend(NextSearch.prototype, api); + var FullTextSearch = function () { + $.extend(FullTextSearch.prototype, settings); + $.extend(FullTextSearch.prototype, result); + $.extend(FullTextSearch.prototype, searchbar); + $.extend(FullTextSearch.prototype, nav); + $.extend(FullTextSearch.prototype, api); - next_settings.generateDefaultTemplate(); - next_settings.generateNoResultDiv(); + settings.generateDefaultTemplate(); + settings.generateNoResultDiv(); }; - OCA.NextSearch = NextSearch; - OCA.NextSearch.api = new NextSearch(); + OCA.FullTextSearch = FullTextSearch; + OCA.FullTextSearch.api = new FullTextSearch(); })(); diff --git a/js/nextsearch.v1.navigation.js b/js/fulltextsearch.v1.navigation.js index 6dd0944..98a3284 100644 --- a/js/nextsearch.v1.navigation.js +++ b/js/fulltextsearch.v1.navigation.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,19 +21,21 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ /** global: api */ /** global: search */ /** global: result */ -/** global: next_settings */ +/** global: settings */ + var curr = { providerResult: [], - + page: 1, + lastRequest: '', + moreDisplayed: false, setProviderResult: function (id, value) { curr.providerResult[id] = value; @@ -62,12 +64,39 @@ var nav = { }, - managerDivProviderResult: function (divProvider, newResult, oldResult) { + manageDivProviderNavigation: function (divProviderNavigation, meta) { + + var maxPage = Math.ceil(meta.total / meta.request.size); + + divProviderNavigation.attr('data-time', meta.time); + divProviderNavigation.attr('data-page', meta.request.page); + divProviderNavigation.attr('data-search', meta.request.search); + divProviderNavigation.attr('data-max-page', maxPage); + divProviderNavigation.attr('data-size', meta.request.size); + divProviderNavigation.attr('data-total', meta.total); + + var providerName = divProviderNavigation.attr('data-provider-name'); + + var left = "Searching " + providerName + " for '" + meta.request.search + "' returns " + + meta.total + " results in " + meta.time + "ms"; + divProviderNavigation.find('.provider_navigation_left').text(left); + + divProviderNavigation.find('.provider_navigation_curr').text(meta.request.page + ' / ' + + maxPage); + + divProviderNavigation.find('.provider_navigation_prev').stop().fadeTo(200, + (meta.request.page > 1) ? 1 : 0); + divProviderNavigation.find('.provider_navigation_next').stop().fadeTo(200, + (meta.request.page < maxPage) ? 1 : 0); + }, + + + manageDivProviderResult: function (divProviderResult, newResult, oldResult) { //replaceWith(); - nav.divProviderResultAddItems(divProvider, newResult, oldResult); + nav.divProviderResultAddItems(divProviderResult, newResult, oldResult); if (oldResult) { - nav.divProviderResultRemoveItems(divProvider, newResult, oldResult); - nav.divProviderResultMoveItems(divProvider, newResult, oldResult); + nav.divProviderResultRemoveItems(divProviderResult, newResult, oldResult); + nav.divProviderResultMoveItems(divProviderResult, newResult, oldResult); } }, @@ -89,8 +118,8 @@ var nav = { precItem.after(divResult); } - divResult.slideDown(next_settings.delay_result, function () { - $(this).children('.result_template').fadeTo(next_settings.delay_result, 1); + divResult.slideDown(settings.delay_result, function () { + $(this).children('.result_template').fadeTo(settings.delay_result, 1); }); precItem = divResult; @@ -104,8 +133,8 @@ var nav = { var entry = oldResult[i]; if (result.getResultIndex(entry.id, newResult) === -1) { var divResult = nav.getDivResult(entry.id, divProviderResult); - divResult.fadeTo(next_settings.delay_result, 0, function () { - $(this).slideUp(next_settings.delay_result, function () { + divResult.fadeTo(settings.delay_result, 0, function () { + $(this).slideUp(settings.delay_result, function () { $(this).remove(); }); }); @@ -138,12 +167,12 @@ var nav = { var divResult = nav.getDivResult(entryId, divProviderResult); if (precId === '') { - divResult.fadeTo(next_settings.delay_result, 0.35, function () { + divResult.fadeTo(settings.delay_result, 0.35, function () { $(this).prependTo(divProviderResult).fadeTo(100, 1); }); } else { var precItem = nav.getDivResult(precId, divProviderResult); - divResult.fadeTo(next_settings.delay_result, 0.35, function () { + divResult.fadeTo(settings.delay_result, 0.35, function () { $(this).insertAfter(precItem).fadeTo(100, 1); }); } @@ -153,7 +182,7 @@ var nav = { getDivProvider: function (providerId, providerName) { var ret = null; - next_settings.resultContainer.children('.provider_header').each(function () { + settings.resultContainer.children('.provider_header').each(function () { if ($(this).attr('data-id') === providerId) { ret = $(this); } @@ -161,7 +190,7 @@ var nav = { if (ret === null) { ret = nav.generateDivProvider(providerId, providerName); - next_settings.resultContainer.append(ret); + settings.resultContainer.append(ret); } return ret; @@ -220,20 +249,20 @@ var nav = { nav.deleteEmptyDiv(divResult, '#line1'); nav.deleteEmptyDiv(divResult, '#line2'); - if (next_settings.parentHasMethod('onEntryGenerated')) { - next_settings.parent.onEntryGenerated(divResult); + if (settings.parentHasMethod('onEntryGenerated')) { + settings.parent.onEntryGenerated(divResult); } }, onSearchReset: function () { - if (next_settings.parentHasMethod('onSearchReset')) { - next_settings.parent.onSearchReset(); + if (settings.parentHasMethod('onSearchReset')) { + settings.parent.onSearchReset(); } }, onResultDisplayed: function () { - if (next_settings.parentHasMethod('onResultDisplayed')) { - next_settings.parent.onResultDisplayed(); + if (settings.parentHasMethod('onResultDisplayed')) { + settings.parent.onResultDisplayed(); } }, @@ -246,13 +275,13 @@ var nav = { generateTemplateEntry: function (document) { - var divTemplate = next_settings.entryTemplate; + var divTemplate = settings.entryTemplate; if (divTemplate === null) { - divTemplate = next_settings.entryTemplateDefault; + divTemplate = settings.entryTemplateDefault; } if (!divTemplate.length) { - console.log('FullNextSearch Error: template_entry is not defined'); + console.log('FullTextSearch Error: template_entry is not defined'); return; } @@ -281,14 +310,45 @@ var nav = { generateDivProvider: function (providerId, providerName) { - var divProviderName = $('<div>', {class: 'provider_name'}); - divProviderName.text(providerName); + + + var divProviderNavigation = $('<div>', {class: 'provider_navigation'}); + divProviderNavigation.attr('data-provider-name', providerName); + divProviderNavigation.append($('<div>', {class: 'provider_navigation_left'})); + + var divProviderPagination = $('<div>', {class: 'provider_navigation_right'}); + var divProviderPaginationPrev = $('<div>', {class: 'icon-page-prev provider_navigation_prev'}); + divProviderPaginationPrev.on('click', function () { + fullTextSearch.search({ + providers: providerId, + search: divProviderNavigation.attr('data-search'), + page: Number(divProviderNavigation.attr('data-page')) - 1, + size: divProviderNavigation.attr('data-size') + }); + }); + divProviderPagination.append(divProviderPaginationPrev); + + divProviderPagination.append($('<div>', {class: 'provider_navigation_curr'})); + + var divProviderPaginationNext = $('<div>', {class: 'icon-page-next provider_navigation_next'}); + divProviderPaginationNext.on('click', function () { + fullTextSearch.search({ + providers: providerId, + search: divProviderNavigation.attr('data-search'), + page: Number(divProviderNavigation.attr('data-page')) + 1, + size: divProviderNavigation.attr('data-size') + }); + }); + divProviderPagination.append(divProviderPaginationNext); + + divProviderNavigation.append(divProviderPagination); var divProviderResult = $('<div>', {class: 'provider_result'}); + var divProvider = $('<div>', {class: 'provider_header'}); divProvider.hide(); divProvider.attr('data-id', providerId); - divProvider.append(divProviderName); + divProvider.append(divProviderNavigation); divProvider.append(divProviderResult); return divProvider; diff --git a/js/nextsearch.v1.result.js b/js/fulltextsearch.v1.result.js index b8f5f06..80a19f5 100644 --- a/js/nextsearch.v1.result.js +++ b/js/fulltextsearch.v1.result.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,23 +21,23 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ -/** global: next_settings */ +/** global: settings */ /** global: curr */ /** global: nav */ +/** @namespace result.provider */ +/** @namespace result.documents */ + var result = { displayResult: function (res) { - if (next_settings.resultContainer === null) { + if (settings.resultContainer === null) { return; } - nav.onResultDisplayed(); - var searchResult = res.result; if (searchResult.length === 0) { result.displayNoResult(); @@ -51,27 +51,26 @@ var result = { displayNoResult: function () { - next_settings.divNoResult.fadeTo(next_settings.delay_result, 1); - next_settings.resultContainer.find('.provider_header').each(function () { - $(this).fadeTo(next_settings.delay_result, 0); + settings.divNoResult.fadeTo(settings.delay_result, 1); + settings.resultContainer.find('.provider_header').each(function () { + $(this).fadeTo(settings.delay_result, 0); }); }, - /** @namespace result.provider */ - /** @namespace result.documents */ displayProviderResult: function (result) { - next_settings.divNoResult.fadeTo(next_settings.delay_result, 0); + settings.divNoResult.fadeTo(settings.delay_result, 0); var current = curr.getProviderResult(result.provider.id); var divProvider = nav.getDivProvider(result.provider.id, result.provider.name); - nav.managerDivProviderResult(divProvider.children('.provider_result'), result.documents, + nav.manageDivProviderNavigation(divProvider.children('.provider_navigation'), result.meta); + nav.manageDivProviderResult(divProvider.children('.provider_result'), result.documents, current.documents); - divProvider.slideDown(next_settings.delay_provider, function () { - $(this).fadeTo(next_settings.delay_provider, 1); + divProvider.slideDown(settings.delay_provider, function () { + $(this).fadeTo(settings.delay_provider, 1); }); curr.setProviderResult(result.provider.id, result); diff --git a/js/nextsearch.v1.searchbar.js b/js/fulltextsearch.v1.searchbar.js index 3a263a9..641ab95 100644 --- a/js/nextsearch.v1.searchbar.js +++ b/js/fulltextsearch.v1.searchbar.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,7 +21,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ @@ -30,12 +29,14 @@ /** global: api */ /** global: search */ /** global: result */ -/** global: nextSearch */ -/** global: next_settings */ +/** global: fullTextSearch */ +/** global: settings */ var searchbox = { searchTimeout: null, + search_more: null, + search_icon_more: null, search_icon_close: null, search_icon: null, search_input: null, @@ -51,13 +52,12 @@ var searchbar = { searchbox.search_div = $('<div>', {class: 'next_search_div'}); divHeaderRight.prepend(searchbox.search_div); - searchbox.search_icon = $('<div>', {class: 'icon-fullnextsearch'}); + searchbox.search_icon = $('<div>', {class: 'icon-fulltextsearch'}); searchbox.search_icon.css('background-image', - "url('/apps/fullnextsearch/img/fullnextsearch.svg')"); + "url('/apps/fulltextsearch/img/fulltextsearch.svg')"); searchbox.search_icon.fadeTo(0, 0.7); searchbox.search_div.append(searchbox.search_icon); - searchbox.search_form = $('<div>'); searchbox.search_form.fadeTo(0, 0); @@ -67,42 +67,62 @@ var searchbar = { }); searchbox.search_form.append(searchbox.search_input); - searchbox.search_icon_close = $('<div>', {class: 'icon-close-white icon-close-fullnextsearch'}); + searchbox.search_more = $('<div>', {class: 'search_more'}); + searchbox.search_more.fadeTo(0, 0); + + searchbox.search_icon_more = $('<div>', {class: 'icon-more-white icon-more-fulltextsearch'}); + searchbox.search_icon_more.fadeTo(0, 0); + searchbox.search_icon_more.on('click', function () { + if (curr.moreDisplayed) { + searchbox.search_more.stop().fadeTo(100, 0); + curr.moreDisplayed = false; + } else { + searchbox.search_more.stop().fadeTo(100, 1); + curr.moreDisplayed = true; + } + }); + searchbox.search_form.append(searchbox.search_icon_more); + + searchbox.search_icon_close = $('<div>', {class: 'icon-close-white icon-close-fulltextsearch'}); searchbox.search_icon_close.fadeTo(0, 0); searchbox.search_icon_close.on('click', function () { - next_settings.lockSearchbox = false; + settings.lockSearchbox = false; + searchbox.search_icon_more.stop().fadeTo(100, 0); searchbox.search_icon_close.stop().fadeTo(100, 0); + searchbox.search_more.stop().fadeTo(100, 0); + curr.moreDisplayed = false; searchbox.search_input.val(''); nav.onSearchReset(); }); searchbox.search_form.append(searchbox.search_icon_close); - searchbox.search_div.append(searchbox.search_form); - searchbox.search_div.hover(function () { + searchbox.search_form.hover(function () { searchbox.search_icon.stop().fadeTo(100, 0); searchbox.search_form.stop().fadeTo(100, 0.8); }, function () { - if (next_settings.lockSearchbox === true) { + if (settings.lockSearchbox === true) { return; } searchbox.search_form.stop().fadeTo(500, 0); searchbox.search_icon.stop().fadeTo(800, 0.7); }); + searchbox.search_div.append(searchbox.search_form); + searchbox.search_div.append(searchbox.search_more); searchbox.search_input.on('focus', function () { - next_settings.lockSearchbox = true; + settings.lockSearchbox = true; + searchbox.search_icon_more.stop().fadeTo(200, 1); searchbox.search_icon_close.stop().fadeTo(200, 1); }); searchbox.search_input.on('input', function () { - if ($(this).val() === '') { nav.onSearchReset(); } - if (next_settings.parentHasMethod('onEntryGenerated')) { - next_settings.parent.onEntryGenerated(); + if (settings.parentHasMethod('onEntryGenerated')) { + settings.parent.onEntryGenerated(); } if (searchbox.searchTimeout === null && searchbar.initSearch(false)) { @@ -112,9 +132,45 @@ var searchbar = { }, 2000); } }); + + fullTextSearch.options(settings.searchProviderId); + }, + + + onOptionsLoaded: function (result) { + searchbox.search_more.html(result[settings.searchProviderId]); + searchbox.search_more.find('INPUT').each(function () { + $(this).on('change', function () { + var search = searchbox.search_input.val(); + fullTextSearch.search({ + providers: settings.searchProviderId, + search: search, + page: curr.page, + options: searchbar.getSearchOptions(), + size: 20 + }); + }); + }) + }, + + + getSearchOptions: function () { + var options = {}; + searchbox.search_more.find('INPUT').each(function () { + var value = $(this).val(); + + if ($(this).attr('type') === 'checkbox' && !$(this).is(':checked')) { + value = ''; + } + + options[$(this).attr('id')] = value; + }); + + return options; }, + // TODO: do we really need this initSearch, or should we use the one from fulltextsearch.js !? initSearch: function (force) { var search = searchbox.search_input.val(); @@ -122,7 +178,19 @@ var searchbar = { return false; } - nextSearch.search(next_settings.searchProviderId, search, searchbar.searchResult); + if (curr.lastRequest === search) { + return true; + } + + curr.lastRequest = search; + + fullTextSearch.search({ + providers: settings.searchProviderId, + search: search, + page: curr.page, + options: searchbar.getSearchOptions(), + size: 20 + }); return true; } diff --git a/js/nextsearch.v1.settings.js b/js/fulltextsearch.v1.settings.js index b1a8fb8..7baa168 100644 --- a/js/nextsearch.v1.settings.js +++ b/js/fulltextsearch.v1.settings.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,13 +21,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: searchbar */ /** global: api */ -var next_settings = { +var settings = { parent: null, delay_provider: 300, @@ -39,6 +38,7 @@ var next_settings = { entryTemplateDefault: null, divNoResult: null, + generateDefaultTemplate: function () { var divLeft = $('<div>', {class: 'result_entry_left'}); @@ -53,7 +53,7 @@ var next_settings = { div.append(divLeft); div.append(divRight); - next_settings.entryTemplateDefault = $('<div>').append(div); + settings.entryTemplateDefault = $('<div>').append(div); }, @@ -61,29 +61,29 @@ var next_settings = { var div = $('<div>', {id: 'noresult'}); div.html('no result'); div.hide(); - next_settings.divNoResult = div; + settings.divNoResult = div; }, setEntryTemplateId: function (template, parent) { - next_settings.entryTemplate = template; - next_settings.parent = parent; + settings.entryTemplate = template; + settings.parent = parent; }, setResultContainerId: function (container) { - next_settings.resultContainer = container; - next_settings.resultContainer.prepend(next_settings.divNoResult); + settings.resultContainer = container; + settings.resultContainer.prepend(settings.divNoResult); }, addSearchBar: function (providerId) { - next_settings.searchProviderId = providerId; + settings.searchProviderId = providerId; searchbar.init(); }, parentHasMethod: function (method) { - if (next_settings.parent === null) { + if (settings.parent === null) { return false; } - return (typeof eval('next_settings.parent. ' + method) === "function"); + return (typeof eval('settings.parent. ' + method) === "function"); } }; diff --git a/js/fullnextsearch.js b/js/navigate.js index 9727694..e800338 100644 --- a/js/fullnextsearch.js +++ b/js/navigate.js @@ -1,11 +1,11 @@ /* - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,14 +21,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ /** global: OCA */ /** global: _ */ -const nextSearch = OCA.NextSearch.api; +const fullTextSearch = OCA.FullTextSearch.api; var elements = { @@ -48,8 +47,8 @@ Navigate.prototype = { init: function () { var self = this; - nextSearch.setEntryTemplateId($('#template_entry'), self); - nextSearch.setResultContainerId($('#search_result')); + fullTextSearch.setEntryTemplateId($('#template_entry'), self); + fullTextSearch.setResultContainerId($('#search_result')); elements.search_input = $('#search_input'); elements.search_submit = $('#search_submit'); @@ -80,8 +79,13 @@ Navigate.prototype = { if (!force && search.length < 3) { return false; } + var request = { + providers: 'all', + search: search, + page: curr.page + }; - nextSearch.search('_all', search, this.searchResult); + fullTextSearch.search(request, this.searchResult); return true; }, @@ -121,11 +125,11 @@ Navigate.prototype = { } }; -OCA.NextSearch.Example = Navigate; +OCA.FullTextSearch.Example = Navigate; $(document).ready(function () { - OCA.NextSearch.example = new Navigate(); + OCA.FullTextSearch.example = new Navigate(); }); diff --git a/js/personal.js b/js/personal.js deleted file mode 100644 index e69de29..0000000 --- a/js/personal.js +++ /dev/null diff --git a/lib/Api/v1/NextSearch.php b/lib/Api/v1/FullTextSearch.php index 71eefda..a40e4b4 100644 --- a/lib/Api/v1/NextSearch.php +++ b/lib/Api/v1/FullTextSearch.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,22 +22,21 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Api\v1; +namespace OCA\FullTextSearch\Api\v1; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Model\ExtendedIndex; -use OCA\FullNextSearch\Model\Index; -use OCA\FullNextSearch\Service\IndexService; -use OCA\FullNextSearch\Service\ProviderService; -use OCA\FullNextSearch\Service\SearchService; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Model\ExtendedIndex; +use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Service\IndexService; +use OCA\FullTextSearch\Service\ProviderService; +use OCA\FullTextSearch\Service\SearchService; use OCP\AppFramework\QueryException; use OCP\Util; -class NextSearch { +class FullTextSearch { const API_VERSION = [0, 1, 0]; @@ -59,7 +58,7 @@ class NextSearch { /** - * FullNextSearch::version(); + * FullTextSearch::version(); * * returns the current version of the API * @@ -74,13 +73,13 @@ class NextSearch { * */ public static function addJavascriptAPI() { - Util::addStyle(Application::APP_NAME, 'nextsearch'); - Util::addScript(Application::APP_NAME, 'nextsearch.v1.api'); - Util::addScript(Application::APP_NAME, 'nextsearch.v1.settings'); - Util::addScript(Application::APP_NAME, 'nextsearch.v1.searchbar'); - Util::addScript(Application::APP_NAME, 'nextsearch.v1.result'); - Util::addScript(Application::APP_NAME, 'nextsearch.v1.navigation'); - Util::addScript(Application::APP_NAME, 'nextsearch.v1'); + Util::addStyle(Application::APP_NAME, 'fulltextsearch'); + Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.api'); + Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.settings'); + Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.searchbar'); + Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.result'); + Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.navigation'); + Util::addScript(Application::APP_NAME, 'fulltextsearch.v1'); } diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 04db022..1ca4e76 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,18 +22,18 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\AppInfo; +namespace OCA\FullTextSearch\AppInfo; -use OCA\FullNextSearch\Capabilities; -use OCA\FullNextSearch\Service\ConfigService; +use OCA\FullTextSearch\Capabilities; +use OCA\FullTextSearch\Service\ConfigService; use OCP\AppFramework\App; +use OCP\AppFramework\QueryException; class Application extends App { - const APP_NAME = 'fullnextsearch'; + const APP_NAME = 'fulltextsearch'; /** * @param array $params @@ -58,7 +58,7 @@ class Application extends App { /** * Register Navigation Tab * - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function registerNavigation() { @@ -71,20 +71,20 @@ class Application extends App { $this->getContainer() ->getServer() ->getNavigationManager() - ->add($this->fullNextSearchNavigation()); + ->add($this->fullTextSearchNavigation()); } - public function fullNextSearchNavigation() { + public function fullTextSearchNavigation() { $urlGen = \OC::$server->getURLGenerator(); $navName = \OC::$server->getL10N(self::APP_NAME) - ->t('Full Next Search'); + ->t('Full text search'); return [ 'id' => self::APP_NAME, 'order' => 5, - 'href' => $urlGen->linkToRoute('fullnextsearch.Navigation.navigate'), - 'icon' => $urlGen->imagePath(self::APP_NAME, 'fullnextsearch.svg'), + 'href' => $urlGen->linkToRoute('fulltextsearch.Navigation.navigate'), + 'icon' => $urlGen->imagePath(self::APP_NAME, 'fulltextsearch.svg'), 'name' => $navName ]; } diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 29c8807..dbfdd5e 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -1,17 +1,40 @@ <?php +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ - -namespace OCA\FullNextSearch; +namespace OCA\FullTextSearch; use Exception; -use OCA\FullNextSearch\Service\ProviderService; +use OCA\FullTextSearch\Service\ProviderService; use OCP\Capabilities\ICapability; /** * Class Capabilities * - * @package OCA\FullNextSearch + * @package OCA\FullTextSearch */ class Capabilities implements ICapability { @@ -34,7 +57,7 @@ class Capabilities implements ICapability { * Return this classes capabilities * * Result to be expected: - * {"fullnextsearch":{"remote":true,"providers":[{"id":"files","name":"Files"}]}} + * {"fulltextsearch":{"remote":true,"providers":[{"id":"files","name":"Files"}]}} * * if 'remote' is false, it means administrator does not allow search request with no CSRF check. * @@ -50,7 +73,7 @@ class Capabilities implements ICapability { $providers = $this->providerService->getConfiguredProviders(); return [ - 'fullnextsearch' => [ + 'fulltextsearch' => [ 'remote' => true, 'providers' => $this->providerService->serialize($providers) ] diff --git a/lib/Command/Index.php b/lib/Command/Index.php index 5e26822..2c2d62b 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,20 +22,19 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Command; +namespace OCA\FullTextSearch\Command; use Exception; -use OCA\FullNextSearch\INextSearchProvider; -use OCA\FullNextSearch\Model\ExtendedBase; -use OCA\FullNextSearch\Model\Runner; -use OCA\FullNextSearch\Service\IndexService; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\PlatformService; -use OCA\FullNextSearch\Service\ProviderService; -use OCA\FullNextSearch\Service\RunningService; +use OCA\FullTextSearch\IFullTextSearchProvider; +use OCA\FullTextSearch\Model\ExtendedBase; +use OCA\FullTextSearch\Model\Runner; +use OCA\FullTextSearch\Service\IndexService; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\PlatformService; +use OCA\FullTextSearch\Service\ProviderService; +use OCA\FullTextSearch\Service\RunningService; use OCP\IUserManager; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -95,7 +94,7 @@ class Index extends ExtendedBase { */ protected function configure() { parent::configure(); - $this->setName('fullnextsearch:index') + $this->setName('fulltextsearch:index') ->setDescription('Index files'); } @@ -130,11 +129,11 @@ class Index extends ExtendedBase { /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * * @throws Exception */ - private function indexProvider(INextSearchProvider $provider) { + private function indexProvider(IFullTextSearchProvider $provider) { $platform = $this->platformService->getPlatform(); $platform->initializeIndex($provider); $platform->setRunner($this->runner); diff --git a/lib/Command/Live.php b/lib/Command/Live.php index 76b1414..01c6f4c 100644 --- a/lib/Command/Live.php +++ b/lib/Command/Live.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,21 +22,20 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Command; +namespace OCA\FullTextSearch\Command; use Exception; -use OCA\FullNextSearch\Exceptions\InterruptException; -use OCA\FullNextSearch\Exceptions\TickDoesNotExistException; -use OCA\FullNextSearch\Model\ExtendedBase; -use OCA\FullNextSearch\Model\Runner; -use OCA\FullNextSearch\Service\IndexService; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\PlatformService; -use OCA\FullNextSearch\Service\ProviderService; -use OCA\FullNextSearch\Service\RunningService; +use OCA\FullTextSearch\Exceptions\InterruptException; +use OCA\FullTextSearch\Exceptions\TickDoesNotExistException; +use OCA\FullTextSearch\Model\ExtendedBase; +use OCA\FullTextSearch\Model\Runner; +use OCA\FullTextSearch\Service\IndexService; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\PlatformService; +use OCA\FullTextSearch\Service\ProviderService; +use OCA\FullTextSearch\Service\RunningService; use OCP\IUserManager; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -96,7 +95,7 @@ class Live extends ExtendedBase { */ protected function configure() { parent::configure(); - $this->setName('fullnextsearch:live') + $this->setName('fulltextsearch:live') ->setDescription('Index files'); } diff --git a/lib/Command/Reset.php b/lib/Command/Reset.php index ce895e9..92505dc 100644 --- a/lib/Command/Reset.php +++ b/lib/Command/Reset.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,17 +22,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Command; +namespace OCA\FullTextSearch\Command; use Exception; -use OCA\FullNextSearch\Model\ExtendedBase; -use OCA\FullNextSearch\Model\Runner; -use OCA\FullNextSearch\Service\IndexService; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\RunningService; +use OCA\FullTextSearch\Model\ExtendedBase; +use OCA\FullTextSearch\Model\Runner; +use OCA\FullTextSearch\Service\IndexService; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\RunningService; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -70,7 +69,7 @@ class Reset extends ExtendedBase { protected function configure() { parent::configure(); - $this->setName('fullnextsearch:reset') + $this->setName('fulltextsearch:reset') ->setDescription('reset index') ->addArgument('provider', InputArgument::OPTIONAL, 'provider'); } @@ -85,7 +84,6 @@ class Reset extends ExtendedBase { */ protected function execute(InputInterface $input, OutputInterface $output) { - try { $this->runner->sourceIsCommandLine($this, $output); $this->runner->start(); diff --git a/lib/Command/Search.php b/lib/Command/Search.php index 7491536..b3eab78 100644 --- a/lib/Command/Search.php +++ b/lib/Command/Search.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,17 +22,17 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Command; +namespace OCA\FullTextSearch\Command; use Exception; use OC\Core\Command\Base; -use OCA\FullNextSearch\Model\IndexDocument; -use OCA\FullNextSearch\Model\SearchResult; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\SearchService; +use OCA\FullTextSearch\Model\IndexDocument; +use OCA\FullTextSearch\Model\SearchRequest; +use OCA\FullTextSearch\Model\SearchResult; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\SearchService; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -65,7 +65,7 @@ class Search extends Base { protected function configure() { parent::configure(); - $this->setName('fullnextsearch:search') + $this->setName('fulltextsearch:search') ->setDescription('Search something') ->addArgument('user', InputArgument::OPTIONAL, 'user') ->addArgument('string', InputArgument::OPTIONAL, 'needle'); @@ -83,10 +83,15 @@ class Search extends Base { protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('search'); + $request = SearchRequest::fromArray( + [ + 'providers' => 'all', + 'search' => $input->getArgument('string') + ] + ); + try { - $result = $this->searchService->search( - 'files', $input->getArgument('user'), $input->getArgument('string') - ); + $result = $this->searchService->search($input->getArgument('user'), $request); foreach ($result as $searchResult) { $this->displaySearchResult($searchResult); diff --git a/lib/Command/Stop.php b/lib/Command/Stop.php index 3dbda2c..63b039b 100644 --- a/lib/Command/Stop.php +++ b/lib/Command/Stop.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,14 +22,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Command; +namespace OCA\FullTextSearch\Command; -use OCA\FullNextSearch\Model\ExtendedBase; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\RunningService; +use OCA\FullTextSearch\Model\ExtendedBase; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\RunningService; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -59,7 +58,7 @@ class Stop extends ExtendedBase { protected function configure() { parent::configure(); - $this->setName('fullnextsearch:stop') + $this->setName('fulltextsearch:stop') ->setDescription('stop all indexing'); } diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index e5e304b..c123aff 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,16 +22,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Controller; +namespace OCA\FullTextSearch\Controller; use Exception; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Model\SearchResult; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\SearchService; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Model\SearchRequest; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\SearchService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; @@ -66,13 +65,12 @@ class ApiController extends Controller { * @NoAdminRequired * @NoSubAdminRequired * - * @param string $providerId - * @param string $search + * @param string $request * * @return DataResponse */ - public function search($providerId, $search) { - return $this->searchDocuments($providerId, $search); + public function search($request) { + return $this->searchDocuments(SearchRequest::fromJSON($request)); } @@ -81,58 +79,36 @@ class ApiController extends Controller { * @NoSubAdminRequired * @NoCSRFRequired * - * @param string $providerId - * @param string $search + * @param string $request * * @return DataResponse */ - public function searchFromRemote($providerId, $search) { - return $this->searchDocuments($providerId, $search); + public function searchFromRemote($request) { + return $this->searchDocuments(SearchRequest::fromJSON($request)); } /** - * @param string $providerId - * @param string $search + * @param SearchRequest $request * * @return DataResponse */ - private function searchDocuments($providerId, $search) { + private function searchDocuments(SearchRequest $request) { try { - $result = $this->searchService->search($providerId, null, $search); - $meta = $this->generateMeta($result); + $result = $this->searchService->search(null, $request); return $this->success( - ['search' => $search, 'provider' => $providerId, 'result' => $result, 'meta' => $meta] + ['request' => $request, 'result' => $result] ); } catch (Exception $e) { return $this->fail( - ['search' => $search, 'provider' => $providerId, 'error' => $e->getMessage()] + ['request' => $request, 'error' => $e->getMessage()] ); } } /** - * @param SearchResult[] $result - * - * @return array<string,integer> - */ - private function generateMeta($result) { - - $meta = [ - 'size' => 0 - ]; - - foreach ($result as $searchResult) { - $meta['size'] += $searchResult->getSize(); - } - - return $meta; - } - - - /** * @param $data * * @return DataResponse diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index ff3d64e..d18e600 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,14 +22,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Controller; +namespace OCA\FullTextSearch\Controller; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Service\ConfigService; -use OCA\FullNextSearch\Service\MiscService; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 80d2631..52e6b72 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,16 +22,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Controller; +namespace OCA\FullTextSearch\Controller; use Exception; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Service\ConfigService; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\SettingsService; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\SettingsService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; diff --git a/lib/Controller/TemplatesController.php b/lib/Controller/TemplatesController.php new file mode 100644 index 0000000..bef23e2 --- /dev/null +++ b/lib/Controller/TemplatesController.php @@ -0,0 +1,100 @@ +<?php +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\FullTextSearch\Controller; + +use Exception; +use OC\AppFramework\Http; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Exceptions\ProviderDoesNotExistException; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\ProviderService; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\IConfig; +use OCP\IRequest; + +class TemplatesController extends Controller { + + /** @var IConfig */ + private $config; + + /** @var ConfigService */ + private $configService; + + /** @var ProviderService */ + private $providerService; + + /** @var MiscService */ + private $miscService; + + + /** + * TemplatesController constructor. + * + * @param IRequest $request + * @param IConfig $config + * @param ConfigService $configService + * @param ProviderService $providerService + * @param MiscService $miscService + */ + public function __construct( + IRequest $request, IConfig $config, ConfigService $configService, + ProviderService $providerService, MiscService $miscService + ) { + parent::__construct(Application::APP_NAME, $request); + $this->config = $config; + $this->configService = $configService; + $this->providerService = $providerService; + $this->miscService = $miscService; + } + + + /** + * @NoAdminRequired + * @NoSubAdminRequired + * + * @param $providerId + * + * @return DataResponse + * @throws Exception + * @throws ProviderDoesNotExistException + */ + public function getOptionsPanel($providerId) { + $provider = $this->providerService->getProvider($providerId); + + $ret = []; + $tmpl = + new TemplateResponse($provider->getAppId(), $provider->getOptionsTemplate(), [], 'blank'); + $ret[$providerId] = $tmpl->render(); + + return new DataResponse($ret, Http::STATUS_OK); + } + + +}
\ No newline at end of file diff --git a/lib/Cron/Index.php b/lib/Cron/Index.php index d16afdd..b0c3d06 100644 --- a/lib/Cron/Index.php +++ b/lib/Cron/Index.php @@ -1,13 +1,13 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -23,25 +23,24 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Cron; +namespace OCA\FullTextSearch\Cron; use Exception; use OC\BackgroundJob\TimedJob; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Exceptions\InterruptException; -use OCA\FullNextSearch\Exceptions\PlatformNotSelectedException; -use OCA\FullNextSearch\Model\Runner; -use OCA\FullNextSearch\Service\IndexService; -use OCA\FullNextSearch\Service\MiscService; -use OCA\FullNextSearch\Service\PlatformService; -use OCA\FullNextSearch\Service\ProviderService; -use OCA\FullNextSearch\Service\RunningService; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Exceptions\InterruptException; +use OCA\FullTextSearch\Model\Runner; +use OCA\FullTextSearch\Service\IndexService; +use OCA\FullTextSearch\Service\MiscService; +use OCA\FullTextSearch\Service\PlatformService; +use OCA\FullTextSearch\Service\ProviderService; +use OCA\FullTextSearch\Service\RunningService; use OCP\AppFramework\QueryException; use OCP\IUserManager; + class Index extends TimedJob { /** @var IUserManager */ @@ -70,8 +69,6 @@ class Index extends TimedJob { /** * @param $argument * - * @throws Exception - * @throws InterruptException * @throws QueryException */ protected function run($argument) { @@ -87,7 +84,6 @@ class Index extends TimedJob { $this->providerService = $c->query(ProviderService::class); $this->miscService = $c->query(MiscService::class); - try { $this->runner->start(); $this->liveCycle(); diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index b879bae..2eb3a26 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,24 +22,23 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Db; +namespace OCA\FullTextSearch\Db; use Doctrine\DBAL\Query\QueryBuilder; -use OCA\FullNextSearch\Model\Index; -use OCA\FullNextSearch\Service\ConfigService; -use OCA\FullNextSearch\Service\MiscService; +use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IL10N; class CoreRequestBuilder { - const TABLE_INDEXES = 'fullnextsearch_indexes'; - const TABLE_TICKS = 'fullnextsearch_ticks'; + const TABLE_INDEXES = 'fulltextsearch_indexes'; + const TABLE_TICKS = 'fulltextsearch_ticks'; /** @var IDBConnection */ protected $dbConnection; diff --git a/lib/Db/IndexesRequest.php b/lib/Db/IndexesRequest.php index c070dfa..a4a8dca 100644 --- a/lib/Db/IndexesRequest.php +++ b/lib/Db/IndexesRequest.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,16 +22,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Db; +namespace OCA\FullTextSearch\Db; -use OCA\FullNextSearch\Exceptions\IndexDoesNotExistException; -use OCA\FullNextSearch\INextSearchProvider; -use OCA\FullNextSearch\Model\ExtendedIndex; -use OCA\FullNextSearch\Model\Index; +use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException; +use OCA\FullTextSearch\IFullTextSearchProvider; +use OCA\FullTextSearch\Model\ExtendedIndex; +use OCA\FullTextSearch\Model\Index; class IndexesRequest extends IndexesRequestBuilder { @@ -175,11 +174,11 @@ class IndexesRequest extends IndexesRequestBuilder { /** * return list of last indexes from a providerId. * - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * * @return Index[] */ - public function getIndexesFromProvider(INextSearchProvider $provider) { + public function getIndexesFromProvider(IFullTextSearchProvider $provider) { $qb = $this->getIndexesSelectSql(); $this->limitToProviderId($qb, $provider->getId()); diff --git a/lib/Db/IndexesRequestBuilder.php b/lib/Db/IndexesRequestBuilder.php index bd62f23..53d8b62 100644 --- a/lib/Db/IndexesRequestBuilder.php +++ b/lib/Db/IndexesRequestBuilder.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,15 +22,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Db; +namespace OCA\FullTextSearch\Db; -use OCA\FullNextSearch\Model\ExtendedIndex; -use OCA\FullNextSearch\Service\ConfigService; -use OCA\FullNextSearch\Service\MiscService; +use OCA\FullTextSearch\Model\ExtendedIndex; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IL10N; diff --git a/lib/Db/TickRequest.php b/lib/Db/TickRequest.php index 3e4b589..ba6dfe5 100644 --- a/lib/Db/TickRequest.php +++ b/lib/Db/TickRequest.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,15 +22,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Db; +namespace OCA\FullTextSearch\Db; -use OCA\FullNextSearch\Exceptions\TickDoesNotExistException; -use OCA\FullNextSearch\Model\ExtendedTick; -use OCA\FullNextSearch\Model\Tick; +use OCA\FullTextSearch\Exceptions\TickDoesNotExistException; +use OCA\FullTextSearch\Model\ExtendedTick; +use OCA\FullTextSearch\Model\Tick; class TickRequest extends TickRequestBuilder { diff --git a/lib/Db/TickRequestBuilder.php b/lib/Db/TickRequestBuilder.php index ecf44e7..bbce090 100644 --- a/lib/Db/TickRequestBuilder.php +++ b/lib/Db/TickRequestBuilder.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,15 +22,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Db; +namespace OCA\FullTextSearch\Db; -use OCA\FullNextSearch\Model\ExtendedTick; -use OCA\FullNextSearch\Service\ConfigService; -use OCA\FullNextSearch\Service\MiscService; +use OCA\FullTextSearch\Model\ExtendedTick; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IL10N; diff --git a/lib/Exceptions/DatabaseException.php b/lib/Exceptions/DatabaseException.php index e524f57..b285337 100644 --- a/lib/Exceptions/DatabaseException.php +++ b/lib/Exceptions/DatabaseException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class DatabaseException extends \Exception { diff --git a/lib/Exceptions/EmptySearchException.php b/lib/Exceptions/EmptySearchException.php index 98da469..cfec8d9 100644 --- a/lib/Exceptions/EmptySearchException.php +++ b/lib/Exceptions/EmptySearchException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class EmptySearchException extends \Exception { diff --git a/lib/Exceptions/IndexDoesNotExistException.php b/lib/Exceptions/IndexDoesNotExistException.php index fecb3cf..d113814 100644 --- a/lib/Exceptions/IndexDoesNotExistException.php +++ b/lib/Exceptions/IndexDoesNotExistException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class IndexDoesNotExistException extends \Exception { diff --git a/lib/Exceptions/InterruptException.php b/lib/Exceptions/InterruptException.php index cdd0353..6a6f680 100644 --- a/lib/Exceptions/InterruptException.php +++ b/lib/Exceptions/InterruptException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class InterruptException extends \Exception { diff --git a/lib/Exceptions/NoResultException.php b/lib/Exceptions/NoResultException.php index 8588ae9..5bcefd7 100644 --- a/lib/Exceptions/NoResultException.php +++ b/lib/Exceptions/NoResultException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class NoResultException extends \Exception { diff --git a/lib/Exceptions/PlatformDoesNotExistException.php b/lib/Exceptions/PlatformDoesNotExistException.php index c38277a..e69e03a 100644 --- a/lib/Exceptions/PlatformDoesNotExistException.php +++ b/lib/Exceptions/PlatformDoesNotExistException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class PlatformDoesNotExistException extends \Exception { diff --git a/lib/Exceptions/PlatformIsNotCompatibleException.php b/lib/Exceptions/PlatformIsNotCompatibleException.php index 79cff1e..ee7ebe2 100644 --- a/lib/Exceptions/PlatformIsNotCompatibleException.php +++ b/lib/Exceptions/PlatformIsNotCompatibleException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class PlatformIsNotCompatibleException extends \Exception { diff --git a/lib/Exceptions/PlatformMustBeSingleException.php b/lib/Exceptions/PlatformMustBeSingleException.php index 7e09e32..04b386e 100644 --- a/lib/Exceptions/PlatformMustBeSingleException.php +++ b/lib/Exceptions/PlatformMustBeSingleException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class PlatformMustBeSingleException extends \Exception { diff --git a/lib/Exceptions/PlatformNotDefinedException.php b/lib/Exceptions/PlatformNotDefinedException.php index f707e1d..2f8ff37 100644 --- a/lib/Exceptions/PlatformNotDefinedException.php +++ b/lib/Exceptions/PlatformNotDefinedException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class PlatformNotDefinedException extends \Exception { diff --git a/lib/Exceptions/PlatformNotSelectedException.php b/lib/Exceptions/PlatformNotSelectedException.php index 0217dc9..3c7025e 100644 --- a/lib/Exceptions/PlatformNotSelectedException.php +++ b/lib/Exceptions/PlatformNotSelectedException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class PlatformNotSelectedException extends \Exception { diff --git a/lib/Exceptions/ProviderDoesNotExistException.php b/lib/Exceptions/ProviderDoesNotExistException.php index b3c01dd..01f51a1 100644 --- a/lib/Exceptions/ProviderDoesNotExistException.php +++ b/lib/Exceptions/ProviderDoesNotExistException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class ProviderDoesNotExistException extends \Exception { diff --git a/lib/Exceptions/ProviderIsNotCompatibleException.php b/lib/Exceptions/ProviderIsNotCompatibleException.php index 7e3914b..b0d7cca 100644 --- a/lib/Exceptions/ProviderIsNotCompatibleException.php +++ b/lib/Exceptions/ProviderIsNotCompatibleException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class ProviderIsNotCompatibleException extends \Exception { diff --git a/lib/Exceptions/ProviderIsNotUniqueException.php b/lib/Exceptions/ProviderIsNotUniqueException.php index dd5d0fc..13a1032 100644 --- a/lib/Exceptions/ProviderIsNotUniqueException.php +++ b/lib/Exceptions/ProviderIsNotUniqueException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class ProviderIsNotUniqueException extends \Exception { diff --git a/lib/Exceptions/ProviderOptionsDoesNotExistException.php b/lib/Exceptions/ProviderOptionsDoesNotExistException.php index c3e96c6..305f311 100644 --- a/lib/Exceptions/ProviderOptionsDoesNotExistException.php +++ b/lib/Exceptions/ProviderOptionsDoesNotExistException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class ProviderOptionsDoesNotExistException extends \Exception { diff --git a/lib/Exceptions/RunnerAlreadyUpException.php b/lib/Exceptions/RunnerAlreadyUpException.php index 43710cd..4571740 100644 --- a/lib/Exceptions/RunnerAlreadyUpException.php +++ b/lib/Exceptions/RunnerAlreadyUpException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class RunnerAlreadyUpException extends \Exception { diff --git a/lib/Exceptions/TickDoesNotExistException.php b/lib/Exceptions/TickDoesNotExistException.php index 9eb259d..7edbc17 100644 --- a/lib/Exceptions/TickDoesNotExistException.php +++ b/lib/Exceptions/TickDoesNotExistException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class TickDoesNotExistException extends \Exception { diff --git a/lib/Exceptions/TickIsNotAliveException.php b/lib/Exceptions/TickIsNotAliveException.php index 4b96795..338a804 100644 --- a/lib/Exceptions/TickIsNotAliveException.php +++ b/lib/Exceptions/TickIsNotAliveException.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Exceptions; +namespace OCA\FullTextSearch\Exceptions; class TickIsNotAliveException extends \Exception { diff --git a/lib/INextSearchPlatform.php b/lib/IFullTextSearchPlatform.php index 686b6ea..98b2561 100644 --- a/lib/INextSearchPlatform.php +++ b/lib/IFullTextSearchPlatform.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,19 +22,19 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch; +namespace OCA\FullTextSearch; -use OCA\FullNextSearch\Model\DocumentAccess; -use OCA\FullNextSearch\Model\Index; -use OCA\FullNextSearch\Model\IndexDocument; -use OCA\FullNextSearch\Model\Runner; -use OCA\FullNextSearch\Model\SearchResult; +use OCA\FullTextSearch\Model\DocumentAccess; +use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Model\IndexDocument; +use OCA\FullTextSearch\Model\Runner; +use OCA\FullTextSearch\Model\SearchRequest; +use OCA\FullTextSearch\Model\SearchResult; -interface INextSearchPlatform { +interface IFullTextSearchPlatform { /** * must returns a unique Id @@ -68,15 +68,15 @@ interface INextSearchPlatform { /** * Init an index regarding a provider * - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider */ - public function initializeIndex(INextSearchProvider $provider); + public function initializeIndex(IFullTextSearchProvider $provider); /** * Reset the indexes * - * @param INextSearchProvider|null $provider + * @param IFullTextSearchProvider|null $provider */ public function removeIndex($provider); @@ -85,30 +85,30 @@ interface INextSearchPlatform { * $command can be null. instanceof ExtendedBase if the method is called from CLI. * Use it to echo whatever and intercept ^C * - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * @param IndexDocument[] $documents * * @return Index[] */ - public function indexDocuments(INextSearchProvider $provider, $documents); + public function indexDocuments(IFullTextSearchProvider $provider, $documents); /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * @param IndexDocument $document * * @return Index */ - public function indexDocument(INextSearchProvider $provider, IndexDocument $document); + public function indexDocument(IFullTextSearchProvider $provider, IndexDocument $document); /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * @param DocumentAccess $access - * @param string $string + * @param SearchRequest $request * * @return SearchResult */ - public function searchDocuments(INextSearchProvider $provider, DocumentAccess $access, $string); + public function searchDocuments(IFullTextSearchProvider $provider, DocumentAccess $access, $request); }
\ No newline at end of file diff --git a/lib/INextSearchProvider.php b/lib/IFullTextSearchProvider.php index 7b4b51e..1c45be1 100644 --- a/lib/INextSearchProvider.php +++ b/lib/IFullTextSearchProvider.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,18 +21,19 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch; +namespace OCA\FullTextSearch; -use OCA\FullNextSearch\Model\Index; -use OCA\FullNextSearch\Model\IndexDocument; -use OCA\FullNextSearch\Model\Runner; -use OCA\FullNextSearch\Model\SearchResult; +use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Model\IndexDocument; +use OCA\FullTextSearch\Model\Runner; +use OCA\FullTextSearch\Model\SearchRequest; +use OCA\FullTextSearch\Model\SearchResult; +use OCP\AppFramework\Http\TemplateResponse; -interface INextSearchProvider { +interface IFullTextSearchProvider { /** @@ -44,6 +45,14 @@ interface INextSearchProvider { /** + * return a appId of the Provider + * + * @return string + */ + public function getAppId(); + + + /** * return a display name of the Provider * * @return string @@ -52,6 +61,12 @@ interface INextSearchProvider { /** + * @return string + */ + public function getOptionsTemplate(); + + + /** * Called when loading the provider */ public function loadProvider(); @@ -95,39 +110,46 @@ interface INextSearchProvider { /** - * @param INextSearchPlatform $platform + * @param IFullTextSearchPlatform $platform */ - public function onInitializingIndex(INextSearchPlatform $platform); + public function onInitializingIndex(IFullTextSearchPlatform $platform); /** - * @param INextSearchPlatform $platform + * @param IFullTextSearchPlatform $platform * @param array $arr */ - public function onIndexingDocument(INextSearchPlatform $platform, &$arr); + public function onIndexingDocument(IFullTextSearchPlatform $platform, &$arr); /** - * @param INextSearchPlatform $platform + * @param IFullTextSearchPlatform $platform */ - public function onRemovingIndex(INextSearchPlatform $platform); + public function onRemovingIndex(IFullTextSearchPlatform $platform); /** - * @param INextSearchPlatform $platform + * @param IFullTextSearchPlatform $platform + * @param SearchRequest $request * @param array $arr * * @return array */ - public function onSearchingQuery(INextSearchPlatform $platform, &$arr); + public function onSearchingQuery(IFullTextSearchPlatform $platform, SearchRequest $request, &$arr); + + + /** + * before a search, improve the request + * + * @param SearchRequest $searchRequest + */ + public function improveSearchRequest(SearchRequest $searchRequest); /** * after a search, improve the result * * @param SearchResult $searchResult - * - * @return mixed */ public function improveSearchResult(SearchResult $searchResult); diff --git a/lib/Model/DocumentAccess.php b/lib/Model/DocumentAccess.php index c2b542a..7c61b53 100644 --- a/lib/Model/DocumentAccess.php +++ b/lib/Model/DocumentAccess.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class DocumentAccess implements \JsonSerializable { diff --git a/lib/Model/ExtendedBase.php b/lib/Model/ExtendedBase.php index 6f7f3da..2b5c25e 100644 --- a/lib/Model/ExtendedBase.php +++ b/lib/Model/ExtendedBase.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,14 +22,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; use OC\Core\Command\Base; -use OCA\FullNextSearch\Exceptions\InterruptException; +use OCA\FullTextSearch\Exceptions\InterruptException; use Symfony\Component\Console\Output\OutputInterface; diff --git a/lib/Model/ExtendedIndex.php b/lib/Model/ExtendedIndex.php index 9dea110..a26377e 100644 --- a/lib/Model/ExtendedIndex.php +++ b/lib/Model/ExtendedIndex.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,12 +21,11 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class ExtendedIndex extends Index { diff --git a/lib/Model/ExtendedTick.php b/lib/Model/ExtendedTick.php index 806bdf9..8c70c6c 100644 --- a/lib/Model/ExtendedTick.php +++ b/lib/Model/ExtendedTick.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,11 +22,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class ExtendedTick extends Tick { diff --git a/lib/Model/Index.php b/lib/Model/Index.php index 4cf1b2c..c9525ca 100644 --- a/lib/Model/Index.php +++ b/lib/Model/Index.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class Index implements \JsonSerializable { diff --git a/lib/Model/IndexDocument.php b/lib/Model/IndexDocument.php index 01fabcb..5f27b76 100644 --- a/lib/Model/IndexDocument.php +++ b/lib/Model/IndexDocument.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,11 +21,10 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class IndexDocument implements \JsonSerializable { diff --git a/lib/Model/ProviderIndexes.php b/lib/Model/ProviderIndexes.php index dc838c2..8b747fc 100644 --- a/lib/Model/ProviderIndexes.php +++ b/lib/Model/ProviderIndexes.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,11 +22,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class ProviderIndexes { diff --git a/lib/Model/Runner.php b/lib/Model/Runner.php index cf6c15b..7dea51f 100644 --- a/lib/Model/Runner.php +++ b/lib/Model/Runner.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,19 +21,18 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; use Exception; -use OCA\FullNextSearch\Exceptions\InterruptException; -use OCA\FullNextSearch\Exceptions\RunnerAlreadyUpException; -use OCA\FullNextSearch\Exceptions\TickDoesNotExistException; -use OCA\FullNextSearch\Exceptions\TickIsNotAliveException; -use OCA\FullNextSearch\Service\RunningService; +use OCA\FullTextSearch\Exceptions\InterruptException; +use OCA\FullTextSearch\Exceptions\RunnerAlreadyUpException; +use OCA\FullTextSearch\Exceptions\TickDoesNotExistException; +use OCA\FullTextSearch\Exceptions\TickIsNotAliveException; +use OCA\FullTextSearch\Service\RunningService; use Symfony\Component\Console\Output\OutputInterface; diff --git a/lib/Model/SearchRequest.php b/lib/Model/SearchRequest.php new file mode 100644 index 0000000..4c535eb --- /dev/null +++ b/lib/Model/SearchRequest.php @@ -0,0 +1,243 @@ +<?php +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\FullTextSearch\Model; + +use OCA\FullTextSearch\Service\MiscService; + +class SearchRequest implements \JsonSerializable { + + /** @var array */ + private $providers; + + /** @var string */ + private $search; + + /** @var int */ + private $page = 1; + + /** @var int */ + private $size = 10; + + /** @var string */ + private $author; + + /** @var array */ + private $tags; + + /** @var array */ + private $options; + + + /** + * SearchRequest constructor. + */ + public function __construct() { + } + + + /** + * @return array + */ + public function getProviders() { + return $this->providers; + } + + /** + * @param string|array $providers + */ + public function setProviders($providers) { + if (!is_array($providers)) { + $providers = [$providers]; + } + + $this->providers = $providers; + } + + + /** + * @return string + */ + public function getAuthor() { + return $this->author; + } + + /** + * @param string $author + */ + public function setAuthor($author) { + $this->author = $author; + } + + + /** + * @return string + */ + public function getSearch() { + return $this->search; + } + + /** + * @param string $search + */ + public function setSearch($search) { + $this->search = $search; + } + + public function cleanSearch() { + $this->search = trim(str_replace(' ', ' ', $this->search)); + } + + + /** + * @return int + */ + public function getPage() { + return $this->page; + } + + /** + * @param int $page + */ + public function setPage($page) { + if ($page < 1) { + $page = 1; + } + + $this->page = $page; + } + + + /** + * @return int + */ + public function getSize() { + return $this->size; + } + + /** + * @param int $size + */ + public function setSize($size) { + $this->size = $size; + } + + + /** + * @return array + */ + public function getOptions() { + return $this->options; + } + + /** + * @param array $options + */ + public function setOptions($options) { + $this->options = $options; + } + + /** + * @param string $option + * + * @return mixed|string + */ + public function getOption($option) { + if (array_key_exists($option, $this->options)) { + return $this->options[$option]; + } + + return ''; + } + + + /** + * @param string $tag + */ + public function addTag($tag) { + $this->tags[] = $tag; + } + + /** + * @return array + */ + public function getTags() { + return $this->tags; + } + + /** + * @param array $tags + */ + public function setTags($tags) { + $this->tags = $tags; + } + + + /** + * @return array + */ + public function jsonSerialize() { + return [ + 'providers' => $this->getProviders(), + 'author' => $this->getAuthor(), + 'search' => $this->getSearch(), + 'page' => $this->getPage(), + 'size' => $this->getSize(), + 'options' => $this->getOptions(), + 'tags' => $this->getTags() + ]; + } + + + /** + * @param string $json + * + * @return SearchRequest + */ + public static function fromJSON($json) { + return self::fromArray(json_decode($json, true)); + } + + /** + * @param array $arr + * + * @return SearchRequest + */ + public static function fromArray($arr) { + $request = new SearchRequest(); + $request->setProviders($arr['providers']); + $request->setAuthor(MiscService::get($arr, 'author', '')); + $request->setSearch(MiscService::get($arr, 'search', '')); + $request->setPage(MiscService::get($arr, 'page', 0)); + $request->setSize(MiscService::get($arr, 'size', 10)); + $request->setOptions(MiscService::get($arr, 'options', [])); + $request->setTags(MiscService::get($arr, 'tags', [])); + + return $request; + } + + +}
\ No newline at end of file diff --git a/lib/Model/SearchResult.php b/lib/Model/SearchResult.php index 46f97f6..b364123 100644 --- a/lib/Model/SearchResult.php +++ b/lib/Model/SearchResult.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,12 +22,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; -use OCA\FullNextSearch\INextSearchProvider; +use OCA\FullTextSearch\IFullTextSearchProvider; class SearchResult implements \JsonSerializable { @@ -37,9 +36,25 @@ class SearchResult implements \JsonSerializable { /** @var string */ private $rawResult; - /** @var INextSearchProvider */ + /** @var IFullTextSearchProvider */ private $provider; + /** @var int */ + private $total; + + /** @var int */ + private $maxScore; + + /** @var int */ + private $time; + + /** @var boolean */ + private $timedOut; + + /** @var SearchRequest */ + private $request; + + public function __construct() { } @@ -73,6 +88,13 @@ class SearchResult implements \JsonSerializable { return $this; } + /** + * @return int + */ + public function getCount() { + return count($this->documents); + } + /** * @param string $result @@ -90,22 +112,92 @@ class SearchResult implements \JsonSerializable { /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider */ - public function setProvider(INextSearchProvider $provider) { + public function setProvider(IFullTextSearchProvider $provider) { $this->provider = $provider; } /** - * @return INextSearchProvider + * @return IFullTextSearchProvider */ public function getProvider() { return $this->provider; } - public function getSize() { - return count($this->documents); + /** + * @return int + */ + public function getTotal() { + return $this->total; + } + + /** + * @param int $total + */ + public function setTotal($total) { + $this->total = $total; + } + + + /** + * @return int + */ + public function getMaxScore() { + return $this->maxScore; + } + + /** + * @param int $maxScore + */ + public function setMaxScore($maxScore) { + $this->maxScore = $maxScore; + } + + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @param int $time + */ + public function setTime($time) { + $this->time = $time; + } + + + /** + * @return bool + */ + public function isTimedOut() { + return $this->timedOut; + } + + /** + * @param bool $timedOut + */ + public function setTimedOut($timedOut) { + $this->timedOut = $timedOut; + } + + + /** + * @return SearchRequest + */ + public function getRequest() { + return $this->request; + } + + /** + * @param SearchRequest $request + */ + public function setRequest($request) { + $this->request = $request; } @@ -122,7 +214,15 @@ class SearchResult implements \JsonSerializable { 'name' => $provider->getName() ], 'documents' => $this->getDocuments(), - 'size' => $this->getSize() + 'meta' => + [ + 'timedOut' => $this->isTimedOut(), + 'time' => $this->getTime(), + 'count' => $this->getCount(), + 'total' => $this->getTotal(), + 'maxScore' => $this->getMaxScore(), + 'request' => $this->getRequest() + ] ]; } }
\ No newline at end of file diff --git a/lib/Model/Tick.php b/lib/Model/Tick.php index 676e03f..865bb86 100644 --- a/lib/Model/Tick.php +++ b/lib/Model/Tick.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,11 +22,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Model; +namespace OCA\FullTextSearch\Model; class Tick { diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 5d7c80f..953b9dd 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,13 +22,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Exceptions\ProviderOptionsDoesNotExistException; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Exceptions\ProviderOptionsDoesNotExistException; use OCP\IConfig; use OCP\PreConditionNotMetException; use OCP\Util; diff --git a/lib/Service/IndexService.php b/lib/Service/IndexService.php index f27c3b7..e1d7c6e 100644 --- a/lib/Service/IndexService.php +++ b/lib/Service/IndexService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,26 +21,25 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; use Exception; -use OCA\FullNextSearch\Db\IndexesRequest; -use OCA\FullNextSearch\Exceptions\DatabaseException; -use OCA\FullNextSearch\Exceptions\IndexDoesNotExistException; -use OCA\FullNextSearch\Exceptions\InterruptException; -use OCA\FullNextSearch\Exceptions\NoResultException; -use OCA\FullNextSearch\Exceptions\TickDoesNotExistException; -use OCA\FullNextSearch\INextSearchPlatform; -use OCA\FullNextSearch\INextSearchProvider; -use OCA\FullNextSearch\Model\ExtendedIndex; -use OCA\FullNextSearch\Model\Index; -use OCA\FullNextSearch\Model\IndexDocument; -use OCA\FullNextSearch\Model\ProviderIndexes; -use OCA\FullNextSearch\Model\Runner; +use OCA\FullTextSearch\Db\IndexesRequest; +use OCA\FullTextSearch\Exceptions\DatabaseException; +use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException; +use OCA\FullTextSearch\Exceptions\InterruptException; +use OCA\FullTextSearch\Exceptions\NoResultException; +use OCA\FullTextSearch\Exceptions\TickDoesNotExistException; +use OCA\FullTextSearch\IFullTextSearchPlatform; +use OCA\FullTextSearch\IFullTextSearchProvider; +use OCA\FullTextSearch\Model\ExtendedIndex; +use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Model\IndexDocument; +use OCA\FullTextSearch\Model\ProviderIndexes; +use OCA\FullTextSearch\Model\Runner; class IndexService { @@ -108,14 +107,14 @@ class IndexService { /** - * @param INextSearchPlatform $platform - * @param INextSearchProvider $provider + * @param IFullTextSearchPlatform $platform + * @param IFullTextSearchProvider $provider * @param string $userId * * @throws Exception */ public function indexProviderContentFromUser( - INextSearchPlatform $platform, INextSearchProvider $provider, $userId + IFullTextSearchPlatform $platform, IFullTextSearchProvider $provider, $userId ) { $this->updateRunner('generateIndex' . $provider->getName()); $documents = $provider->generateIndexableDocuments($userId); @@ -128,14 +127,14 @@ class IndexService { /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * @param IndexDocument[] $items * * @return IndexDocument[] * @throws InterruptException * @throws TickDoesNotExistException */ - private function updateDocumentsWithCurrentIndex(INextSearchProvider $provider, array $items) { + private function updateDocumentsWithCurrentIndex(IFullTextSearchProvider $provider, array $items) { $currIndex = $this->getProviderIndexFromProvider($provider); $result = []; @@ -152,11 +151,11 @@ class IndexService { /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * * @return ProviderIndexes */ - private function getProviderIndexFromProvider(INextSearchProvider $provider) { + private function getProviderIndexFromProvider(IFullTextSearchProvider $provider) { $indexes = $this->indexesRequest->getIndexesFromProvider($provider); return new ProviderIndexes($indexes); @@ -164,13 +163,13 @@ class IndexService { /** - * @param INextSearchPlatform $platform - * @param INextSearchProvider $provider + * @param IFullTextSearchPlatform $platform + * @param IFullTextSearchProvider $provider * @param IndexDocument[] $documents * * @throws Exception */ - private function indexChunks(INextSearchPlatform $platform, INextSearchProvider $provider, $documents + private function indexChunks(IFullTextSearchPlatform $platform, IFullTextSearchProvider $provider, $documents ) { $chunkSize = $this->configService->getAppValue(ConfigService::CHUNK_INDEX); @@ -196,14 +195,14 @@ class IndexService { /** - * @param INextSearchPlatform $platform - * @param INextSearchProvider $provider + * @param IFullTextSearchPlatform $platform + * @param IFullTextSearchProvider $provider * @param IndexDocument[] $chunk * * @throws NoResultException * @throws DatabaseException */ - private function indexChunk(INextSearchPlatform $platform, INextSearchProvider $provider, $chunk) { + private function indexChunk(IFullTextSearchPlatform $platform, IFullTextSearchProvider $provider, $chunk) { if (sizeof($chunk) === 0) { throw new NoResultException(); } @@ -236,15 +235,15 @@ class IndexService { /** - * @param INextSearchPlatform $platform - * @param INextSearchProvider $provider + * @param IFullTextSearchPlatform $platform + * @param IFullTextSearchProvider $provider * @param Index $index * * @internal param int|string $documentId * @throws Exception */ public function updateDocument( - INextSearchPlatform $platform, INextSearchProvider $provider, Index $index + IFullTextSearchPlatform $platform, IFullTextSearchProvider $provider, Index $index ) { $document = $provider->updateDocument($index); if ($document === null) { diff --git a/lib/Service/MiscService.php b/lib/Service/MiscService.php index 485fce8..9b35995 100644 --- a/lib/Service/MiscService.php +++ b/lib/Service/MiscService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,12 +22,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; -use OCA\FullNextSearch\AppInfo\Application; +use OCA\FullTextSearch\AppInfo\Application; use OCP\ILogger; class MiscService { @@ -57,6 +56,10 @@ class MiscService { * @return array|string|integer */ public static function get($arr, $k, $default = '') { + if ($arr === null) { + return $default; + } + if (!key_exists($k, $arr)) { return $default; } diff --git a/lib/Service/PlatformService.php b/lib/Service/PlatformService.php index 14a32db..806f8bd 100644 --- a/lib/Service/PlatformService.php +++ b/lib/Service/PlatformService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,19 +21,18 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; use Exception; use OC\App\AppManager; use OC_App; -use OCA\FullNextSearch\Exceptions\PlatformDoesNotExistException; -use OCA\FullNextSearch\Exceptions\PlatformIsNotCompatibleException; -use OCA\FullNextSearch\Exceptions\PlatformNotSelectedException; -use OCA\FullNextSearch\INextSearchPlatform; +use OCA\FullTextSearch\Exceptions\PlatformDoesNotExistException; +use OCA\FullTextSearch\Exceptions\PlatformIsNotCompatibleException; +use OCA\FullTextSearch\Exceptions\PlatformNotSelectedException; +use OCA\FullTextSearch\IFullTextSearchPlatform; use OCP\AppFramework\QueryException; class PlatformService { @@ -50,7 +49,7 @@ class PlatformService { /** @var array */ private $platforms = []; - /** @var INextSearchPlatform */ + /** @var IFullTextSearchPlatform */ private $platform; /** @var bool */ @@ -78,7 +77,7 @@ class PlatformService { /** * @param bool $silent * - * @return INextSearchPlatform + * @return IFullTextSearchPlatform * @throws Exception */ public function getPlatform($silent = false) { @@ -96,7 +95,7 @@ class PlatformService { /** - * @return INextSearchPlatform[] + * @return IFullTextSearchPlatform[] * @throws Exception */ public function getPlatforms() { @@ -106,7 +105,7 @@ class PlatformService { foreach ($this->platforms as $class) { try { $platform = \OC::$server->query((string)$class); - if ($platform instanceof INextSearchPlatform) { + if ($platform instanceof IFullTextSearchPlatform) { $platforms[$class] = $platform; } } catch (QueryException $e) { @@ -158,9 +157,9 @@ class PlatformService { $selected = $this->getSelectedPlatform(); $platform = \OC::$server->query((string)$selected); - if (!($platform instanceof INextSearchPlatform)) { + if (!($platform instanceof IFullTextSearchPlatform)) { throw new PlatformIsNotCompatibleException( - $selected . ' is not a compatible NextSearchPlatform' + $selected . ' is not a compatible FullTextSearchPlatform' ); } @@ -178,12 +177,12 @@ class PlatformService { $selected = $this->configService->getAppValue(ConfigService::SEARCH_PLATFORM); if ($selected === '') { - throw new PlatformNotSelectedException('Admin have not selected any NextSearchPlatform'); + throw new PlatformNotSelectedException('Admin have not selected any FullTextSearchPlatform'); } if (!in_array($selected, $this->platforms)) { throw new PlatformDoesNotExistException( - 'NextSearchPlatform ' . $selected . ' is not available' + 'FullTextSearchPlatform ' . $selected . ' is not available' ); } @@ -195,12 +194,12 @@ class PlatformService { */ private function loadPlatformsFromApp($appId) { $appInfo = OC_App::getAppInfo($appId); - if (!is_array($appInfo) || !key_exists('fullnextsearch', $appInfo) - || !key_exists('platform', $appInfo['fullnextsearch'])) { + if (!is_array($appInfo) || !key_exists('fulltextsearch', $appInfo) + || !key_exists('platform', $appInfo['fulltextsearch'])) { return; } - $platforms = $appInfo['fullnextsearch']['platform']; + $platforms = $appInfo['fulltextsearch']['platform']; if (!is_array($platforms)) { $platforms = [$platforms]; } diff --git a/lib/Service/ProviderService.php b/lib/Service/ProviderService.php index d19ffce..1378431 100644 --- a/lib/Service/ProviderService.php +++ b/lib/Service/ProviderService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,19 +22,18 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; use Exception; use OC\App\AppManager; use OC_App; -use OCA\FullNextSearch\Exceptions\ProviderDoesNotExistException; -use OCA\FullNextSearch\Exceptions\ProviderIsNotCompatibleException; -use OCA\FullNextSearch\Exceptions\ProviderIsNotUniqueException; -use OCA\FullNextSearch\Exceptions\ProviderOptionsDoesNotExistException; -use OCA\FullNextSearch\INextSearchProvider; +use OCA\FullTextSearch\Exceptions\ProviderDoesNotExistException; +use OCA\FullTextSearch\Exceptions\ProviderIsNotCompatibleException; +use OCA\FullTextSearch\Exceptions\ProviderIsNotUniqueException; +use OCA\FullTextSearch\Exceptions\ProviderOptionsDoesNotExistException; +use OCA\FullTextSearch\IFullTextSearchProvider; use OCP\AppFramework\QueryException; class ProviderService { @@ -48,7 +47,7 @@ class ProviderService { /** @var MiscService */ private $miscService; - /** @var INextSearchProvider[] */ + /** @var IFullTextSearchProvider[] */ private $providers = []; /** @var bool */ @@ -73,7 +72,7 @@ class ProviderService { /** - * Load all NextSearchProviders set in any info.xml file + * Load all FullTextSearchProviders set in any info.xml file * * @throws Exception */ @@ -105,9 +104,9 @@ class ProviderService { public function loadProvider($providerId) { $provider = \OC::$server->query((string)$providerId); - if (!($provider instanceof INextSearchProvider)) { + if (!($provider instanceof IFullTextSearchProvider)) { throw new ProviderIsNotCompatibleException( - $providerId . ' is not a compatible NextSearchProvider' + $providerId . ' is not a compatible FullTextSearchProvider' ); } @@ -119,7 +118,7 @@ class ProviderService { /** - * @return INextSearchProvider[] + * @return IFullTextSearchProvider[] * @throws Exception */ public function getProviders() { @@ -129,7 +128,7 @@ class ProviderService { } /** - * @return INextSearchProvider[] + * @return IFullTextSearchProvider[] * @throws Exception */ public function getConfiguredProviders() { @@ -147,32 +146,35 @@ class ProviderService { /** - * @param string $providerId + * @param array $providerList * - * @return INextSearchProvider[] + * @return IFullTextSearchProvider[] * @throws Exception * @throws ProviderDoesNotExistException */ - public function getFilteredProviders($providerId) { + public function getFilteredProviders($providerList) { $this->loadProviders(); $providers = $this->getConfiguredProviders(); - if ($providerId === '_all') { + if (in_array('all', $providerList)) { return $providers; } - if (!$this->isProviderIndexed($providerId)) { - return []; + $ret = []; + foreach ($providerList as $providerId) { + if ($this->isProviderIndexed($providerId)) { + $ret[] = $this->getProvider($providerId); + } } - return [$this->getProvider($providerId)]; + return $ret; } /** * @param string $providerId * - * @return INextSearchProvider + * @return IFullTextSearchProvider * @throws Exception * @throws ProviderDoesNotExistException */ @@ -212,7 +214,7 @@ class ProviderService { } - public function setProviderAsIndexed(INextSearchProvider $provider, $boolean) { + public function setProviderAsIndexed(IFullTextSearchProvider $provider, $boolean) { $this->configService->setProviderOptions( $provider->getId(), ConfigService::PROVIDER_INDEXED, (($boolean) ? '1' : '0') ); @@ -233,12 +235,12 @@ class ProviderService { */ private function loadProvidersFromApp($appId) { $appInfo = OC_App::getAppInfo($appId); - if (!is_array($appInfo) || !key_exists('fullnextsearch', $appInfo) - || !key_exists('provider', $appInfo['fullnextsearch'])) { + if (!is_array($appInfo) || !key_exists('fulltextsearch', $appInfo) + || !key_exists('provider', $appInfo['fulltextsearch'])) { return; } - $providers = $appInfo['fullnextsearch']['provider']; + $providers = $appInfo['fulltextsearch']['provider']; $this->loadProvidersFromList($providers); } @@ -262,15 +264,15 @@ class ProviderService { /** - * @param INextSearchProvider $provider + * @param IFullTextSearchProvider $provider * * @throws ProviderIsNotUniqueException */ - private function providerIdMustBeUnique(INextSearchProvider $provider) { + private function providerIdMustBeUnique(IFullTextSearchProvider $provider) { foreach ($this->providers AS $knownProvider) { if ($knownProvider->getId() === $provider->getId()) { throw new ProviderIsNotUniqueException( - 'NextSearchProvider ' . $provider->getId() . ' already exist' + 'FullTextSearchProvider ' . $provider->getId() . ' already exist' ); } } @@ -278,7 +280,7 @@ class ProviderService { /** - * @param INextSearchProvider[] $providers + * @param IFullTextSearchProvider[] $providers * * @return array */ diff --git a/lib/Service/RunningService.php b/lib/Service/RunningService.php index ec47bae..dff1e87 100644 --- a/lib/Service/RunningService.php +++ b/lib/Service/RunningService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,17 +22,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; -use OCA\FullNextSearch\Db\TickRequest; -use OCA\FullNextSearch\Exceptions\RunnerAlreadyUpException; -use OCA\FullNextSearch\Exceptions\TickDoesNotExistException; -use OCA\FullNextSearch\Exceptions\TickIsNotAliveException; -use OCA\FullNextSearch\Model\ExtendedTick; -use OCA\FullNextSearch\Model\Runner; +use OCA\FullTextSearch\Db\TickRequest; +use OCA\FullTextSearch\Exceptions\RunnerAlreadyUpException; +use OCA\FullTextSearch\Exceptions\TickDoesNotExistException; +use OCA\FullTextSearch\Exceptions\TickIsNotAliveException; +use OCA\FullTextSearch\Model\ExtendedTick; +use OCA\FullTextSearch\Model\Runner; class RunningService { diff --git a/lib/Service/SearchService.php b/lib/Service/SearchService.php index 29a9cbb..c249436 100644 --- a/lib/Service/SearchService.php +++ b/lib/Service/SearchService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,21 +21,21 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; use Exception; use OC\App\AppManager; use OCA\Circles\Api\v1\Circles; -use OCA\FullNextSearch\Exceptions\EmptySearchException; -use OCA\FullNextSearch\Exceptions\ProviderDoesNotExistException; -use OCA\FullNextSearch\INextSearchPlatform; -use OCA\FullNextSearch\INextSearchProvider; -use OCA\FullNextSearch\Model\DocumentAccess; -use OCA\FullNextSearch\Model\SearchResult; +use OCA\FullTextSearch\Exceptions\EmptySearchException; +use OCA\FullTextSearch\Exceptions\ProviderDoesNotExistException; +use OCA\FullTextSearch\IFullTextSearchPlatform; +use OCA\FullTextSearch\IFullTextSearchProvider; +use OCA\FullTextSearch\Model\DocumentAccess; +use OCA\FullTextSearch\Model\SearchRequest; +use OCA\FullTextSearch\Model\SearchResult; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; @@ -97,30 +97,35 @@ class SearchService { /** - * @param string $providerId * @param string $userId - * @param string $search + * @param SearchRequest $request * * @return SearchResult[] * @throws EmptySearchException * @throws Exception * @throws ProviderDoesNotExistException */ - public function search($providerId, $userId, $search) { + public function search($userId, SearchRequest $request) { - $this->searchCannotBeEmpty($search); + $this->searchCannotBeEmpty($request); if ($userId === null) { $userId = $this->userId; } - $search = trim(str_replace(' ', ' ', $search)); - $providers = $this->providerService->getFilteredProviders($providerId); + $user = $this->userManager->get($userId); + $request->setAuthor($user->getUID()); + $request->cleanSearch(); + + $providers = $this->providerService->getFilteredProviders($request->getProviders()); $platform = $this->platformService->getPlatform(); - $user = $this->userManager->get($userId); $access = $this->getDocumentAccessFromUser($user); - $result = $this->searchFromProviders($platform, $providers, $access, $search); + $result = $this->searchFromProviders($platform, $providers, $access, $request); + + foreach ($result as $searchResult) { + $searchResult->setRequest($request); + } return $result; } @@ -139,20 +144,20 @@ class SearchService { /** - * @param INextSearchPlatform $platform - * @param INextSearchProvider[] $providers + * @param IFullTextSearchPlatform $platform * @param DocumentAccess $access - * @param string $search + * @param IFullTextSearchProvider[] $providers + * @param SearchRequest $request * - * @return array + * @return SearchResult[] */ private function searchFromProviders( - INextSearchPlatform $platform, array $providers, DocumentAccess $access, $search + IFullTextSearchPlatform $platform, array $providers, DocumentAccess $access, SearchRequest $request ) { - $result = []; foreach ($providers AS $provider) { - $searchResult = $platform->searchDocuments($provider, $access, $search); + $provider->improveSearchRequest($request); + $searchResult = $platform->searchDocuments($provider, $access, $request); $provider->improveSearchResult($searchResult); if (sizeof($searchResult->getDocuments()) > 0) { diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 2fe25a0..d035c7a 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,10 +22,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Service; +namespace OCA\FullTextSearch\Service; use Exception; use OCP\IConfig; diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 9710165..3ab45dc 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -22,15 +22,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * */ -namespace OCA\FullNextSearch\Settings; +namespace OCA\FullTextSearch\Settings; use Exception; -use OCA\FullNextSearch\AppInfo\Application; -use OCA\FullNextSearch\Service\ConfigService; -use OCA\FullNextSearch\Service\MiscService; +use OCA\FullTextSearch\AppInfo\Application; +use OCA\FullTextSearch\Service\ConfigService; +use OCA\FullTextSearch\Service\MiscService; use OCP\AppFramework\Http\TemplateResponse; use OCP\IL10N; use OCP\IURLGenerator; diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index cbd4263..9365477 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -1,12 +1,12 @@ <?php /** - * FullNextSearch - Full Text Search your Nextcloud. + * FullTextSearch - Full text search framework for Nextcloud * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Maxence Lange <maxence@artificial-owl.com> - * @copyright 2017 + * @copyright 2018 * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -21,13 +21,12 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * + * */ -namespace OCA\FullNextSearch\Settings; +namespace OCA\FullTextSearch\Settings; -use OCA\FullNextSearch\AppInfo\Application; +use OCA\FullTextSearch\AppInfo\Application; use OCP\IL10N; use OCP\IURLGenerator; use OCP\Settings\IIconSection; @@ -60,7 +59,7 @@ class AdminSection implements IIconSection { * {@inheritdoc} */ public function getName() { - return $this->l10n->t('Full Next Search'); + return $this->l10n->t('Full text search'); } /** @@ -74,6 +73,6 @@ class AdminSection implements IIconSection { * {@inheritdoc} */ public function getIcon() { - return $this->urlGenerator->imagePath(Application::APP_NAME, 'fullnextsearch_black.svg'); + return $this->urlGenerator->imagePath(Application::APP_NAME, 'fulltextsearch_black.svg'); } } diff --git a/templates/navigate.php b/templates/navigate.php index 328a119..c47cb16 100644 --- a/templates/navigate.php +++ b/templates/navigate.php @@ -1,19 +1,41 @@ <?php - - -use OCA\FullNextSearch\Api\v1\NextSearch; +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +use OCA\FullTextSearch\Api\v1\FullTextSearch; +use OCA\FullTextSearch\AppInfo\Application; use OCP\Util; -NextSearch::addJavascriptAPI(); -Util::addScript(NextSearch::appName(), 'fullnextsearch'); -Util::addStyle(NextSearch::appName(), 'fullnextsearch'); +FullTextSearch::addJavascriptAPI(); +Util::addScript(Application::APP_NAME, 'navigate'); +Util::addStyle(Application::APP_NAME, 'navigate'); ?> <div id="search_header"> <input id="search_input" placeholder="<?php p($l->t('Search on %s', [$_['themingName']])); ?>"> -<!-- <input id="search_submit" type="submit"--> -<!-- value="--><?php //p($l->t('Search on %s', [$_['themingName']])); ?><!--">--> </div> diff --git a/templates/settings.admin.php b/templates/settings.admin.php index 5d32d8b..dae047d 100644 --- a/templates/settings.admin.php +++ b/templates/settings.admin.php @@ -1,6 +1,30 @@ <?php +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ -use OCA\FullNextSearch\AppInfo\Application; +use OCA\FullTextSearch\AppInfo\Application; use OCP\Util; Util::addScript(Application::APP_NAME, 'admin.elements'); @@ -14,14 +38,14 @@ Util::addStyle(Application::APP_NAME, 'admin'); <div id="fns" class="section"> <span> - <a href="https://github.com/nextcloud/fullnextsearch/wiki" target="_blank"> + <a href="https://github.com/nextcloud/fulltextsearch/wiki" target="_blank"> Please check the wiki</a> - for documentation related to the installation and the configuration of the Full Text Search within your Nextcloud + for documentation related to the installation and the configuration of the Full text search within your Nextcloud </span> <br/> <br/> - <h2><?php p($l->t('Full Next Search')) ?></h2> + <h2><?php p($l->t('Full text search')) ?></h2> <div class="div-table"> <div class="div-table-row"> @@ -31,7 +55,7 @@ Util::addStyle(Application::APP_NAME, 'admin'); <em>Select the app that will be used to index content and answer search queries.</em> </div> <div class="div-table-col"> - <select id="fns_platforms"> + <select id="fts_platforms"> <option></option> </select> </div> @@ -44,7 +68,7 @@ Util::addStyle(Application::APP_NAME, 'admin'); <em>Lower the value if the server is short on memory.</em> </div> <div class="div-table-col"> - <input type="text" class="small" id="fns_chunk_size"/> + <input type="text" class="small" id="fts_chunk_size"/> </div> </div> |