diff --git a/pages/01.blog/take-a-breath-enjoy-your-world/item.de.md b/pages/01.blog/take-a-breath-enjoy-your-world/item.de.md new file mode 100644 index 0000000..182f773 --- /dev/null +++ b/pages/01.blog/take-a-breath-enjoy-your-world/item.de.md @@ -0,0 +1,87 @@ +--- +title: 'Atme durch! Genieße deine Welt!' +published: true +date: '03-09-2022 01:59' +taxonomy: + category: + - news + tag: + - privacy + - socialcooling + - socialmedia + - selbstmord + - depressionen + - facebook + - instagram + - digitalprivacy + - google +aura: + author: dan +--- + +# Atme durch! Genieße deine Welt! + +Unsere erste **_Deine eigenen Extras_** ist verfügbar! +Sorry Mastodon (fediverse), du gehörst dazu. + +Neuseeländer und andere Menschen in dieser Zeitzone, und natürlich auch diejenigen, die unserer Zeitzone voraus sind (Grüße nach Tonga), haben die Hälfte des Jahres 2022 erreicht. Samstag, 02.07 also der 183. Tag im Jahr 2022 in der 26. Kalenderwoche. +Es ist Zeit für unsere erste **_Deine eigenen Extras_**, die auch in unserem [wiki](https://wiki.techsaviours.org/de/extras/take_a_breath) zu finden sind. + +**_Atme durch! Genieße deine Welt!_** wird eher eine Erinnerung daran sein, nicht nur Google, Facebook & Co. loszuwerden oder den Kampf gegen all die Unternehmen zu führen, die die digitale Privatsphäre im Allgemeinen verletzen. Und gute Open-Source-Alternativen zu finden und sie zum Laufen zu bringen. Anderen zu erklären, warum sie dieses und jenes nicht benutzen sollten. Das gehört eigentlich alles dazu, aber es geht mehr darum, zu verstehen, dass wir es mit einem gesellschaftlichen Problem zu tun haben, das schnell wächst und an das wir uns von Zeit zu Zeit erinnern sollten. + +Ich (Dan) bin froh, dass ich in einer Generation aufgewachsen bin, in der wir eine Telefonzelle suchen mussten, um die Eltern um weitere 15 Minuten zu bitten. So konnten wir weiter draußen mit unseren Freunden Fußball oder andere coole Sachen machen. +Es gab keine seltsamen Kommentare, die ich an irgendjemanden geschickt oder von irgendjemandem erhalten habe und die im World Wide Web die Runde machten. Keine Erinnerung an was auch immer (nur, dass es dunkel wird und meine Eltern wollen, dass ich nach Hause komme). Keine Benachrichtigung, die mir die Vision raubte, den Ball wie Roberto Carlos zu schießen (Lattenkreuz! Pfosten! TOOOOOOR!!!). +Wir hatten einfach nur Spaß, kamen nach Hause, duschten (wahrscheinlich von unseren Eltern gezwungen) und schauten mehr Fußball und träumten davon, endlich die GANZE Box mit Panini-Stickern in den Händen zu halten. + +Es ist eigentlich ganz einfach, **//Atme durch! Genieße deine Welt//**! +Lösche einfach alle deine Social-Media-Konten und lass dein Smartphone zu Hause. Am wichtigsten ist, dass du das auch für deine Kinder tust. +Wir wollen nicht, dass die Selbstmorde bei Kindern weiter zunehmen. Wir wollen das für keinen von uns. Es hört nicht auf, seit die verdammten Social-Media-Plattformen unsere (sensiblen) Gehirne infiziert haben. +Wir alle wollen die Freiheit und unsere Gewohnheiten bewahren?! Und wir wollen die Welt weiterhin genießen, ohne von Tausenden von Smartphone- oder Regierungskameras umgeben zu sein (die bereits überall in der Stadt, auf Spielplätzen usw. zu finden sind), wenn wir uns am Hals kratzen oder beim Fußballspielen unglücklich den Ball zwischen die Beine bekommen, die Videos dann widerum auf einer der Social Media-Plattformen landen. + +# Das gesellschaftliche Dilemma +Wir sollten zum Beispiel etwas gegen Folgendes unternehmen: + +- https://reclaimyourface.eu/the-problem/ +- https://www.socialcooling.de/ +- https://en.wikipedia.org/wiki/Social_media_and_suicide +- https://de.wikipedia.org/wiki/Das_Dilemma_mit_den_sozialen_Medien + +# Wie? +Lösche einfach deine Social-Media-Konten und genieße die Natur und gönne deinem Gehirn nach sooo vielen Jahren endlich eine Pause: + +- Mastodon - https://docs.joinmastodon.org/user/moving/#delete +- Diaspora + - Melde dich bei deinem Diaspora-Konto an + - Klicke dann oben rechts auf deinen Benutzernamen und wähle "Einstellungen". + - Scrolle unter der Registerkarte "Konto" ganz nach unten und klicke auf "Konto schließen". + - Gib dein aktuelles Passwort ein und bestätige die Kontolöschung über den Button "Konto schließen". +- Misskey und andere [fediverse](https://de.wikipedia.org/wiki/Fediverse#Kommunikationsprotokolle_und_Instanzen) - Um ehrlich zu sein, ich weiß es nicht. Wahrscheinlich ähnlich wie Dispora und Mastodon. + +Die folgenden Links sind Mozillas "Internet spring cleaning": + +- Facebook - https://blog.mozilla.org/internet-culture/mozilla-explains/how-to-delete-facebook/ +- Instagram - https://blog.mozilla.org/internet-culture/mozilla-explains/how-to-delete-instagram/ +- Snapshat - https://blog.mozilla.org/internet-culture/how-to-delete-snapchat +- Twitter - https://blog.mozilla.org/internet-culture/how-to-delete-twitter/ +- Tiktok - https://blog.mozilla.org/internet-culture/mozilla-explains/how-to-delete-tiktok +- Google - https://blog.mozilla.org/internet-culture/how-to-delete-google/ + +Mozillas gesamte Liste: + +- https://blog.mozilla.org/en/internet-culture/how-to-delete-instagram-facebook-online-accounts/ + +# Das war's? +Nein, natürlich nicht! Du kannst das Problem mit unserem Klimawandel vergleichen. Es braucht viel mehr, als nur seine Konten zu löschen oder keine Plastiktüten mehr zu benutzen. Wir alle müssen es eigentlich tun. Und es wird wahrscheinlich nie passieren, aber zumindest kann es dir helfen, einen klaren Kopf in deiner kleinen Welt zu behalten. + +# Du fragst dich, warum wir immer noch auf Mastodon und Twitter sind?! +Ich habe Facebook, Twitter usw. noch nie benutzt. Das ist einfach nicht meine Welt, aber nicht jeder ist sich über Open-Source-Alternativen, Social Cooling oder digitalen Datenschutz im Allgemeinen bewusst. Deshalb versuchen wir, die Leute zu erreichen (unser Twitter-Account) und haben ein Mastodon-Account eingerichtet, um den Leuten die Möglichkeit zu geben, uns über eine datenschutzfreundlichere Open-Source-Lösung zu folgen. Aber Sie müssen kein Mastodon-Account haben, um uns oder jemand anderem zu folgen. RSS ist für die meisten Webseiten verfügbar. Du kannst auch deinem Lieblings-Mastodon-Benutzer über RSS folgen. Füge einfach den Benutzer (https://fosstodon.org/@techsaviours) zu deinem RSS-Feed-Aggregator hinzu. + +Eine Anleitung, wie man einen RSS-Server ([FreshRSS](https://github.com/FreshRSS/FreshRSS)) hinzufügt, wird eines Tages auch einen Platz in unserem Wiki finden. + +# Schalte dein Smartphone aus +So, es ist Wochenende, für uns Samstag, für andere sogar noch Freitag. Zeit für Zeit mit Freunden, Familie, Natur oder einfach nur ein Buch vor den “verstrahlten” Augen zu lesen. Das heißt, leg deine Geräte beiseite und fang am Montag an, deine Social-Media-Accounts zu löschen und **_Atme durch! Genieße deine Welt!_** genau jetzt. + +P.S. Nicht vergessen! Die mürrische Person vor dir hat vielleicht das gleiche Problem! + +**_Atme durch! Genieße deine Welt!_** +Dan diff --git a/plugins/pagination/CHANGELOG.md b/plugins/pagination/CHANGELOG.md index 1d80bf1..aec9738 100644 --- a/plugins/pagination/CHANGELOG.md +++ b/plugins/pagination/CHANGELOG.md @@ -1,3 +1,12 @@ +# v1.4.3 +## 08/26/2022 + +1. [](#new) + * Pass phpstan level 1 tests + * Require Grav v1.6 + * Moved pagination classes under `Grav\Plugin\Pagination` namespace + * Removed extension to bring Twig function into Plugin class + # v1.4.2 ## 05/09/2019 diff --git a/plugins/pagination/blueprints.yaml b/plugins/pagination/blueprints.yaml index 2d08b8a..2afc9c5 100644 --- a/plugins/pagination/blueprints.yaml +++ b/plugins/pagination/blueprints.yaml @@ -1,5 +1,7 @@ name: Pagination -version: 1.4.2 +slug: pagination +type: plugin +version: 1.4.3 description: "**Pagination** is a very useful plugin to help navigate a large collection of pages, such as for a **blog**." icon: list-ol author: @@ -10,6 +12,8 @@ homepage: https://github.com/getgrav/grav-plugin-pagination keywords: pagination, plugin, pages, navigation bugs: https://github.com/getgrav/grav-plugin-pagination/issues license: MIT +dependencies: + - { name: grav, version: '>=1.6.0' } form: validation: strict diff --git a/plugins/pagination/classes/paginationhelper.php b/plugins/pagination/classes/plugin/PaginationHelper.php similarity index 97% rename from plugins/pagination/classes/paginationhelper.php rename to plugins/pagination/classes/plugin/PaginationHelper.php index a780824..9c10a87 100644 --- a/plugins/pagination/classes/paginationhelper.php +++ b/plugins/pagination/classes/plugin/PaginationHelper.php @@ -1,5 +1,5 @@ =7.1.3", + "ext-json": "*", + "ext-mbstring": "*" + }, + "autoload": { + "psr-4": { + "Grav\\Plugin\\Pagination\\": "classes/plugin" + }, + "classmap": ["pagination.php"] + }, + "config": { + "platform": { + "php": "7.1.3" + } + } +} diff --git a/plugins/pagination/composer.lock b/plugins/pagination/composer.lock new file mode 100644 index 0000000..10bb907 --- /dev/null +++ b/plugins/pagination/composer.lock @@ -0,0 +1,24 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "0b6ccb6ac74643ef6b539ab9dbeffe31", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.1.3", + "ext-json": "*", + "ext-mbstring": "*" + }, + "platform-dev": [], + "platform-overrides": { + "php": "7.1.3" + } +} diff --git a/plugins/pagination/hebe.json b/plugins/pagination/hebe.json new file mode 100644 index 0000000..c6e7d2f --- /dev/null +++ b/plugins/pagination/hebe.json @@ -0,0 +1,15 @@ +{ + "project":"grav-plugin-pagination", + "platforms":{ + "grav":{ + "nodes":{ + "plugin":[ + { + "source":"/", + "destination":"/user/plugins/pagination" + } + ] + } + } + } +} diff --git a/plugins/pagination/pagination.php b/plugins/pagination/pagination.php index 531ca0e..be0bbe7 100644 --- a/plugins/pagination/pagination.php +++ b/plugins/pagination/pagination.php @@ -1,10 +1,14 @@ ['onPluginsInitialized', 0] + 'onPluginsInitialized' => [ + ['autoload', 100001], + ['onPluginsInitialized', 0] + ] ]; } + /** + * [onPluginsInitialized:100000] Composer autoload. + * + * @return ClassLoader + */ + public function autoload() + { + return require __DIR__ . '/vendor/autoload.php'; + } + /** * Initialize configuration */ @@ -33,6 +50,9 @@ class PaginationPlugin extends Plugin return; } + class_alias(PaginationHelper::class, 'Grav\\Plugin\\PaginationHelper'); + class_alias(PaginationPage::class, 'Grav\\Plugin\\PaginationPage'); + $this->enable([ 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], 'onPageInitialized' => ['onPageInitialized', 0], @@ -53,9 +73,10 @@ class PaginationPlugin extends Plugin */ public function onTwigExtensions() { - require_once(__DIR__.'/twig/PaginationTwigExtension.php'); - - $this->grav['twig']->twig->addExtension(new PaginationTwigExtension()); + // Add Twig functions + $this->grav['twig']->twig()->addFunction( + new TwigFunction('paginate', [$this, 'paginateTwigFunction']) + ); } /** @@ -63,7 +84,7 @@ class PaginationPlugin extends Plugin */ public function onPageInitialized() { - /** @var Page $page */ + /** @var PageInterface $page */ $page = $this->grav['page']; if ($page && ($page->value('header.content.pagination') || $page->value('header.pagination'))) { @@ -96,7 +117,6 @@ class PaginationPlugin extends Plugin } if (!empty($params['limit']) && $collection->count() > $params['limit']) { - require_once __DIR__ . '/classes/paginationhelper.php'; $this->pagination = new PaginationHelper($collection); $collection->setParams(['pagination' => $this->pagination]); } @@ -119,14 +139,13 @@ class PaginationPlugin extends Plugin * @param int $limit * @param array $ignore_param_array url parameters to be ignored in page links */ - public function paginateCollection( $collection, $limit, $ignore_param_array = []) + public function paginateCollection($collection, $limit, $ignore_param_array = []) { $collection->setParams(['pagination' => 'true']); $collection->setParams(['limit' => $limit]); $collection->setParams(['ignore_params' => $ignore_param_array]); if ($collection->count() > $limit) { - require_once __DIR__ . '/classes/paginationhelper.php'; $this->pagination = new PaginationHelper($collection); $collection->setParams(['pagination' => $this->pagination]); @@ -138,4 +157,9 @@ class PaginationPlugin extends Plugin } } } + + public function paginateTwigFunction($collection, $limit, $ignore_url_param_array = []) + { + $this->paginateCollection($collection, $limit, $ignore_url_param_array); + } } diff --git a/plugins/pagination/twig/PaginationTwigExtension.php b/plugins/pagination/twig/PaginationTwigExtension.php deleted file mode 100644 index ca1689d..0000000 --- a/plugins/pagination/twig/PaginationTwigExtension.php +++ /dev/null @@ -1,42 +0,0 @@ -config = Grav::instance()['config']; - } - - /** - * Returns extension name. - * - * @return string - */ - public function getName() - { - return 'PaginationTwigExtension'; - } - - /** - * Return a list of all functions. - * - * @return array - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('paginate', [$this, 'paginateFunc']), - ]; - } - - public function paginateFunc($collection, $limit, $ignore_url_param_array = []) { - $pag = new PaginationPlugin($this, Grav::instance(), $this->config); - $pag->paginateCollection($collection, $limit, $ignore_url_param_array); - } -} diff --git a/plugins/pagination/vendor/autoload.php b/plugins/pagination/vendor/autoload.php new file mode 100644 index 0000000..cc986c9 --- /dev/null +++ b/plugins/pagination/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath.'\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/plugins/pagination/vendor/composer/LICENSE b/plugins/pagination/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/plugins/pagination/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/plugins/pagination/vendor/composer/autoload_classmap.php b/plugins/pagination/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..06a2a3d --- /dev/null +++ b/plugins/pagination/vendor/composer/autoload_classmap.php @@ -0,0 +1,10 @@ + $baseDir . '/pagination.php', +); diff --git a/plugins/pagination/vendor/composer/autoload_namespaces.php b/plugins/pagination/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/plugins/pagination/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/classes/plugin'), +); diff --git a/plugins/pagination/vendor/composer/autoload_real.php b/plugins/pagination/vendor/composer/autoload_real.php new file mode 100644 index 0000000..d8d74b1 --- /dev/null +++ b/plugins/pagination/vendor/composer/autoload_real.php @@ -0,0 +1,52 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitea591f86e2ec72c59666a51291247f87::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/plugins/pagination/vendor/composer/autoload_static.php b/plugins/pagination/vendor/composer/autoload_static.php new file mode 100644 index 0000000..424889e --- /dev/null +++ b/plugins/pagination/vendor/composer/autoload_static.php @@ -0,0 +1,36 @@ + + array ( + 'Grav\\Plugin\\Pagination\\' => 23, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Grav\\Plugin\\Pagination\\' => + array ( + 0 => __DIR__ . '/../..' . '/classes/plugin', + ), + ); + + public static $classMap = array ( + 'Grav\\Plugin\\PaginationPlugin' => __DIR__ . '/../..' . '/pagination.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitea591f86e2ec72c59666a51291247f87::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitea591f86e2ec72c59666a51291247f87::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitea591f86e2ec72c59666a51291247f87::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/plugins/pagination/vendor/composer/installed.json b/plugins/pagination/vendor/composer/installed.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/plugins/pagination/vendor/composer/installed.json @@ -0,0 +1 @@ +[] diff --git a/plugins/simplesearch/.gitignore b/plugins/simplesearch/.gitignore new file mode 100644 index 0000000..8828462 --- /dev/null +++ b/plugins/simplesearch/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +/.idea diff --git a/plugins/simplesearch/CHANGELOG.md b/plugins/simplesearch/CHANGELOG.md index c2e0d30..32b78f3 100644 --- a/plugins/simplesearch/CHANGELOG.md +++ b/plugins/simplesearch/CHANGELOG.md @@ -1,3 +1,10 @@ +# v2.3.0 +## 08/26/2022 + +1. [](#new) + * Added new `onSimpleSearchCollection()` event to allow for custom integration into SimpleSearch. + * Require Grav 1.7+ + # v2.2.2 ## 05/25/2021 diff --git a/plugins/simplesearch/README.md b/plugins/simplesearch/README.md index f8d7d0a..0c1270d 100644 --- a/plugins/simplesearch/README.md +++ b/plugins/simplesearch/README.md @@ -187,6 +187,40 @@ You can tell Simplesearch to return a positive value when searching for characte To do so, enable _Ignore accented characters_ in Admin, or manually set `ignore_accented_characters` to true in the plugin configuration. The `en_US` locale must be installed on the server. +# Extending + +As of version `2.3.0` SimpleSearch has a Grav even that allow for integrating into custom logic and adding your own 'pages' into the searchable collection. Because SimpleSearch utilizes Grav pages for its searching mechanism, your event needs to build fake 'pages' from your data, then you can add to the collection being passed to the event. Some example psudeo code should help you out: + +```php + public function onSimpleSearchCollection(Event $event) + { + $collection = $event['collection']; + $locator = $this->grav['locator']; + $pages = $this->grav['pages']; + + //find all my custom files + $finder = new Finder(); + $data_location = $locator->findResource("user://data/custom-data"); + + foreach($finder->in($data_location)->name('*.json') as $file) { + $content = $file->getContents(); + $data = json_decode($content, true); + + $header['routes']['default'] = $data['url'], + $page = new Page(); + $page->title($data['title']); + $page->content($data['content']); + $page->path($file->getPathname()); + $page->header($header); + + // Page needs to be added to Pages inorder to work in Collection + $pages->addPage($page); + // Add the fake page to the collection used to search + $collection->addPage($page); + } + } +``` + # Updating As development for SimpleSearch continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating SimpleSearch is easy, and can be done through Grav's GPM system, as well as manually. diff --git a/plugins/simplesearch/blueprints.yaml b/plugins/simplesearch/blueprints.yaml index 1f476b7..2c98b5d 100644 --- a/plugins/simplesearch/blueprints.yaml +++ b/plugins/simplesearch/blueprints.yaml @@ -1,7 +1,7 @@ name: SimpleSearch type: plugin slug: simplesearch -version: 2.2.2 +version: 2.3.0 description: "Don't be fooled, the **SimpleSearch** plugin provides a **fast** and highly **configurable** way to search your content." icon: search author: @@ -15,7 +15,7 @@ bugs: https://github.com/getgrav/grav-plugin-simplesearch/issues license: MIT dependencies: - - { name: grav, version: '>=1.6.0' } + - { name: grav, version: '>=1.7.0' } form: validation: strict diff --git a/plugins/simplesearch/hebe.json b/plugins/simplesearch/hebe.json new file mode 100644 index 0000000..521b391 --- /dev/null +++ b/plugins/simplesearch/hebe.json @@ -0,0 +1,15 @@ +{ + "project":"grav-plugin-simplesearch", + "platforms":{ + "grav":{ + "nodes":{ + "plugin":[ + { + "source":"/", + "destination":"/user/plugins/simplesearch" + } + ] + } + } + } +} diff --git a/plugins/simplesearch/simplesearch.php b/plugins/simplesearch/simplesearch.php index 8239c32..b635b57 100644 --- a/plugins/simplesearch/simplesearch.php +++ b/plugins/simplesearch/simplesearch.php @@ -201,6 +201,9 @@ class SimplesearchPlugin extends Plugin //Add modular pages again $this->collection->merge($modularPageCollection); + //Allow for integration to SimpleSearch collection + $this->grav->fireEvent('onSimpleSearchCollection', new Event(['collection' => $this->collection])); + //Check if user has permission to view page if ($this->grav['config']->get('plugins.login.enabled')) { $this->collection = $this->checkForPermissions($this->collection);