]> _ Git - cubist_cms-back.git/commitdiff
wip #2941
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 21 Aug 2019 18:34:11 +0000 (20:34 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 21 Aug 2019 18:34:11 +0000 (20:34 +0200)
src/app/Console/Commands/SearchIndexCommand.php
src/app/Http/Controllers/CubistPageController.php
src/app/Magic/Menu/PageItem.php

index a049e3a2747956c7ce31ec9dde41cc2b60c2cf6d..1d5009fc6c1d7a0fc370fbdd4b5835afd5768791 100644 (file)
@@ -43,6 +43,8 @@ class SearchIndexCommand extends Command
         /** @var Cubist\Backpack\app\Magic\Menu\Item[] $pages */
         $pages = Menu::getNavigation()->findAll();
 
+        $indexed = [];
+
         foreach ($pages as $page) {
             // Skip nav items
             if ($page instanceof VirtualItem) {
@@ -58,11 +60,14 @@ class SearchIndexCommand extends Command
             }
 
             $href = $page->getHref();
-            if ($href == '#') {
+            if ($href == '#' || $href=='home') {
                 continue;
             }
 
             $url = action("PageController@catchall", ['page' => $href]);
+            if (isset($indexed[$url])) {
+                continue;
+            }
 
             $html = @file_get_contents($url);
             if (!$html) {
@@ -94,6 +99,9 @@ class SearchIndexCommand extends Command
                 'id' => $url,
             ];
 
+            echo $href . ' : ' . $url . "\n";
+            $indexed[$url] = true;
+
             Elasticsearch::index($data);
         }
     }
index 9626756a6abd60b3bebb4534535b5e44e6b67030..6e3a33422da2c76bdb316d43741f44404c9b54c9 100644 (file)
@@ -41,7 +41,6 @@ class CubistPageController extends CubistFrontController
                 $c['params']['path'] = implode('/', $e);
             }
         } else {
-
             $path = trim($main . '/' . $subs, '/');
             if (!$path) {
                 $path = 'home';
@@ -51,7 +50,6 @@ class CubistPageController extends CubistFrontController
             if (null === $item) {
                 $this->_404();
             }
-
             $c = $item->getController();
         }
 
index b866cedab5ba8c1c115ae733b81dc72f7c135ed1..d2632a88f2f52716d34b12e0c3a20d47a72ca92b 100644 (file)
@@ -36,7 +36,6 @@ class PageItem extends Item
 
     public function getHref()
     {
-
         if ($this->getPage()->template == 'first_redirection' && $this->hasChildren()) {
             return $this->getChildren()[0]->getHref();
         } else if ($this->getPage()->template == 'internal_redirection') {