From 905af165fb1605c59db208803f8560949ba3d46d Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 24 Nov 2023 22:26:02 +0200 Subject: [PATCH] draft webui --- README.md | 14 ++- composer.json | 3 +- src/config.json | 11 ++ src/webui/index.php | 288 +++++++++++++++++++++++++++++++++++++++++++ src/webui/search.php | 273 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 585 insertions(+), 4 deletions(-) create mode 100644 src/webui/index.php create mode 100644 src/webui/search.php diff --git a/README.md b/README.md index 0ec363e..fcde31b 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ Next generation of [YGGo!](https://github.com/YGGverse/YGGo) project with goal t - Index model changed to the distributed cluster model, and oriented to aggregate search results from different instances trough API - Refactored data exchange model with drop all primary keys dependencies - Snaps now using tar.gz compression to reduce storage requirements and still supporting remote mirrors, FTP including - - Codebase following minimalism principles everywhere + - Minimalism everywhere ## Implementation Engine written in PHP and uses [Manticore](https://github.com/manticoresoftware) on backend. -Default build inspired and adapted for [Yggdrasil](https://github.com/yggdrasil-network) eco-system but could be used to make own search project. +Default build inspired and adapted for [Yggdrasil](https://github.com/yggdrasil-network) but could be used to make internet search portal. ## Components @@ -32,7 +32,15 @@ Default build inspired and adapted for [Yggdrasil](https://github.com/yggdrasil- 4. Check `src/config.json` for any customizations 5. Make sure `storage` folder writable 6. Run indexes init script `php src/cli/index/init.php` -7. [Start crawling!](https://github.com/YGGverse/Yo#documentation) +7. Add new URL `php src/cli/document/add.php URL` +8. Run crawler `php src/cli/document/crawl.php` +9. Get search results `php src/cli/document/search.php '*'` + +#### Web UI + +1. `cd src/webui` +2. `php -S 127.0.0.1:8080` +3. now open `127.0.0.1:8080` in your browser! ## Documentation diff --git a/composer.json b/composer.json index 8f72c1c..2f6dfba 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "require": { "manticoresoftware/manticoresearch-php": "^3.1", "symfony/css-selector": "^6.3", - "symfony/dom-crawler": "^6.3" + "symfony/dom-crawler": "^6.3", + "jdenticon/jdenticon": "^1.0" } } diff --git a/src/config.json b/src/config.json index dfdb430..2f52990 100644 --- a/src/config.json +++ b/src/config.json @@ -11,6 +11,17 @@ "document":"yo_document" } }, + "webui": + { + "url": + { + "base":"http://127.0.0.1:8888" + }, + "pagination": + { + "limit":20 + } + }, "cli": { "document": diff --git a/src/webui/index.php b/src/webui/index.php new file mode 100644 index 0000000..9e3f8f4 --- /dev/null +++ b/src/webui/index.php @@ -0,0 +1,288 @@ + $config->manticore->server->host, + 'port' => $config->manticore->server->port, + ] +); + +// Init index +$index = $client->index( + $config->manticore->index->document +); + +*/ + +?> + + + + + <?php echo _('Yo! Web Search Engine') ?> + + + + + + +
+
+

+ + +
+
+ +
+ +
+ + + + \ No newline at end of file diff --git a/src/webui/search.php b/src/webui/search.php new file mode 100644 index 0000000..27953be --- /dev/null +++ b/src/webui/search.php @@ -0,0 +1,273 @@ + $config->manticore->server->host, + 'port' => $config->manticore->server->port, + ] +); + +// Init index +$index = $client->index( + $config->manticore->index->document +); + +// Request +$q = !empty($_GET['q']) ? $_GET['q'] : ''; +$p = !empty($_GET['p']) ? (int) $_GET['p'] : 1; + +// Check URL for exist +$results = $index->search($q) + ->offset($p * $config->webui->pagination->limit - $config->webui->pagination->limit) + ->limit($config->webui->pagination->limit) + ->get(); + +?> + + + + + <?php echo sprintf(_('%s - YGGo!'), htmlentities($q)) ?> + + + + + +
+
+

+ + +
+
+
+ getTotal()) { ?> + +
+ url)) { ?> +

title ?>

+ + description)) { ?> + description ?> + + keywords)) { ?> + keywords ?> + + + setValue($result->url); + $identicon->setSize(16); + $identicon->setStyle( + [ + 'backgroundColor' => 'rgba(255, 255, 255, 0)', + 'padding' => 0 + ] + ); + ?> + identicon + url)) ?> + + +
+ + webui->pagination->limit <= $results->getTotal()) { ?> +
+ + + +
+ + +
+ +
+ +
+ + \ No newline at end of file