Skip to content

Commit

Permalink
Merge branch 'release/3.2.16' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jul 18, 2019
2 parents 177c2d5 + 454b028 commit bd0cd19
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,13 @@
# SEOmatic Changelog

## 3.2.16 - 2019.07.18
### Added
* Added **Social Media Preview Target** plugin setting
* Added `X-Robots-Tag: noindex` header to the sitemaps to prevent the sitemaps themselves from appearing in the SERP

### Changed
* Fixed an issue with the sitemap generation not respecting an already running queue

## 3.2.15 - 2019.07.15
### Changed
* Fixed an issue where assigning a Rich Text field to a JSON-LD property didn't work
Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -508,6 +508,9 @@ return [
// Should SEOmatic display the SEO Preview sidebar?
'displayPreviewSidebar' => true,

// Should SEOmatic add a Social Media Preview Target?
'socialMediaPreviewTarget' => true,

// The social media platforms that should be displayed in the SEO Preview sidebar
'sidebarDisplayPreviewTypes' => [
'google',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "3.2.14",
"version": "3.2.16",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion src/Seomatic.php
Expand Up @@ -529,7 +529,7 @@ function (ElementEvent $event) {
);
}
);
if (self::$craft32) {
if (self::$craft32 && Seomatic::$settings->socialMediaPreviewTarget) {
// Handler: Entry::EVENT_REGISTER_PREVIEW_TARGETS
Event::on(
Entry::class,
Expand Down
3 changes: 3 additions & 0 deletions src/config.php
Expand Up @@ -53,6 +53,9 @@
// Should SEOmatic display the SEO Preview sidebar?
'displayPreviewSidebar' => true,

// Should SEOmatic add a Social Media Preview Target?
'socialMediaPreviewTarget' => true,

// The social media platforms that should be displayed in the SEO Preview sidebar
'sidebarDisplayPreviewTypes' => [
'google',
Expand Down
3 changes: 3 additions & 0 deletions src/controllers/SitemapController.php
Expand Up @@ -57,6 +57,7 @@ public function actionSitemapIndex(int $groupId, int $siteId = null): Response
);
$headers = Craft::$app->response->headers;
$headers->add('Content-Type', 'text/xml; charset=utf-8');
$headers->add('X-Robots-Tag', 'noindex');

return $this->asRaw($xml);
}
Expand Down Expand Up @@ -84,6 +85,7 @@ public function actionSitemap(int $groupId, string $type, string $handle, int $s
);
$headers = Craft::$app->response->headers;
$headers->add('Content-Type', 'text/xml; charset=utf-8');
$headers->add('X-Robots-Tag', 'noindex');

return $this->asRaw($xml);
}
Expand All @@ -107,6 +109,7 @@ public function actionSitemapCustom(int $groupId, int $siteId): Response
);
$headers = Craft::$app->response->headers;
$headers->add('Content-Type', 'text/xml; charset=utf-8');
$headers->add('X-Robots-Tag', 'noindex');

return $this->asRaw($xml);
}
Expand Down
60 changes: 60 additions & 0 deletions src/helpers/Queue.php
@@ -0,0 +1,60 @@
<?php
/**
* SEOmatic plugin for Craft CMS 3.x
*
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
* and flexible
*
* @link https://nystudio107.com
* @copyright Copyright (c) 2017 nystudio107
*/

namespace nystudio107\seomatic\helpers;

use nystudio107\seomatic\Seomatic;

use Craft;
use craft\helpers\App;
use craft\queue\QueueInterface;

/**
* @author nystudio107
* @package Seomatic
* @since 3.2.16
*/
class Queue
{
// Constants
// =========================================================================

// Static Methods
// =========================================================================

/**
* Run the queue if we can run it via the web interface
*
* @return void
*/
public static function run()
{
$queue = Craft::$app->getQueue();
// Make sure the queue uses the Craft web interface
if (!$queue instanceof QueueInterface) {
return;
}

// Make sure Craft is configured to run queues over the web
if (!Craft::$app->getConfig()->getGeneral()->runQueueAutomatically) {
return;
}

// Make sure the queue isn't already running, and there are waiting jobs
if ($queue->getHasReservedJobs() || !$queue->getHasWaitingJobs()) {
return;
}

// Run the queue
App::maxPowerCaptain();
$queue->run();
}
}
6 changes: 6 additions & 0 deletions src/models/Settings.php
Expand Up @@ -64,6 +64,11 @@ class Settings extends VarsModel
*/
public $displayPreviewSidebar = true;

/**
* @var bool Should SEOmatic add a Social Media Preview Target?
*/
public $socialMediaPreviewTarget = true;

/**
* @var array The social media platforms that should be displayed in the SEO Preview sidebar
*/
Expand Down Expand Up @@ -159,6 +164,7 @@ public function rules(): array
['environment', 'string'],
['environment', 'default', 'value' => 'live'],
['displayPreviewSidebar', 'boolean'],
['socialMediaPreviewTarget', 'boolean'],
['displayAnalysisSidebar', 'boolean'],
[['devModeTitlePrefix', 'cpTitlePrefix', 'devModeCpTitlePrefix'], 'string'],
['separatorChar', 'string'],
Expand Down
18 changes: 7 additions & 11 deletions src/models/SitemapTemplate.php
Expand Up @@ -14,10 +14,10 @@
use nystudio107\seomatic\Seomatic;
use nystudio107\seomatic\base\FrontendTemplate;
use nystudio107\seomatic\base\SitemapInterface;
use nystudio107\seomatic\helpers\Queue as QueueHelper;
use nystudio107\seomatic\jobs\GenerateSitemap;

use Craft;
use craft\helpers\App;

use yii\caching\TagDependency;
use yii\web\NotFoundHttpException;
Expand Down Expand Up @@ -134,16 +134,12 @@ public function render(array $params = []): string
),
__METHOD__
);
// If the queue should be run automatically, do it now
if (Craft::$app->getConfig()->getGeneral()->runQueueAutomatically) {
// This might take a while
App::maxPowerCaptain();
$queue->run();
// Try it again now
$result = $cache->get($cacheKey);
if ($result !== false) {
return $result;
}
// Try to run the queue immediately
QueueHelper::run();
// Try it again now
$result = $cache->get($cacheKey);
if ($result !== false) {
return $result;
}
// Return a 503 Service Unavailable an a Retry-After so bots will try back later
$response = Craft::$app->getResponse();
Expand Down
12 changes: 11 additions & 1 deletion src/templates/settings/plugin/_edit.twig
Expand Up @@ -99,14 +99,24 @@
{% endif %}
{{ forms.lightswitchField({
label: "Display Sidebar SEO Preview"|t("seomatic"),
instructions: "Controls whether to display the Google, Twitter, and Facebook social media previews in the sidebar on entry, category, and product pages."|t("seomatic"),
instructions: "Controls whether to display the Google, Twitter, Facebook, etc. social media previews in the sidebar on entry, category, and product pages."|t("seomatic"),
id: "displayPreviewSidebar",
name: "displayPreviewSidebar",
on: settings.displayPreviewSidebar,
warning: configWarning("displayPreviewSidebar", "seomatic"),
errors: settings.getErrors("displayPreviewSidebar"),
}) }}

{{ forms.lightswitchField({
label: "Add Social Media Preview Target"|t("seomatic"),
instructions: "Controls whether to add the Google, Twitter, Facebook, etc. social media previews as a Preview Target."|t("seomatic"),
id: "socialMediaPreviewTarget",
name: "socialMediaPreviewTarget",
on: settings.socialMediaPreviewTarget,
warning: configWarning("socialMediaPreviewTarget", "seomatic"),
errors: settings.getErrors("socialMediaPreviewTarget"),
}) }}

<div id="sidebarDisplayPreviewTypes-wrapper">
{{ forms.checkboxSelectField({
label: "SEO Preview Sites"|t("seomatic"),
Expand Down
6 changes: 5 additions & 1 deletion src/translations/en/seomatic.php
Expand Up @@ -425,5 +425,9 @@
'Transform Facebook OpenGraph Image' => 'Transform Facebook OpenGraph Image',
'Video Sitemap Property' => 'Video Sitemap Property',
'Same as Site Twitter Handle' => 'Same as Site Twitter Handle',
'If you are seeing this in local dev or an' => 'If you are seeing this in local dev or an'
'If you are seeing this in local dev or an' => 'If you are seeing this in local dev or an',
'Add Social Media Preview Target' => 'Add Social Media Preview Target',
'Controls whether to add the Google, Twitter, Facebook, etc. social media previews as a Preview Target.' => 'Controls whether to add the Google, Twitter, Facebook, etc. social media previews as a Preview Target.',
'Controls whether to display the Google, Twitter, Facebook, etc. social media previews in the sidebar on entry, category, and product pages.' => 'Controls whether to display the Google, Twitter, Facebook, etc. social media previews in the sidebar on entry, category, and product pages.',
'Controls whether to add the Google, Twitter, and Facebook social media previews as a Preview Target.' => 'Controls whether to add the Google, Twitter, and Facebook social media previews as a Preview Target.'
];

0 comments on commit bd0cd19

Please sign in to comment.