diff --git a/.gitignore b/.gitignore index 12f8319..e3ec9f9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,10 @@ user/data/* !user/data/.* user/plugins/* !user/plugins/.* -user/themes/* -!user/themes/.* +user/themes/quark/ +!user/themes/quark/.* +user/pages/* +!user/pages/.* user/localhost/config/security.yaml user/config/security.yaml diff --git a/.htaccess b/.htaccess index ef79a4b..d850bdc 100644 --- a/.htaccess +++ b/.htaccess @@ -73,3 +73,8 @@ RewriteRule ^(LICENSE\.txt|composer\.lock|composer\.json|\.htaccess)$ error [F] Options -Indexes DirectoryIndex index.php index.html index.htm # End - Prevent Browsing and Set Default Resources + + +# Redirect http://figureslibres.kevintessier.net/ https://figureslibres.kevintessier.net/ + +Redirect 301 /sitemap /sitemap.xml diff --git a/tmp/Grav-5d9771f040539/1.1.1 b/tmp/Grav-5d9771f040539/1.1.1 new file mode 100644 index 0000000..7f746cc Binary files /dev/null and b/tmp/Grav-5d9771f040539/1.1.1 differ diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/.gitignore b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/.gitignore new file mode 100644 index 0000000..2938888 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/.gitignore @@ -0,0 +1,48 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +.php_cs.cache diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/CHANGELOG.md b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/CHANGELOG.md new file mode 100644 index 0000000..552fe55 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/CHANGELOG.md @@ -0,0 +1,58 @@ +# v1.1.1 + +## 29-04-2019 + +1. [](#bugfix) + - Content-processing + +# v1.1.1-beta-1 + +## 11-04-2019 + +1. [](#bugfix) + - Content-processing + +# v1.1.0 + +## 14-02-2019 + +1. [](#improved) + - Allow per-page options + - Bump vendor-dependency + - Code-cleanup + +# v1.0.3 + +## 28-02-2017 + +1. [](#improved) + - Use selectize in blueprint + - Code cleanup + - PSR-1 and PSR-2 compliance + - Change plugin icon + - Update readme +2. [](#new) + - Document class and methods +3. [](#bugfix) + - Fix changelog format + +# v1.0.2 + +## 09-01-2017 + +1. [](#bugfix) + - Fixed blueprint for admin interface + +# v1.0.1 + +## 03-01-2017 + +1. [](#bugfix) + - Restricted operations to non-admin pages only + +# v1.0.0 + +## 14-05-2016 + +1. [](#new) + - Initial release diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/LICENSE b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/LICENSE new file mode 100644 index 0000000..5b50e4a --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Ole Vik + +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/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/README.md b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/README.md new file mode 100644 index 0000000..edc03e3 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/README.md @@ -0,0 +1,108 @@ +# [Grav](http://getgrav.org/) Image Srcset Plugin + +Adds a `srcset`-attribute to `img`-elements to allow for responsive images in Markdown. This allows [modern browsers](http://caniuse.com/#feat=srcset) to load the image which best fits within the viewport, based on available images and sizes, essentially choosing the best image to reduce loading times (see [RespImg](https://responsiveimages.org/)). + +Thus, on a small mobile screen this would load a much smaller image than on a large desktop. From this: + +```html +Street view +``` + +To this: + +```html +Street view +``` + +This is only applied to image-elements generated from Markdown. Depends on [PHP Html Parser v1.7.0](https://github.com/paquettg/php-html-parser/) for DOM parsing and manipulation of `srcset` and `sizes`. + +# Installation and Configuration + +1. Download the zip version of [this repository](https://github.com/OleVik/grav-plugin-imgsrcset) and unzip it under `/your/site/grav/user/plugins`. +2. Rename the folder to `imgsrcset`. + +You should now have all the plugin files under + + /your/site/grav/user/plugins/imgsrcset + +The plugin is enabled by default, and can be disabled by copying `user/plugins/imgsrcset/imgsrcset.yaml` into `user/config/plugins/imgsrcset.yaml` and setting `enabled: false`. For a simple Twig-integration see [this gist](https://gist.github.com/OleVik/a7604215f127763b71bd8b8788d45cfd). + +**Note**: The plugin needs Twig to be processed first, so be sure to set `twig_first` to `true` in `system.yaml`, like this: + +``` +pages: + twig_first: true +``` + +## Generating images + +This plugin does **not** leverage Grav's media caching mechanisms, it simply circumvenes the need for caching by assuming that images are generated outside of Grav. This is necessary because Grav currently uses the Gregwar library, which relies on PHP's GD-module for image manipulation, and it handles large or many images poorly - indeed it tends to crash both caching and Grav itself. Thus by creating the images outside of this system the same quality and automation is achieved. + +**For an example of generating responsive images with NodeJS and Gulp see [this gist](https://gist.github.com/OleVik/f2c8b51a7153743b13607072c27cf8d2).** + +## Widths + +The `widths` setting is a YAML sequence wherein each integer represents the width of the image, defaulting to: + +```yaml +- 320 +- 480 +- 640 +- 960 +- 1280 +- 1600 +- 1920 +- 2240 +``` + +## Sizes + +The `sizes` setting is a YAML string defining the [sizes](https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-sizes)-attribute, defaulting to: + +```yaml +sizes: "100vw" +``` + +## Images + +The plugin expects the images to be in the same folder as the source image. So, for the case of `street.jpg`, the page folder should contain: + +```bash +street.jpg +street-320.jpg +street-480.jpg +street-640.jpg +street-960.jpg +street-1280.jpg +street-1600.jpg +street-1920.jpg +street-2240.jpg +``` + +## Per Page Options + +Configuration-options may also be set on an individual Page, using the following FrontMatter: + +```yaml +imgsrcset: + enabled: true + widths: widths + sizes: sizes +``` + +MIT License 2019 by [Ole Vik](http://github.com/olevik). diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/blueprints.yaml b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/blueprints.yaml new file mode 100644 index 0000000..16f9ce1 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/blueprints.yaml @@ -0,0 +1,42 @@ +name: Image Srcset +version: 1.1.1 +testing: true +description: "Adds a srcset-attribute to img-elements to allow for responsive images in Markdown." +icon: picture-o +author: + name: Ole Vik + email: git@olevik.me + url: http://olevik.me +homepage: https://github.com/olevik/grav-plugin-imgsrcset +keywords: responsive, srcset +bugs: https://github.com/olevik/grav-plugin-imgsrcset/issues +license: MIT + +form: + validation: loose + fields: + enabled: + type: toggle + label: Plugin Status + highlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + widths: + type: selectize + label: Widths + description: Determines the available image sizes. Comma-separated list of widths. + classes: fancy + validate: + type: commalist + sizes: + type: text + size: x-small + label: Sizes + help: Determines the Sizes-attribute. + validate: + type: text + min: 1 diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/composer.json b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/composer.json new file mode 100644 index 0000000..9b9e71c --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "paquettg/php-html-parser": "^2.0.2" + } +} diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/composer.lock b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/composer.lock new file mode 100644 index 0000000..03ef294 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/composer.lock @@ -0,0 +1,114 @@ +{ + "_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#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "f38b95fb20b42face451f5eb678baf3e", + "packages": [ + { + "name": "paquettg/php-html-parser", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/paquettg/php-html-parser.git", + "reference": "77e4a44b0916690b4300fe9abf98fd05bbba48f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paquettg/php-html-parser/zipball/77e4a44b0916690b4300fe9abf98fd05bbba48f0", + "reference": "77e4a44b0916690b4300fe9abf98fd05bbba48f0", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "paquettg/string-encode": "~1.0.0", + "php": ">=7.1" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^7.5.1" + }, + "type": "library", + "autoload": { + "psr-0": { + "PHPHtmlParser": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gilles Paquette", + "email": "paquettg@gmail.com", + "homepage": "http://gillespaquette.ca" + } + ], + "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.", + "homepage": "https://github.com/paquettg/php-html-parser", + "keywords": [ + "dom", + "html", + "parser" + ], + "time": "2019-02-10T01:35:49+00:00" + }, + { + "name": "paquettg/string-encode", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/paquettg/string-encoder.git", + "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee", + "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5.1" + }, + "type": "library", + "autoload": { + "psr-0": { + "stringEncode": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gilles Paquette", + "email": "paquettg@gmail.com", + "homepage": "http://gillespaquette.ca" + } + ], + "description": "Facilitating the process of altering string encoding in PHP.", + "homepage": "https://github.com/paquettg/string-encoder", + "keywords": [ + "charset", + "encoding", + "string" + ], + "time": "2018-12-21T02:25:09+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/imgsrcset.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/imgsrcset.php new file mode 100644 index 0000000..ea25888 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/imgsrcset.php @@ -0,0 +1,84 @@ + + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link https://github.com/OleVik/grav-plugin-imgsrcset + */ +namespace Grav\Plugin; + +use Grav\Common\Data; +use Grav\Common\Plugin; +use Grav\Common\Grav; +use Grav\Common\Page\Page; +use RocketTheme\Toolbox\Event\Event; +use PHPHtmlParser\Dom; + +/** + * Adds a srcset-attribute to img-elements to allow for responsive images in Markdown + * + * Class ImgSrcsetPlugin + * + * @category Extensions + * @package Grav\Plugin + * @author Ole Vik + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link https://github.com/OleVik/grav-plugin-imgsrcset + */ +class ImgSrcsetPlugin extends Plugin +{ + + /** + * Register events with Grav + * + * @return array + */ + public static function getSubscribedEvents() + { + return [ + 'onPageContentProcessed' => ['onPageContentProcessed', 0] + ]; + } + + /** + * Iterates over images in page content and rewrites paths + * + * @return void + */ + public function onPageContentProcessed() + { + if ($this->isAdmin()) { + return; + } + $config = (array) $this->config->get('plugins.imgsrcset'); + $page = $this->grav['page']; + $config = $this->mergeConfig($page); + if ($config['enabled']) { + include __DIR__ . '/vendor/autoload.php'; + $dom = new Dom; + $dom->load($page->getRawContent()); + $images = $dom->find('img'); + $widths = $config['widths']; + foreach ($images as $image) { + $file = pathinfo($image->getAttribute('src')); + $dirname = $file['dirname']; + $filename = $file['filename']; + $extension = $file['extension']; + $srcsets = ''; + foreach ($widths as $width) { + $srcsets .= $dirname.'/'.$filename.'-'.$width.'.'.$extension.' '.$width.'w, '; + } + $srcsets = rtrim($srcsets, ", "); + $image->setAttribute('srcset', $srcsets); + $image->setAttribute('sizes', $config['sizes']); + } + $page->setRawContent($dom->outerHtml); + } + } +} diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/imgsrcset.yaml b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/imgsrcset.yaml new file mode 100644 index 0000000..70b3234 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/imgsrcset.yaml @@ -0,0 +1,11 @@ +enabled: true +widths: + - 320 + - 480 + - 640 + - 960 + - 1280 + - 1600 + - 1920 + - 2240 +sizes: "100vw" \ No newline at end of file diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/autoload.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/autoload.php new file mode 100644 index 0000000..a4a34bf --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/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])) { + foreach ($this->prefixDirsPsr4[$search] as $dir) { + $length = $this->prefixLengthsPsr4[$first][$search]; + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + 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/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/LICENSE b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/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/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_classmap.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/paquettg/string-encode/src'), + 'PHPHtmlParser' => array($vendorDir . '/paquettg/php-html-parser/src'), +); diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_psr4.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..b265c64 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_psr4.php @@ -0,0 +1,9 @@ += 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\ComposerStaticInite863a36850238c27fe275e4df5c3a50c::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/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_static.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_static.php new file mode 100644 index 0000000..c4a11e1 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/autoload_static.php @@ -0,0 +1,33 @@ + + array ( + 'stringEncode' => + array ( + 0 => __DIR__ . '/..' . '/paquettg/string-encode/src', + ), + ), + 'P' => + array ( + 'PHPHtmlParser' => + array ( + 0 => __DIR__ . '/..' . '/paquettg/php-html-parser/src', + ), + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixesPsr0 = ComposerStaticInite863a36850238c27fe275e4df5c3a50c::$prefixesPsr0; + + }, null, ClassLoader::class); + } +} diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/installed.json b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/installed.json new file mode 100644 index 0000000..adf05c6 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/composer/installed.json @@ -0,0 +1,102 @@ +[ + { + "name": "paquettg/string-encode", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/paquettg/string-encoder.git", + "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee", + "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5.1" + }, + "time": "2018-12-21T02:25:09+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "stringEncode": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gilles Paquette", + "email": "paquettg@gmail.com", + "homepage": "http://gillespaquette.ca" + } + ], + "description": "Facilitating the process of altering string encoding in PHP.", + "homepage": "https://github.com/paquettg/string-encoder", + "keywords": [ + "charset", + "encoding", + "string" + ] + }, + { + "name": "paquettg/php-html-parser", + "version": "2.0.2", + "version_normalized": "2.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/paquettg/php-html-parser.git", + "reference": "77e4a44b0916690b4300fe9abf98fd05bbba48f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paquettg/php-html-parser/zipball/77e4a44b0916690b4300fe9abf98fd05bbba48f0", + "reference": "77e4a44b0916690b4300fe9abf98fd05bbba48f0", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "paquettg/string-encode": "~1.0.0", + "php": ">=7.1" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^7.5.1" + }, + "time": "2019-02-10T01:35:49+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "PHPHtmlParser": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gilles Paquette", + "email": "paquettg@gmail.com", + "homepage": "http://gillespaquette.ca" + } + ], + "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.", + "homepage": "https://github.com/paquettg/php-html-parser", + "keywords": [ + "dom", + "html", + "parser" + ] + } +] diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/.gitattributes b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/.gitattributes new file mode 100644 index 0000000..afc2bfb --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/.gitattributes @@ -0,0 +1,10 @@ +/tests export-ignore +/.scrutinizar.yml export-ignore +/.travis.yml export-ignore +/.gitignore export-ignore +/CHANGELOG.md export-ignore +/CONTRIBUTING.md export-ignore +/LICENSE.md export-ignore +/README.md export-ignore +/phpunit.php export-ignore +/phpunit.xml export-ignore diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/.scrutinizer.yml b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/.scrutinizer.yml new file mode 100644 index 0000000..8b3532b --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/.scrutinizer.yml @@ -0,0 +1,41 @@ +filter: + paths: [src/*] + excluded_paths: [tests/*] +checks: + php: + code_rating: true + remove_extra_empty_lines: true + remove_php_closing_tag: true + remove_trailing_whitespace: true + fix_use_statements: + remove_unused: true + preserve_multiple: false + preserve_blanklines: true + order_alphabetically: true + fix_php_opening_tag: true + fix_linefeed: true + fix_line_ending: true + fix_identation_4spaces: true + fix_doc_comments: true +tools: + external_code_coverage: + timeout: 600 + runs: 3 + php_code_coverage: false + php_code_sniffer: + config: + standard: PSR2 + filter: + paths: ['src'] + php_loc: + enabled: true + excluded_dirs: [vendor, test] + php_cpd: + enabled: true + excluded_dirs: [vendor, test] +build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/composer.json b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/composer.json new file mode 100644 index 0000000..108b710 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/composer.json @@ -0,0 +1,33 @@ +{ + "name": "paquettg/php-html-parser", + "type": "library", + "version": "2.0.2", + "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.", + "keywords": ["html", "dom", "parser"], + "homepage": "https://github.com/paquettg/php-html-parser", + "license": "MIT", + "authors": [ + { + "name": "Gilles Paquette", + "email": "paquettg@gmail.com", + "homepage": "http://gillespaquette.ca" + } + ], + "require": { + "php": ">=7.1", + "ext-mbstring": "*", + "paquettg/string-encode": "~1.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5.1", + "mockery/mockery": "^1.2", + "php-coveralls/php-coveralls": "^2.1" + }, + "autoload": { + "psr-0": { + "PHPHtmlParser": "src/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Content.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Content.php new file mode 100644 index 0000000..0aa6b1c --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Content.php @@ -0,0 +1,254 @@ +'; + protected $slash = " />\r\n\t"; + protected $attr = ' >'; + + /** + * Content constructor. + * + * @param string $content + */ + public function __construct(string $content = '') + { + $this->content = $content; + $this->size = strlen($content); + $this->pos = 0; + } + + /** + * Returns the current position of the content. + * + * @return int + */ + public function getPosition(): int + { + return $this->pos; + } + + /** + * Gets the current character we are at. + * + * @param int $char + * @return string + */ + public function char(int $char = null): string + { + $pos = $this->pos; + if ( ! is_null($char)) { + $pos = $char; + } + + if ( ! isset($this->content[$pos])) { + return ''; + } + + return $this->content[$pos]; + } + + /** + * Moves the current position forward. + * + * @param int $count + * @return Content + * @chainable + */ + public function fastForward(int $count): Content + { + $this->pos += $count; + + return $this; + } + + /** + * Moves the current position backward. + * + * @param int $count + * @return Content + * @chainable + */ + public function rewind(int $count): Content + { + $this->pos -= $count; + if ($this->pos < 0) { + $this->pos = 0; + } + + return $this; + } + + /** + * Copy the content until we find the given string. + * + * @param string $string + * @param bool $char + * @param bool $escape + * @return string + */ + public function copyUntil(string $string, bool $char = false, bool $escape = false): string + { + if ($this->pos >= $this->size) { + // nothing left + return ''; + } + + if ($escape) { + $position = $this->pos; + $found = false; + while ( ! $found) { + $position = strpos($this->content, $string, $position); + if ($position === false) { + // reached the end + $found = true; + continue; + } + + if ($this->char($position - 1) == '\\') { + // this character is escaped + ++$position; + continue; + } + + $found = true; + } + } elseif ($char) { + $position = strcspn($this->content, $string, $this->pos); + $position += $this->pos; + } else { + $position = strpos($this->content, $string, $this->pos); + } + + if ($position === false) { + // could not find character, just return the remaining of the content + $return = substr($this->content, $this->pos, $this->size - $this->pos); + $this->pos = $this->size; + + return $return; + } + + if ($position == $this->pos) { + // we are at the right place + return ''; + } + + $return = substr($this->content, $this->pos, $position - $this->pos); + // set the new position + $this->pos = $position; + + return $return; + } + + /** + * Copies the content until the string is found and return it + * unless the 'unless' is found in the substring. + * + * @param string $string + * @param string $unless + * @return string + */ + public function copyUntilUnless(string $string, string $unless) + { + $lastPos = $this->pos; + $this->fastForward(1); + $foundString = $this->copyUntil($string, true, true); + + $position = strcspn($foundString, $unless); + if ($position == strlen($foundString)) { + return $string.$foundString; + } + // rewind changes and return nothing + $this->pos = $lastPos; + + return ''; + } + + /** + * Copies the content until it reaches the token string., + * + * @param string $token + * @param bool $char + * @param bool $escape + * @return string + * @uses $this->copyUntil() + */ + public function copyByToken(string $token, bool $char = false, bool $escape = false) + { + $string = $this->$token; + + return $this->copyUntil($string, $char, $escape); + } + + /** + * Skip a given set of characters. + * + * @param string $string + * @param bool $copy + * @return Content|string + */ + public function skip(string $string, bool $copy = false) + { + $len = strspn($this->content, $string, $this->pos); + + // make it chainable if they don't want a copy + $return = $this; + if ($copy) { + $return = substr($this->content, $this->pos, $len); + } + + // update the position + $this->pos += $len; + + return $return; + } + + /** + * Skip a given token of pre-defined characters. + * + * @param string $token + * @param bool $copy + * @return Content|string + * @uses $this->skip() + */ + public function skipByToken(string $token, bool $copy = false) + { + $string = $this->$token; + + return $this->skip($string, $copy); + } +} diff --git a/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Curl.php b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Curl.php new file mode 100644 index 0000000..8ce8fa3 --- /dev/null +++ b/tmp/Grav-5d9771f1b1ffd/OleVik-grav-plugin-imgsrcset-c25bfd7/vendor/paquettg/php-html-parser/src/PHPHtmlParser/Curl.php @@ -0,0 +1,46 @@ + at the end (html5 style) + * + * @var array + */ + protected $noSlash = []; + + /** + * Returns the inner html of the root node. + * + * @return string + */ + public function __toString(): string + { + return $this->root->innerHtml(); + } + + /** + * A simple wrapper around the root node. + * + * @param string $name + * @return mixed + */ + public function __get($name) + { + return $this->root->$name; + } + + /** + * Attempts to load the dom from any resource, string, file, or URL. + * + * @param string $str + * @param array $options + * @return Dom + * @chainable + */ + public function load(string $str, array $options = []): Dom + { + AbstractNode::resetCount(); + // check if it's a file + if (strpos($str, "\n") === false && is_file($str)) { + return $this->loadFromFile($str, $options); + } + // check if it's a url + if (preg_match("/^https?:\/\//i", $str)) { + return $this->loadFromUrl($str, $options); + } + + return $this->loadStr($str, $options); + } + + /** + * Loads the dom from a document file/url + * + * @param string $file + * @param array $options + * @return Dom + * @chainable + */ + public function loadFromFile(string $file, array $options = []): Dom + { + return $this->loadStr(file_get_contents($file), $options); + } + + /** + * Use a curl interface implementation to attempt to load + * the content from a url. + * + * @param string $url + * @param array $options + * @param CurlInterface $curl + * @return Dom + * @chainable + */ + public function loadFromUrl(string $url, array $options = [], CurlInterface $curl = null): Dom + { + if (is_null($curl)) { + // use the default curl interface + $curl = new Curl; + } + $content = $curl->get($url); + + return $this->loadStr($content, $options); + } + + /** + * Parsers the html of the given string. Used for load(), loadFromFile(), + * and loadFromUrl(). + * + * @param string $str + * @param array $option + * @return Dom + * @chainable + */ + public function loadStr(string $str, array $option = []): Dom + { + $this->options = new Options; + $this->options->setOptions($this->globalOptions) + ->setOptions($option); + + $this->rawSize = strlen($str); + $this->raw = $str; + + $html = $this->clean($str); + + $this->size = strlen($str); + $this->content = new Content($html); + + $this->parse(); + $this->detectCharset(); + + return $this; + } + + /** + * Sets a global options array to be used by all load calls. + * + * @param array $options + * @return Dom + * @chainable + */ + public function setOptions(array $options): Dom + { + $this->globalOptions = $options; + + return $this; + } + + /** + * Find elements by css selector on the root node. + * + * @param string $selector + * @param int $nth + * @return mixed + */ + public function find(string $selector, int $nth = null) + { + $this->isLoaded(); + + return $this->root->find($selector, $nth); + } + + /** + * Find element by Id on the root node + * + * @param int $id + * @return mixed + */ + public function findById(int $id) + { + $this->isLoaded(); + + return $this->root->findById($id); + } + + /** + * Adds the tag (or tags in an array) to the list of tags that will always + * be self closing. + * + * @param string|array $tag + * @return Dom + * @chainable + */ + public function addSelfClosingTag($tag): Dom + { + if ( ! is_array($tag)) { + $tag = [$tag]; + } + foreach ($tag as $value) { + $this->selfClosing[] = $value; + } + + return $this; + } + + /** + * Removes the tag (or tags in an array) from the list of tags that will + * always be self closing. + * + * @param string|array $tag + * @return Dom + * @chainable + */ + public function removeSelfClosingTag($tag): Dom + { + if ( ! is_array($tag)) { + $tag = [$tag]; + } + $this->selfClosing = array_diff($this->selfClosing, $tag); + + return $this; + } + + /** + * Sets the list of self closing tags to empty. + * + * @return Dom + * @chainable + */ + public function clearSelfClosingTags(): Dom + { + $this->selfClosing = []; + + return $this; + } + + + /** + * Adds a tag to the list of self closing tags that should not have a trailing slash + * + * @param $tag + * @return Dom + * @chainable + */ + public function addNoSlashTag($tag): Dom + { + if ( ! is_array($tag)) { + $tag = [$tag]; + } + foreach ($tag as $value) { + $this->noSlash[] = $value; + } + + return $this; + } + + /** + * Removes a tag from the list of no-slash tags. + * + * @param $tag + * @return Dom + * @chainable + */ + public function removeNoSlashTag($tag): Dom + { + if ( ! is_array($tag)) { + $tag = [$tag]; + } + $this->noSlash = array_diff($this->noSlash, $tag); + + return $this; + } + + /** + * Empties the list of no-slash tags. + * + * @return Dom + * @chainable + */ + public function clearNoSlashTags(): Dom + { + $this->noSlash = []; + + return $this; + } + + /** + * Simple wrapper function that returns the first child. + * + * @return \PHPHtmlParser\Dom\AbstractNode + */ + public function firstChild(): \PHPHtmlParser\Dom\AbstractNode + { + $this->isLoaded(); + + return $this->root->firstChild(); + } + + /** + * Simple wrapper function that returns the last child. + * + * @return \PHPHtmlParser\Dom\AbstractNode + */ + public function lastChild(): \PHPHtmlParser\Dom\AbstractNode + { + $this->isLoaded(); + + return $this->root->lastChild(); + } + + /** + * Simple wrapper function that returns count of child elements + * + * @return int + */ + public function countChildren(): int + { + $this->isLoaded(); + + return $this->root->countChildren(); + } + + /** + * Get array of children + * + * @return array + */ + public function getChildren(): array + { + $this->isLoaded(); + + return $this->root->getChildren(); + } + + /** + * Check if node have children nodes + * + * @return bool + */ + public function hasChildren(): bool + { + $this->isLoaded(); + + return $this->root->hasChildren(); + } + + /** + * Simple wrapper function that returns an element by the + * id. + * + * @param string $id + * @return \PHPHtmlParser\Dom\AbstractNode|null + */ + public function getElementById($id) + { + $this->isLoaded(); + + return $this->find('#'.$id, 0); + } + + /** + * Simple wrapper function that returns all elements by + * tag name. + * + * @param string $name + * @return mixed + */ + public function getElementsByTag(string $name) + { + $this->isLoaded(); + + return $this->find($name); + } + + /** + * Simple wrapper function that returns all elements by + * class name. + * + * @param string $class + * @return mixed + */ + public function getElementsByClass(string $class) + { + $this->isLoaded(); + + return $this->find('.'.$class); + } + + /** + * Checks if the load methods have been called. + * + * @throws NotLoadedException + */ + protected function isLoaded(): void + { + if (is_null($this->content)) { + throw new NotLoadedException('Content is not loaded!'); + } + } + + /** + * Cleans the html of any none-html information. + * + * @param string $str + * @return string + */ + protected function clean(string $str): string + { + if ($this->options->get('cleanupInput') != true) { + // skip entire cleanup step + return $str; + } + + // remove white space before closing tags + $str = mb_eregi_replace("'\s+>", "'>", $str); + $str = mb_eregi_replace('"\s+>', '">', $str); + + // clean out the \n\r + $replace = ' '; + if ($this->options->get('preserveLineBreaks')) { + $replace = ' '; + } + $str = str_replace(["\r\n", "\r", "\n"], $replace, $str); + + // strip the doctype + $str = mb_eregi_replace("", '', $str); + + // strip out comments + $str = mb_eregi_replace("", '', $str); + + // strip out cdata + $str = mb_eregi_replace("", '', $str); + + // strip out + {% endif %} +{% endblock %} + +{% block header_navigation %} + + {% if show_onpage_menu %} + + {% else %} + {{ parent() }} + {% endif %} +{% endblock %} + +{% block hero %} + {% for module in page.collection() if module.template == 'modular/hero' %} +
+ {{ module.content|raw }} + {% endfor %} +{% endblock %} + +{% block body %} + {% for module in page.collection() if module.template != 'modular/hero' %} +
+ {{ module.content|raw }} + {% endfor %} +{% endblock %} diff --git a/user/themes/figureslibres/css-compiled/templates/modular/features.html.twig b/user/themes/figureslibres/css-compiled/templates/modular/features.html.twig new file mode 100644 index 0000000..46fe7f3 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/modular/features.html.twig @@ -0,0 +1,30 @@ +{% set grid_size = theme_var('grid-size') %} +{% set columns = page.header.class == 'small' ? 'col-3 col-md-4 col-sm-6' : 'col-4 col-md-6 col-sm-12' %} +
+
+
+ + {{ content|raw }} + +
+ {% for feature in page.header.features %} +
+ {% if feature.url %}{% endif %} +
+ + {% if feature.header %} +
{{ feature.header }}
+ {% endif %} +
+ {% if feature.url %}
{% endif %} +
+ {% if feature.text %} +

{{ feature.text }}

+ {% endif %} +
+
+ {% endfor %} +
+
+
+
diff --git a/user/themes/figureslibres/css-compiled/templates/modular/hero.html.twig b/user/themes/figureslibres/css-compiled/templates/modular/hero.html.twig new file mode 100644 index 0000000..7dbba44 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/modular/hero.html.twig @@ -0,0 +1,4 @@ +{% set grid_size = theme_var('grid-size') %} +{% set hero_image = page.header.hero_image ? page.media[page.header.hero_image] : page.media.images|first %} + +{% include 'partials/hero.html.twig' %} diff --git a/user/themes/figureslibres/css-compiled/templates/modular/text.html.twig b/user/themes/figureslibres/css-compiled/templates/modular/text.html.twig new file mode 100644 index 0000000..fcf2570 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/modular/text.html.twig @@ -0,0 +1,23 @@ +{% set grid_size = theme_var('grid-size') %} +{% set image = page.media.images|first %} + +
+
+
+ {% if image %} +
+ {{ content|raw }} +
+
+ {% if image %} + {{ image.html|raw }} + {% endif %} +
+ {% else %} +
+ {{ content|raw }} +
+ {% endif %} +
+
+
diff --git a/user/themes/figureslibres/css-compiled/templates/partials/base.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/base.html.twig new file mode 100644 index 0000000..028ba19 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/base.html.twig @@ -0,0 +1,59 @@ +{% set body_classes = body_class(['header-fixed', 'header-animated', 'header-dark', 'header-transparent', 'sticky-footer']) %} +{% set grid_size = theme_var('grid-size') %} +{% set compress = theme_var('production-mode') ? '.min.css' : '.css' %} + + + + +{% block head %} + + {% if header.title %}{{ header.title|e('html') }} | {% endif %}{{ site.title|e('html') }} + + + + {% include 'partials/metadata.html.twig' %} + + + + + {% block stylesheets %} + {% do assets.addCss('theme://css/hamburgers.css') %} + {% do assets.addCss('theme://css-compiled/theme'~compress) %} + {% endblock %} + {{ assets.css()|raw }} + + {% block javascripts %} + {% do assets.addJs('theme://js/jquery-3.4.1.min.js', {group:'bottom'}) %} + {% do assets.addJs('theme://js/jquery.lazy.min.js', {group:'bottom'}) %} + {% do assets.addJs('theme://js/site.js', {group:'bottom'}) %} + {% endblock %} + + {{ assets.js()|raw }} + +{% endblock head %} + + + {% block header %} + {% endblock %} +
+ {% block body %} +
+ + {% block content %} + + {% endblock %} +
+ + {% block aside %} + {% include 'partials/sidebar.html.twig' %} + {% endblock %} + + {% endblock %} + + +{% block bottom %} + {{ assets.js('bottom')|raw }} +{% endblock %} + + + diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog-item.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog-item.html.twig new file mode 100644 index 0000000..0a8ca2c --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog-item.html.twig @@ -0,0 +1,18 @@ +
+ {% include 'partials/blog/title.html.twig' with {title_level: 'h2'} %} +
+ {% include 'partials/blog/taxonomy.html.twig' %} + {% include 'partials/blog/date.html.twig' %} +
+ +
+ +
+ {{ page.content|raw }} +
+ +
+{% for image in page.media.images %} + images +{% endfor %} +
diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog-list-item.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog-list-item.html.twig new file mode 100644 index 0000000..e4465cd --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog-list-item.html.twig @@ -0,0 +1,42 @@ +{% macro pageLinkName(text) %}{{ text|lower|replace({' ':'-', 'é':'e', ',':'',':':'','.':'','(':'',')':'','?':'', "’": '','ê':'e' }) }}{% endmacro %} + +{% import _self as macro %} + +{% set image = page.media.images|first %} + +{% if image %} + + + {% else %} + +
+
+ +
+ {% if page.header.title %} + {% include 'partials/blog/title.html.twig' with {title_level: 'h2'} %} + {% endif %} +
+ +
+
+{% endif %} diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog/date.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog/date.html.twig new file mode 100644 index 0000000..a78caf0 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog/date.html.twig @@ -0,0 +1,6 @@ + + + + diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog/other_projets.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog/other_projets.html.twig new file mode 100644 index 0000000..cb0f4f7 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog/other_projets.html.twig @@ -0,0 +1,32 @@ +
+

Les autres projets {{page.parent.title|lower}}s

+ {% set collection_random = page.parent.collection|slice(1,4) %} + + {% for item in collection_random %} + {% if item.title == page.title == false %} +
+ +
+ {% if item.header.title %} + {% include 'partials/blog/title.html.twig' with { 'page': item } %} + {% endif %} + {% if item.header.taxonomy.tag %} + + {% include 'partials/blog/taxonomy.html.twig' with { 'page': item } %} + {% endif %} + {% if item.header.date %} + + {% include 'partials/blog/date.html.twig' with { 'page': item } %} + {% endif %} + +
+
+ {% endif %} + {% endfor %} +
diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog/page-summary.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog/page-summary.html.twig new file mode 100644 index 0000000..3c8fb7f --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog/page-summary.html.twig @@ -0,0 +1,8 @@ +
+ {% if page.summary != page.content %} + {{ page.summary|raw }} + {% else %} + {{ page.content|raw }} + {% endif %} +
+ diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog/taxonomy.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog/taxonomy.html.twig new file mode 100644 index 0000000..86858cd --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog/taxonomy.html.twig @@ -0,0 +1,8 @@ +{% if page.taxonomy.tag %} + + + {% for tag in page.taxonomy.tag %} + {{ tag }} + {% endfor %} + +{% endif %} diff --git a/user/themes/figureslibres/css-compiled/templates/partials/blog/title.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/blog/title.html.twig new file mode 100644 index 0000000..9bfe9eb --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/blog/title.html.twig @@ -0,0 +1,12 @@ +{% set title_level = title_level ?: 'h2' %} + +{% if page.header.link %} + <{{ title_level }}> + {% if page.header.continue_link is not same as(false) %} + + {% endif %} + {{ page.title }} + +{% else %} + <{{ title_level }}>{{ page.title }} +{% endif %} diff --git a/user/themes/figureslibres/css-compiled/templates/partials/footer.html.twig b/user/themes/figureslibres/css-compiled/templates/partials/footer.html.twig new file mode 100644 index 0000000..4365822 --- /dev/null +++ b/user/themes/figureslibres/css-compiled/templates/partials/footer.html.twig @@ -0,0 +1,2 @@ +