diff --git a/pages/01.blog/eu-bans-metas-use-of-personal-data-for-behavioural-advertising/item.en.md b/pages/01.blog/eu-bans-metas-use-of-personal-data-for-behavioural-advertising/item.en.md new file mode 100644 index 0000000..60d30b3 --- /dev/null +++ b/pages/01.blog/eu-bans-metas-use-of-personal-data-for-behavioural-advertising/item.en.md @@ -0,0 +1,34 @@ +--- +title: 'EU bans Meta''s use of personal data for behavioural advertising' +author: Dan +published: true +date: '11-11-2023 23:34' +taxonomy: + category: + - news + tag: + - facebook + - meta + - ban + - EU +aura: + author: dan +--- + +The European Data Protection Board said Wednesday it had adopted a binding decision that will ban Facebook and Instagram owner Meta from using the personal data of users for targeted advertisements. + +The order will "impose a ban on the processing of personal data for behavioural advertising on the legal bases of contract and legitimate interest across the entire European Economic Area," the EDPB said. + +The order comes after Meta said on Monday that Facebook and Instagram users in Europe will be able to buy subscriptions to use the social networks without any advertising from this month. + +"Meta has already announced that we will give people in the EU and EEA the opportunity to consent and, in November, will offer a subscriptions model to comply with regulatory requirements," a Meta representative said. + +The company said EDPB members have been aware of its consent plan for weeks and that it had been fully engaged with them to arrive at a satisfactory outcome. + +"This development unjustifiably ignores that careful and robust regulatory process," the company representative added. + +The EDPB said it took the decision following a request from Norway's data regulator, which earlier this year imposed a ban on sending Facebook and Instagram users targeted advertisements based on their personal data which the social media platform collects without their explicit consent. + +The EDPB decision forces Ireland's data regulator, which has authority over Meta's operations in Europe, to take final measures on the issue within two weeks, with a ban to enter force a week later. + +More at https://www.france24.com/en/live-news/20231101-eu-bans-meta-s-use-of-personal-data-for-behavioural-advertising \ No newline at end of file diff --git a/plugins/admin/CHANGELOG.md b/plugins/admin/CHANGELOG.md index a7e2136..1deda30 100644 --- a/plugins/admin/CHANGELOG.md +++ b/plugins/admin/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.10.43 +## 10/02/2023 + +1. [](#improved) + * Updated vendor libraries + # v1.10.42 ## 06/14/2023 diff --git a/plugins/admin/blueprints.yaml b/plugins/admin/blueprints.yaml index 41dae90..fe8b66e 100644 --- a/plugins/admin/blueprints.yaml +++ b/plugins/admin/blueprints.yaml @@ -1,7 +1,7 @@ name: Admin Panel slug: admin type: plugin -version: 1.10.42 +version: 1.10.43 description: Adds an advanced administration panel to manage your site icon: empire author: diff --git a/plugins/admin/composer.lock b/plugins/admin/composer.lock index 633fd39..6e850a0 100644 --- a/plugins/admin/composer.lock +++ b/plugins/admin/composer.lock @@ -816,16 +816,16 @@ }, { "name": "guzzlehttp/promises", - "version": "1.5.2", + "version": "1.5.3", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "b94b2807d85443f9719887892882d0329d1e2598" + "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", - "reference": "b94b2807d85443f9719887892882d0329d1e2598", + "url": "https://api.github.com/repos/guzzle/promises/zipball/67ab6e18aaa14d753cc148911d273f6e6cb6721e", + "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e", "shasum": "" }, "require": { @@ -835,11 +835,6 @@ "symfony/phpunit-bridge": "^4.4 || ^5.1" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5-dev" - } - }, "autoload": { "files": [ "src/functions_include.php" @@ -880,7 +875,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.2" + "source": "https://github.com/guzzle/promises/tree/1.5.3" }, "funding": [ { @@ -896,7 +891,7 @@ "type": "tidelift" } ], - "time": "2022-08-28T14:55:35+00:00" + "time": "2023-05-21T12:31:43+00:00" }, { "name": "guzzlehttp/psr7", @@ -3184,16 +3179,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "shasum": "" }, "require": { @@ -3208,7 +3203,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3246,7 +3241,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -3262,20 +3257,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "639084e360537a19f9ee352433b84ce831f3d2da" + "reference": "ecaafce9f77234a6a449d29e49267ba10499116d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/639084e360537a19f9ee352433b84ce831f3d2da", - "reference": "639084e360537a19f9ee352433b84ce831f3d2da", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/ecaafce9f77234a6a449d29e49267ba10499116d", + "reference": "ecaafce9f77234a6a449d29e49267ba10499116d", "shasum": "" }, "require": { @@ -3289,7 +3284,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3333,7 +3328,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.28.0" }, "funding": [ { @@ -3349,20 +3344,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:30:37+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "shasum": "" }, "require": { @@ -3374,7 +3369,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3417,7 +3412,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" }, "funding": [ { @@ -3433,20 +3428,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -3461,7 +3456,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3500,7 +3495,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" }, "funding": [ { @@ -3516,20 +3511,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -3538,7 +3533,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3583,7 +3578,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -3599,7 +3594,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/process", diff --git a/plugins/admin/vendor/composer/ClassLoader.php b/plugins/admin/vendor/composer/ClassLoader.php index a72151c..7824d8f 100644 --- a/plugins/admin/vendor/composer/ClassLoader.php +++ b/plugins/admin/vendor/composer/ClassLoader.php @@ -45,35 +45,34 @@ class ClassLoader /** @var \Closure(string):void */ private static $includeFile; - /** @var ?string */ + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -81,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -90,21 +88,20 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { @@ -113,7 +110,7 @@ class ClassLoader } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -125,8 +122,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -134,8 +130,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -143,8 +138,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -152,8 +146,7 @@ class ClassLoader } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -161,8 +154,7 @@ class ClassLoader } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -179,24 +171,25 @@ class ClassLoader * 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 string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -205,19 +198,19 @@ class ClassLoader $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -226,9 +219,9 @@ class ClassLoader * 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 string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -236,17 +229,18 @@ class ClassLoader */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -256,18 +250,18 @@ class ClassLoader 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; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -276,8 +270,8 @@ class ClassLoader * 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 string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -294,8 +288,8 @@ class ClassLoader * 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 string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -481,9 +475,9 @@ class ClassLoader } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { diff --git a/plugins/admin/vendor/composer/installed.php b/plugins/admin/vendor/composer/installed.php index df62166..80176de 100644 --- a/plugins/admin/vendor/composer/installed.php +++ b/plugins/admin/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'getgrav/grav-plugin-admin', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'be85fb4194474700fbd8fe60b48b27613b47ce59', + 'reference' => '8c17ca7d75e271ee2cf4e38ae54e75d2ce8b9224', 'type' => 'grav-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'getgrav/grav-plugin-admin' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'be85fb4194474700fbd8fe60b48b27613b47ce59', + 'reference' => '8c17ca7d75e271ee2cf4e38ae54e75d2ce8b9224', 'type' => 'grav-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/plugins/feed/CHANGELOG.md b/plugins/feed/CHANGELOG.md index 6536be4..7e16ba5 100644 --- a/plugins/feed/CHANGELOG.md +++ b/plugins/feed/CHANGELOG.md @@ -1,3 +1,11 @@ +# v1.10.0 +## 09/26/2023 + +1. [](#new) + * Allow template overrides based on header feed config [#67](https://github.com/getgrav/grav-plugin-feed/pull/67) +1. [](#bugfix) + * Fixed the `` that was broken + # v1.9.0 ## 10/05/2022 diff --git a/plugins/feed/README.md b/plugins/feed/README.md index 580acc7..10417bc 100644 --- a/plugins/feed/README.md +++ b/plugins/feed/README.md @@ -131,6 +131,17 @@ Manually updating Feed is pretty simple. Here is what you will need to do to get > Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in `user/config/plugins`) will remain intact. +## Overriding the default feed template: + +Sometimes, you may wish to use a different template for an RSS/ ATOM/ JSON feed. To override a feed's template, place the following in the page header: +``` yaml +feed: + template: + rss: my-override +``` + +Create the `my-override.rss.twig` in your theme/ plugin's `templates` folder and add it to your [twig template paths](https://learn.getgrav.org/17/cookbook/plugin-recipes#custom-twig-templates-plu). Change `*.rss.*` to `*.atom.*` or `*.json.*` to override those page types. + ## Nginx Note: If you are having trouble with 404s with Nginx, it might be related to your configuration. You may need to remove the feed extensions from the list of types to cache as static files: `.xml`, `.rss`, and `.atom`. For example: diff --git a/plugins/feed/blueprints.yaml b/plugins/feed/blueprints.yaml index 1bf6696..665bef9 100644 --- a/plugins/feed/blueprints.yaml +++ b/plugins/feed/blueprints.yaml @@ -1,7 +1,7 @@ name: Feed type: plugin slug: feed -version: 1.9.0 +version: 1.10.0 description: The **Feed** plugin is a simple yet powerful add-on that lets you view a Grav Collection as **JSON**, **RSS** or **Atom** news feed. icon: rss author: diff --git a/plugins/feed/feed.php b/plugins/feed/feed.php index ecd3440..d676d71 100644 --- a/plugins/feed/feed.php +++ b/plugins/feed/feed.php @@ -78,7 +78,6 @@ class FeedPlugin extends Plugin $this->type = $uri->extension(); if ($this->type && in_array($this->type, $this->valid_types)) { - $this->enable([ 'onPageInitialized' => ['onPageInitialized', 0], 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], @@ -95,19 +94,27 @@ class FeedPlugin extends Plugin // Overwrite regular content with feed config, so you can influence the collection processing with feed config if (property_exists($page->header(), 'content')) { + // Set default template. + $template = "feed"; + if (isset($page->header()->feed)) { $this->feed_config = array_merge($this->feed_config, $page->header()->feed); + + // Look for feed type override, + if (isset($this->feed_config['template']) && isset($this->feed_config['template'][$this->type])) { + $template = $this->feed_config['template'][$this->type]; + } } $page->header()->content = array_merge($page->header()->content, $this->feed_config); - $this->grav['twig']->template = 'feed.' . $this->type . '.twig'; + // Set page template. + $this->grav['twig']->template = $template . "." . $this->type . '.twig'; $this->enable([ 'onCollectionProcessed' => ['onCollectionProcessed', 0], ]); } - } /** @@ -175,4 +182,4 @@ class FeedPlugin extends Plugin $headers->{'Content-Type'} = "$content_type; charset=utf-8"; } } -} \ No newline at end of file +} diff --git a/plugins/feed/templates/feed.rss.twig b/plugins/feed/templates/feed.rss.twig index c2000b5..0a32d38 100644 --- a/plugins/feed/templates/feed.rss.twig +++ b/plugins/feed/templates/feed.rss.twig @@ -4,7 +4,7 @@ {% for page in collection %} {%- set lastBuildDate = max(lastBuildDate, page.date) %} {%- if collection.params.show_last_modified %} - {%- set lastBuildDate = max(feed_updated, page.modified) %} + {%- set lastBuildDate = max(lastBuildDate, page.modified) %} {%- endif %} {% endfor %} diff --git a/plugins/flex-objects/CHANGELOG.md b/plugins/flex-objects/CHANGELOG.md index f18cefa..c71207d 100644 --- a/plugins/flex-objects/CHANGELOG.md +++ b/plugins/flex-objects/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.3.6 +## 10/11/2023 + +1. [](#new) + * Added a new `onAdminObjectGet()` event to allow for manipulation of flex objects + # v1.3.5 ## 05/09/2023 diff --git a/plugins/flex-objects/blueprints.yaml b/plugins/flex-objects/blueprints.yaml index b08cf3f..0077ac8 100644 --- a/plugins/flex-objects/blueprints.yaml +++ b/plugins/flex-objects/blueprints.yaml @@ -1,7 +1,7 @@ name: Flex Objects slug: flex-objects type: plugin -version: 1.3.5 +version: 1.3.6 description: Flex Objects plugin allows you to manage Flex Objects in Grav Admin. icon: list-alt author: diff --git a/plugins/flex-objects/classes/Admin/AdminController.php b/plugins/flex-objects/classes/Admin/AdminController.php index 3ba9242..1a35531 100644 --- a/plugins/flex-objects/classes/Admin/AdminController.php +++ b/plugins/flex-objects/classes/Admin/AdminController.php @@ -1579,6 +1579,8 @@ class AdminController } } + $this->grav->fireEvent('onAdminObjectGet', new Event(['object' => $this->object])); + return $this->object ?: null; } diff --git a/plugins/sitemap/CHANGELOG.md b/plugins/sitemap/CHANGELOG.md index dda4742..92009a0 100644 --- a/plugins/sitemap/CHANGELOG.md +++ b/plugins/sitemap/CHANGELOG.md @@ -1,3 +1,25 @@ +# v5.0.0 +## 10/05/2023 + +1. [](#new) + * New capability to support "standalone" Sitemap News pages + * New XSL format for Sitemap News + * Added a toggle for XSL transform support to be disabled +1. [](#improved) + * Improved blueprint and created sections + * Hide `x-default` alternate links when `include_default_lang` is enabled +1. [](#bugfix) + * Fixed an issue with translated links were not being handled properly and not showing all alternate languages + +# v4.0.0 +## 09/22/2023 + +1. [](#new) + * Added support for Google News tags [#93](https://github.com/getgrav/grav-plugin-sitemap/pull/93) + * Enhanced Google News to allow restriction to paths and configurable max-age in days +1. [](#improved) + * Added YAML syntax highlighting in README.md [#101](https://github.com/getgrav/grav-plugin-sitemap/pull/101) + # v3.0.2 ## 06/14/2022 diff --git a/plugins/sitemap/README.md b/plugins/sitemap/README.md index e59b778..1213951 100644 --- a/plugins/sitemap/README.md +++ b/plugins/sitemap/README.md @@ -1,6 +1,6 @@ # Grav Sitemap Plugin -`Sitemap` is a [Grav](http://github.com/getgrav/grav) Plugin that generates a [map of your pages](http://en.wikipedia.org/wiki/Site_map) in `XML` format that is easily understandable and indexable by Search engines. +`Sitemap` is a [Grav](https://github.com/getgrav/grav) Plugin that generates a [map of your pages](https://en.wikipedia.org/wiki/Site_map) in `XML` format that is easily understandable and indexable by Search engines. # Installation @@ -8,7 +8,7 @@ Installing the Sitemap plugin can be done in one of two ways. Our GPM (Grav Pack ## GPM Installation (Preferred) -The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type: +The simplest way to install this plugin is via the [Grav Package Manager (GPM)](https://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type: bin/gpm install sitemap @@ -16,13 +16,13 @@ This will install the Sitemap plugin into your `/user/plugins` directory within ## Manual Installation -To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `sitemap`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-sitemap) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras). +To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `sitemap`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-sitemap) or via [GetGrav.org](https://getgrav.org/downloads/plugins#extras). You should now have all the plugin files under /your/site/grav/user/plugins/sitemap ->> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate. +>> NOTE: This plugin is a modular component for Grav which requires [Grav](https://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate. # Usage @@ -31,7 +31,7 @@ The `sitemap` plugin works out of the box. You can just go directly to `http://y ## Config Defaults -``` +```yaml enabled: true route: '/sitemap' ignore_external: true @@ -41,9 +41,16 @@ ignores: - /blog/blog-post-to-ignore - /ignore-this-route - /ignore-children-of-this-route/.* +include_news_tags: false +standalone_sitemap_news: false +sitemap_news_path: '/sitemap-news.xml' +news_max_age_days: 2 +news_enabled_paths: + - /blog whitelist: html_support: false urlset: 'http://www.sitemaps.org/schemas/sitemap/0.9' +urlnewsset: 'http://www.google.com/schemas/sitemap-news/0.9' short_date_format: true include_changefreq: true changefreq: daily @@ -64,7 +71,7 @@ additions: You can ignore your own pages by providing a list of routes to ignore. You can also use a page's Frontmatter to signal that the sitemap should ignore it: -``` +```yaml sitemap: ignore: true ``` @@ -75,11 +82,27 @@ The latest Sitemap `v3.0` includes all new multi-language support utilizing the This is handled automatically based on your Grav multi-language System configuration. +### News Support + +New in version 4.0 of the plugin is support for Google's [**News Sitemap Extension**](https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap) that uses a specific tags under a `` tag to provide Google News specific data. When enabled, the news extensions will be enabled when an item is in one of the configured news paths (`/` by default, so all), and if the published date is not older than the configured `max age` (default of 2 per Googles recommendations). + +The output of the news tags is controlled by an overridable `sitemap-extensions/news.html.twig` template. + +The default behavior when **Include News Tags** is enabled, is to include the news tags directly in the primary `sitemap.xml` file. However, if you enabled the **Standalone News URLs** option, news tags will not be added to the primary `sitemap.xml`, rather, they will be available in standalone paths that contain only the pages in the designated news paths. + +For example, the default behavior is to enable `/blog` as a news path. If this path exists, you have content in subfolders of this page, and that content is less than the defined "News Max Age" (2 days recommended by Google), then that sitemap-news-specific sitemap would be available via: + +``` +https://yoursite.com/blog/sitemap-news.xml +``` + +You can change the "News Path" to be something other than `sitemap-news.xml` if you wish. + ## Images You can add images to the sitemap by adding an entry in the page's Frontmatter. -``` +```yaml sitemap: images: your_image: @@ -108,7 +131,7 @@ You can copy and extend this Twig template in your theme to customize it for you You can manually add URLs to the sitemap using the Admin settings, or by adding entries to your `sitemap.yaml` with this format: -``` +```yaml additions: - location: /something-special @@ -122,7 +145,7 @@ Note that Regex support is available: Just append `.*` to a path to ignore all o If you have some dynamic content being added to your site via another plugin, or perhaps a 3rd party API, you can now add them dynamically to the sitemap with a simple event: -Make sure you are subscribed to the `` event then add simply add your entry to the sitemap like this: +Make sure you are subscribed to the `onSitemapProcessed` event then add simply add your entry to the sitemap like this: ```php public function onSitemapProcessed(\RocketTheme\Toolbox\Event\Event $e) diff --git a/plugins/sitemap/blueprints.yaml b/plugins/sitemap/blueprints.yaml index 61a03f0..fdf37b3 100644 --- a/plugins/sitemap/blueprints.yaml +++ b/plugins/sitemap/blueprints.yaml @@ -1,8 +1,8 @@ name: Sitemap type: plugin slug: sitemap -version: 3.0.2 -description: "Provide automatically generated **XML sitemaps** with this very useful, but simple to configure, Grav plugin." +version: 5.0.0 +description: "Provide automatically generated **XML sitemaps** with this very useful, as a simple to configure Grav plugin." icon: map-marker author: name: Team Grav @@ -30,6 +30,14 @@ form: validate: type: bool + route: + type: text + size: medium + label: PLUGIN_SITEMAP.ROUTE + placeholder: /sitemap + validate: + pattern: "/([a-z-_]+/?)+" + multilang_enabled: type: toggle label: PLUGIN_SITEMAP.MULTILANG_ENABLED @@ -78,19 +86,17 @@ form: validate: type: bool - ignores: - type: array - label: PLUGIN_SITEMAP.IGNORES - help: PLUGIN_SITEMAP.IGNORES_HELP - value_only: true - placeholder_value: '/ignore-this-route' - - route: - type: text - label: PLUGIN_SITEMAP.ROUTE - placeholder: /sitemap + xsl_transform: + type: toggle + label: PLUGIN_SITEMAP.XSL_TRANSFORM + help: PLUGIN_SITEMAP.XSL_TRANSFORM_HELP + highlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED validate: - pattern: "/([a-z-_]+/?)+" + type: bool html_support: type: toggle @@ -104,97 +110,95 @@ form: validate: type: bool - urlset: - type: text - default: 'http://www.sitemaps.org/schemas/sitemap/0.9' - label: PLUGIN_SITEMAP.URLSET - help: PLUGIN_SITEMAP.URLSET_HELP + ignores: + type: array + label: PLUGIN_SITEMAP.IGNORES + help: PLUGIN_SITEMAP.IGNORES_HELP + value_only: true + placeholder_value: '/ignore-this-route' - short_date_format: - type: toggle - label: PLUGIN_ADMIN.SHORT_DATE_FORMAT - help: PLUGIN_ADMIN.SHORT_DATE_FORMAT_HELP - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - include_changefreq: - type: toggle - label: PLUGIN_SITEMAP.INCLUDE_CHANGEFREQ - help: PLUGIN_SITEMAP.INCLUDE_CHANGEFREQ_HELP - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - changefreq: - type: select - label: PLUGIN_SITEMAP.CHANGEFREQ - default: '' - options: - '': PLUGIN_SITEMAP.CHANGEFREQ_DEFAULT - always: PLUGIN_SITEMAP.CHANGEFREQ_ALWAYS - hourly: PLUGIN_SITEMAP.CHANGEFREQ_HOURLY - daily: PLUGIN_SITEMAP.CHANGEFREQ_DAILY - weekly: PLUGIN_SITEMAP.CHANGEFREQ_WEEKLY - monthly: PLUGIN_SITEMAP.CHANGEFREQ_MONTHLY - yearly: PLUGIN_SITEMAP.CHANGEFREQ_YEARLY - never: PLUGIN_SITEMAP.CHANGEFREQ_NEVER - - include_priority: - type: toggle - label: PLUGIN_SITEMAP.INCLUDE_PRIORITY - help: PLUGIN_SITEMAP.INCLUDE_PRIORITY_HELP - highlight: 1 - default: 0 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - priority: - type: select - label: PLUGIN_SITEMAP.PRIORITY - default: '' - options: - '': PLUGIN_SITEMAP.PRIORITY_USE_GLOBAL - '0.1': 0.1 - '0.2': 0.2 - '0.3': 0.3 - '0.4': 0.4 - '0.5': 0.5 - '0.6': 0.6 - '0.7': 0.7 - '0.8': 0.8 - '0.9': 0.9 - '1.0': 1.0 - validate: - type: float - - additions: - type: list - label: PLUGIN_SITEMAP.ADDITIONS - help: PLUGIN_SITEMAP.ADDITIONS_HELP + news_section: + type: section + title: Sitemap News + underline: true fields: - .location: + + include_news_tags: + type: toggle + label: PLUGIN_SITEMAP.INCLUDE_NEWS_TAGS + help: PLUGIN_SITEMAP.INCLUDE_NEWS_TAGS_HELP + highlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + standalone_sitemap_news: + type: toggle + label: PLUGIN_SITEMAP.STANDALONE_SITEMAP_NEWS + help: PLUGIN_SITEMAP.STANDALONE_SITEMAP_NEWS_HELP + highlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + sitemap_news_path: type: text - label: PLUGIN_SITEMAP.LOCATION - placeholder: "/not-a-grav-url" - .lastmod: - type: text - label: PLUGIN_SITEMAP.LASTMOD - placeholder: "2017-04-06" - .changefreq: + size: medium + label: PLUGIN_SITEMAP.SITEMAP_NEWS_PATH + help: PLUGIN_SITEMAP.SITEMAP_NEWS_PATH_HELP + + news_max_age_days: + type: number + default: 2 + size: x-small + label: PLUGIN_SITEMAP.NEWS_MAX_AGE_DAYS + append: Days + validate: + type: int + + news_enabled_paths: + type: array + label: PLUGIN_SITEMAP.NEWS_TAG_PATHS + value_only: true + placeholder_value: '/news' + + data_section: + type: section + title: Sitemap Data + underline: true + fields: + + date_type: type: select + label: PLUGIN_SITEMAP.DATE_TYPE + default: page_date + size: medium + options: + page_date: PLUGIN_SITEMAP.DATE_TYPE_PAGE_DATE + last_modified: PLUGIN_SITEMAP.DATE_TYPE_LAST_MODIFIED + + include_changefreq: + type: toggle + label: PLUGIN_SITEMAP.INCLUDE_CHANGEFREQ + help: PLUGIN_SITEMAP.INCLUDE_CHANGEFREQ_HELP + highlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + changefreq: + type: select + size: medium label: PLUGIN_SITEMAP.CHANGEFREQ default: '' options: @@ -206,9 +210,23 @@ form: monthly: PLUGIN_SITEMAP.CHANGEFREQ_MONTHLY yearly: PLUGIN_SITEMAP.CHANGEFREQ_YEARLY never: PLUGIN_SITEMAP.CHANGEFREQ_NEVER - .priority: + + include_priority: + type: toggle + label: PLUGIN_SITEMAP.INCLUDE_PRIORITY + help: PLUGIN_SITEMAP.INCLUDE_PRIORITY_HELP + highlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + priority: type: select label: PLUGIN_SITEMAP.PRIORITY + size: small default: '' options: '': PLUGIN_SITEMAP.PRIORITY_USE_GLOBAL @@ -224,3 +242,73 @@ form: '1.0': 1.0 validate: type: float + + advanced_section: + type: section + title: Advanced Features + underline: true + fields: + + additions: + type: list + label: PLUGIN_SITEMAP.ADDITIONS + help: PLUGIN_SITEMAP.ADDITIONS_HELP + + fields: + .location: + type: text + label: PLUGIN_SITEMAP.LOCATION + placeholder: "/not-a-grav-url" + .lastmod: + type: text + label: PLUGIN_SITEMAP.LASTMOD + placeholder: "2017-04-06" + .changefreq: + type: select + label: PLUGIN_SITEMAP.CHANGEFREQ + default: '' + options: + '': PLUGIN_SITEMAP.CHANGEFREQ_DEFAULT + always: PLUGIN_SITEMAP.CHANGEFREQ_ALWAYS + hourly: PLUGIN_SITEMAP.CHANGEFREQ_HOURLY + daily: PLUGIN_SITEMAP.CHANGEFREQ_DAILY + weekly: PLUGIN_SITEMAP.CHANGEFREQ_WEEKLY + monthly: PLUGIN_SITEMAP.CHANGEFREQ_MONTHLY + yearly: PLUGIN_SITEMAP.CHANGEFREQ_YEARLY + never: PLUGIN_SITEMAP.CHANGEFREQ_NEVER + .priority: + type: select + label: PLUGIN_SITEMAP.PRIORITY + default: '' + options: + '': PLUGIN_SITEMAP.PRIORITY_USE_GLOBAL + '0.1': 0.1 + '0.2': 0.2 + '0.3': 0.3 + '0.4': 0.4 + '0.5': 0.5 + '0.6': 0.6 + '0.7': 0.7 + '0.8': 0.8 + '0.9': 0.9 + '1.0': 1.0 + validate: + type: float + + urlset: + type: text + default: 'http://www.sitemaps.org/schemas/sitemap/0.9' + label: PLUGIN_SITEMAP.URLSET + help: PLUGIN_SITEMAP.URLSET_HELP + + urlimageset: + type: text + default: 'http://www.google.com/schemas/sitemap-image/1.1' + label: PLUGIN_SITEMAP.URLIMAGESET + help: PLUGIN_SITEMAP.URLIMAGESET_HELP + + urlnewsset: + type: text + default: 'http://www.google.com/schemas/sitemap-news/0.9' + label: PLUGIN_SITEMAP.URLNEWSSET + help: PLUGIN_SITEMAP.URLNEWSSET_HELP diff --git a/plugins/sitemap/classes/SitemapEntry.php b/plugins/sitemap/classes/SitemapEntry.php index 2a9d29c..b5a53a6 100644 --- a/plugins/sitemap/classes/SitemapEntry.php +++ b/plugins/sitemap/classes/SitemapEntry.php @@ -14,6 +14,11 @@ class SitemapEntry public $images; public $hreflangs = []; + public int $timestamp; + public string $rawroute; + public string $longdate; + public string $shortdate; + /** * SitemapEntry constructor. * @@ -258,5 +263,44 @@ class SitemapEntry return $this; } + public function getTimestamp(): int + { + return $this->timestamp; + } + + public function setTimestamp(int $timestamp): void + { + $this->timestamp = $timestamp; + } + + public function getRawroute(): string + { + return $this->rawroute; + } + + public function setRawroute(string $rawroute): void + { + $this->rawroute = $rawroute; + } + + public function getLongdate(): string + { + return $this->longdate; + } + + public function setLongdate(string $longdate): void + { + $this->longdate = $longdate; + } + + public function getShortdate(): string + { + return $this->shortdate; + } + + public function setShortdate(string $shortdate): void + { + $this->shortdate = $shortdate; + } } diff --git a/plugins/sitemap/languages.yaml b/plugins/sitemap/languages.yaml index 1ebd2b7..4b205b5 100644 --- a/plugins/sitemap/languages.yaml +++ b/plugins/sitemap/languages.yaml @@ -16,7 +16,7 @@ en: PRIORITY: 'Global - Sitemap Priority' PRIORITY_USE_GLOBAL: 'Use Global (1)' ROUTE: 'Route to Sitemap' - IGNORES: 'Ignore' + IGNORES: 'Ignore URLs' IGNORES_HELP: 'URLs to ignore (You can ignore all children of a path by using regex and appending ".*" to the ignore path)' ADDITIONS: 'Additional URLs' ADDITIONS_HELP: 'Add external URLs to the sitemap' @@ -29,7 +29,14 @@ en: IGNORE_REDIRECT: 'Ignore Redirect Pages' IGNORE_REDIRECT_HELP: 'Ignores pages that have a custom "redirect" entry in the header' URLSET: 'URLSet' - URLSET_HELP: 'The URLSet XML Namespace, don''t change this!' + URLSET_HELP: 'The URLSet XML Namespace' + URLIMAGESET: 'URLImageSet' + URLIMAGESET_HELP: 'The URLImageSet XML Namespace,' + URLNEWSSET: 'URLNewsSet' + URLNEWSSET_HELP: 'The URLNewsSet XML Namespace' + INCLUDE_NEWS_TAGS: 'Include News Tags' + NEWS_MAX_AGE_DAYS: 'News Max Age (Days)' + NEWS_TAG_PATHS: 'News Enabled Paths' MULTILANG_ENABLED: 'Multi-Lang Features' MULTILANG_ENABLED_HELP: 'Enables support for multilanguage features' INCLUDE_CHANGEFREQ: 'Include Change Frequency' @@ -42,6 +49,15 @@ en: TITLE_TITLE: 'Title' TITLE_LASTMOD: 'Last Modified' UNTITLED: 'Untitled' + XSL_TRANSFORM: 'XSL Transform' + XSL_TRANSFORM_HELP: 'Use XSL stylesheets to transform the XML output when viewing in a browser' + DATE_TYPE: 'Date Type' + DATE_TYPE_PAGE_DATE: 'Page Date' + DATE_TYPE_LAST_MODIFIED: 'Last Modified' + STANDALONE_SITEMAP_NEWS: 'Standalone News URLs' + STANDALONE_SITEMAP_NEWS_HELP: 'Create a standalone sitemap-news.xml file for each news-enabled path' + SITEMAP_NEWS_PATH: 'Sitemap News Path' + SITEMAP_NEWS_PATH_HELP: 'The path to the Sitemap News file' ru: PLUGIN_SITEMAP: SITEMAP: 'Карта сайта' diff --git a/plugins/sitemap/sitemap-news.xsl b/plugins/sitemap/sitemap-news.xsl new file mode 100644 index 0000000..25d0178 --- /dev/null +++ b/plugins/sitemap/sitemap-news.xsl @@ -0,0 +1,115 @@ + + + + + + + XML Sitemap + + + + + + + + + + + + + + + + + + + + + + + + + + + +
News Sitemap
locnews:titlenews:publication_date
+ + + + + + + + + + +
+ + +
+
diff --git a/plugins/sitemap/sitemap.php b/plugins/sitemap/sitemap.php index 1dfc470..0597080 100644 --- a/plugins/sitemap/sitemap.php +++ b/plugins/sitemap/sitemap.php @@ -38,6 +38,8 @@ class SitemapPlugin extends Plugin protected $ignore_protected = true; protected $ignore_redirect = true; + protected $news_route = null; + /** * @return array */ @@ -74,9 +76,19 @@ class SitemapPlugin extends Plugin /** @var Uri $uri */ $uri = $this->grav['uri']; - $route = $this->config->get('plugins.sitemap.route'); + $route = $this->config()['route']; + $uri_route = $uri->route(); + $news_page = false; - if ($route && $route == $uri->path()) { + if ($this->config()['include_news_tags'] && + $this->config()['standalone_sitemap_news'] && + Utils::endsWith($uri->uri(), $this->config()['sitemap_news_path']) && + in_array(dirname($uri->route()), $this->config()['news_enabled_paths'])) { + $this->news_route = dirname($uri->route()); + } + + + if ($route === $uri->route() || !empty($this->news_route)) { $this->enable([ 'onTwigInitialized' => ['onTwigInitialized', 0], @@ -100,7 +112,7 @@ class SitemapPlugin extends Plugin $pages = $this->grav['pages']; $cache_id = md5('sitemap-data-'.$pages->getPagesCacheId()); - $this->sitemap = $cache->fetch($cache_id); +// $this->sitemap = $cache->fetch($cache_id); if ($this->sitemap === false) { $this->multilang_enabled = $this->config->get('plugins.sitemap.multilang_enabled'); @@ -110,6 +122,7 @@ class SitemapPlugin extends Plugin $default_lang = $language->getDefault() ?: 'en'; $active_lang = $language->getActive() ?? $default_lang; $languages = $this->multilang_enabled && $language->enabled() ? $language->getLanguages() : [$default_lang]; + $include_default_lang = $this->config->get('system.languages.include_default_lang'); $this->multilang_skiplang_prefix = $this->config->get('system.languages.include_default_lang') ? '' : $language->getDefault(); $this->multilang_include_fallbacks = $this->config->get('system.languages.pages_fallback_only') || !empty($this->config->get('system.languages.content_fallback')); @@ -148,7 +161,7 @@ class SitemapPlugin extends Plugin if ($language->enabled()) { foreach ($route_data as $l => $l_data) { $entry->addHreflangs(['hreflang' => $l, 'href' => $l_data['location']]); - if ($l == $default_lang) { + if ($include_default_lang === false && $l == $default_lang) { $entry->addHreflangs(['hreflang' => 'x-default', 'href' => $l_data['location']]); } } @@ -176,10 +189,11 @@ class SitemapPlugin extends Plugin { $page = $event['page'] ?? null; $route = $this->config->get('plugins.sitemap.route'); + $uri = $this->grav['uri']; + $html_support = $this->config->get('plugins.sitemap.html_support', false); + $extension = $this->grav['uri']->extension() ?? ($html_support ? 'html': 'xml'); - if (is_null($page) || $page->route() !== $route) { - $html_support = $this->config->get('plugins.sitemap.html_support', false); - $extension = $this->grav['uri']->extension() ?? ($html_support ? 'html': 'xml'); + if (is_null($page) || $uri->route() === $route || !empty($this->news_route)) { // set a dummy page $page = new Page; @@ -188,7 +202,16 @@ class SitemapPlugin extends Plugin unset($this->grav['page']); $this->grav['page'] = $page; $twig = $this->grav['twig']; - $twig->template = "sitemap.$extension.twig"; + + if (!empty($this->news_route)) { + $header = $page->header(); + $header->sitemap['news_route'] = $this->news_route; + $page->header($header); + $twig->template = "sitemap-news.$extension.twig"; + } else { + $twig->template = "sitemap.$extension.twig"; + } + } } @@ -198,6 +221,9 @@ class SitemapPlugin extends Plugin $this->grav['twig']->twig()->addFunction( new TwigFunction('sort_sitemap_entries_by_language', [$this, 'sortSitemapEntriesByLanguage']) ); + $this->grav['twig']->twig()->addFunction( + new TwigFunction('timestamp_within_days', [$this, 'timestampWithinDays']) + ); } /** @@ -255,6 +281,13 @@ class SitemapPlugin extends Plugin return $entries; } + public function timestampWithinDays(int $timestamp, int $days): bool + { + $now = time(); + $days_ago = $now - ($days * 24 * 60 * 60); + return $timestamp >= $days_ago; + } + protected function addRouteData($pages, $lang) { $routes = array_unique($pages->routes()); @@ -264,6 +297,7 @@ class SitemapPlugin extends Plugin /** @var PageInterface $page */ $page = $pages->get($path); + $rawroute = $page->rawRoute(); $header = $page->header(); $external_url = $this->ignore_external ? isset($header->external_url) : false; $protected_page = $this->ignore_protected ? isset($header->access) : false; @@ -285,6 +319,10 @@ class SitemapPlugin extends Plugin 'translated' => in_array($lang, $page_languages), 'location' => $location, 'lastmod' => date($this->datetime_format, $page->modified()), + 'longdate' => date('Y-m-d\TH:i:sP', $page->date()), + 'shortdate' => date('Y-m-d', $page->date()), + 'timestamp' => $page->date(), + 'rawroute' => $page->rawRoute(), ]; if ($this->include_change_freq) { @@ -310,7 +348,7 @@ class SitemapPlugin extends Plugin - $this->route_data[$route][$lang] = $lang_route; + $this->route_data[$rawroute][$lang] = $lang_route; } } } diff --git a/plugins/sitemap/sitemap.yaml b/plugins/sitemap/sitemap.yaml index 9d20ddb..a249bb6 100644 --- a/plugins/sitemap/sitemap.yaml +++ b/plugins/sitemap/sitemap.yaml @@ -3,10 +3,19 @@ route: '/sitemap' ignore_external: true ignore_protected: true ignore_redirect: true +include_news_tags: false +standalone_sitemap_news: false +sitemap_news_path: '/sitemap-news.xml' +news_max_age_days: 2 +news_enabled_paths: + - /blog ignores: whitelist: +xsl_transform: true html_support: false urlset: 'http://www.sitemaps.org/schemas/sitemap/0.9' +urlnewsset: 'http://www.google.com/schemas/sitemap-news/0.9' +urlimageset: 'http://www.google.com/schemas/sitemap-image/1.1' short_date_format: true include_changefreq: true changefreq: daily diff --git a/plugins/sitemap/templates/sitemap-extensions/image.xml.twig b/plugins/sitemap/templates/sitemap-extensions/image.xml.twig new file mode 100644 index 0000000..04bd10a --- /dev/null +++ b/plugins/sitemap/templates/sitemap-extensions/image.xml.twig @@ -0,0 +1,17 @@ + +{% if image.loc %} + {{ url(image.loc, true) }} +{% endif %} +{% if image.caption %} + {{ image.caption }} +{% endif %} +{% if image.geoloc %} + {{ image.geoloc }} +{% endif %} +{% if image.title %} + {{ image.title }} +{% endif %} +{% if image.license %} + {{ image.license }} +{% endif %} + \ No newline at end of file diff --git a/plugins/sitemap/templates/sitemap-extensions/news.xml.twig b/plugins/sitemap/templates/sitemap-extensions/news.xml.twig new file mode 100644 index 0000000..b378771 --- /dev/null +++ b/plugins/sitemap/templates/sitemap-extensions/news.xml.twig @@ -0,0 +1,8 @@ + + + {{ site.title }} + {{ entry.lang }} + + {{ entry.longdate }} + {{ entry.title }} + diff --git a/plugins/sitemap/templates/sitemap-news.xml.twig b/plugins/sitemap/templates/sitemap-news.xml.twig new file mode 100644 index 0000000..837c1fb --- /dev/null +++ b/plugins/sitemap/templates/sitemap-news.xml.twig @@ -0,0 +1,19 @@ +{% set sitemap_config = page.header.sitemap %} + +{% if config.plugins.sitemap.xsl_transform %} + +{% endif %} + +{% for entry in sitemap %} + {% if timestamp_within_days(entry.timestamp, config.plugin.sitemap.news_max_age_days|default(2)) and + entry.rawroute|starts_with(sitemap_config.news_route ~ '/') %} + + {{ entry.location|e }} + {% include 'sitemap-extensions/news.xml.twig' %} + + {% endif %} +{% endfor %} + \ No newline at end of file diff --git a/plugins/sitemap/templates/sitemap.xml.twig b/plugins/sitemap/templates/sitemap.xml.twig index 7f3ee10..cca6521 100644 --- a/plugins/sitemap/templates/sitemap.xml.twig +++ b/plugins/sitemap/templates/sitemap.xml.twig @@ -1,11 +1,24 @@ +{% if config.plugins.sitemap.xsl_transform %} - +{% endif %} + {% for entry in sitemap %} {{ entry.location|e }} + {% if config.plugins.sitemap.include_news_tags and + config.plugins.sitemap.standalone_sitemap_news == false and + timestamp_within_days(entry.timestamp, config.plugin.sitemap.news_max_age_days|default(2)) and + entry.rawroute|starts_with(config.plugins.sitemap.news_enabled_paths) + %} + {% include 'sitemap-extensions/news.xml.twig' %} + {% endif %} {% for hreflang in entry.hreflangs %} {% endfor %} @@ -19,23 +32,7 @@ {{ entry.priority|number_format(1) }} {% endif %} {% for image in entry.images %} - - {% if image.loc %} - {{ url(image.loc, true) }} - {% endif %} - {% if image.caption %} - {{ image.caption }} - {% endif %} - {% if image.geoloc %} - {{ image.geoloc }} - {% endif %} - {% if image.title %} - {{ image.title }} - {% endif %} - {% if image.license %} - {{ image.license }} - {% endif %} - + {% include 'sitemap-extensions/image.xml.twig' %} {% endfor %} {% endfor %} diff --git a/themes/mytheme/css/style.css b/themes/mytheme/css/style.css index 9bb06aa..4bf414a 100755 --- a/themes/mytheme/css/style.css +++ b/themes/mytheme/css/style.css @@ -10,12 +10,12 @@ body#layout .nav-collapse,.no-image,.pagenavi .pages,#navbar,.date-header,.feed- body#layout #content {float:left;width:600px;margin-left:30px} body#layout #side-bar {float:right;width:300px;} #column1,#column2,#column3 {float:left} -body,.body-fauxcolumn-outer{font-family: "Gotham";background:#E9F0F4;font-size:18px;font-weight:400;line-height:1.75;overflow-x:hidden;position:relative; line-height: 25px; +body,.body-fauxcolumn-outer{font-family: "Arial";background:#E9F0F4;font-size:18px;font-weight:400;line-height:1.75;overflow-x:hidden;position:relative; line-height: 25px; font-size: 15px; color: #6d7683;} a{color:#333} a:hover{color:#E74C3C} -h1,h2,h3,h4,h5{font-family:"Gotham";} +h1,h2,h3,h4,h5{font-family:"Arial";} .bl_background{position:fixed;z-index:-1;width:100%;height:100%;left:0;top:0} .bl_background img{width:100%;height:100%} #background_pattern{background-repeat:repeat;height:100%;left:0;position:fixed;top:0;width:100%;z-index:-1}