Skip to content

Commit

Permalink
Merge branch 'release/3.0.0-beta.7' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Mar 16, 2018
2 parents 2a9dc2e + e87d368 commit a0f1065
Show file tree
Hide file tree
Showing 33 changed files with 174 additions and 99 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# SEOmatic Changelog

### 3.0.0-beta.7 - 2018.03.16
## Added
* Added a "Same as Global Site Name Position" setting as the default for the **Site Name Position** Content SEO settings

## Changed
* Fixed an issue where the last breadcrumb on the Content SEO `edit-content` page was a 404
* Fixed a caching issue that could result in stale data if you used `seomatic.helper.loadMetadataForUri()`
* Don't automatically generate thumbnails for videos in the sitemap
* Changed the Dashboard charts over to gauge charts

### 3.0.0-beta.6 - 2018.03.15
## Added
* Check whether the `seomatic_metabundles` table exists before installing any even listeners
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
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.0.0-beta.6",
"version": "3.0.0-beta.7",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 2 additions & 2 deletions src/Seomatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ protected function tableSchemaExists(): bool
*/
protected function installEventListeners()
{
// Add in our Twig extensions
Seomatic::$view->registerTwigExtension(new SeomaticTwigExtension);
// Handler: EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function () {
// Add in our Twig extensions
Seomatic::$view->registerTwigExtension(new SeomaticTwigExtension);
// Add in our event listeners that are needed for every request
$this->installGlobalEventListeners();
// Only respond to non-console site requests
Expand Down
2 changes: 1 addition & 1 deletion src/assetbundles/seomatic/dist/js/seomatic.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assetbundles/seomatic/dist/js/seomatic.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assetbundles/seomatic/dist/js/vendor.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/assetbundles/seomatic/src/js/seomatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ $(function () {
var popupValue = $(this).val();
switch (popupValue) {
case "sameAsSeo":
case "sameAsGlobal":
case "sameAsSiteTwitter":
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').hide();
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').hide();
Expand All @@ -145,6 +146,7 @@ $(function () {
$('.seomatic-textSourceSelect > select').on('change', function(e) {
switch (this.value) {
case "sameAsSeo":
case "sameAsGlobal":
case "sameAsSiteTwitter":
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').hide();
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').hide();
Expand Down
29 changes: 11 additions & 18 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SettingsController extends Controller

const PULL_TEXT_FIELDS = [
['fieldName' => 'seoTitle', 'seoField' => 'seoTitle'],
['fieldName' => 'siteNamePosition', 'seoField' => 'siteNamePosition'],
['fieldName' => 'seoDescription', 'seoField' => 'seoDescription'],
['fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords'],
['fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription'],
Expand Down Expand Up @@ -151,13 +152,11 @@ public function actionDashboard(string $siteHandle = null, bool $showWelcome = f
$variables['showWelcome'] = $showWelcome;
// Calulate the setup grades
$variables['contentSetupStats'] = [];
$variables['globalSetupStats'] = [];
$variables['setupGrades'] = self::SETUP_GRADES;
$numFields = count(self::SEO_SETUP_FIELDS);
$numGrades = count(self::SETUP_GRADES);
while ($numGrades--) {
$variables['contentSetupStats'][] = 0;
$variables['globalSetupStats'][] = 0;
}
$numGrades = count(self::SETUP_GRADES);
// Content SEO grades
Expand All @@ -180,27 +179,16 @@ public function actionDashboard(string $siteHandle = null, bool $showWelcome = f
foreach (self::SEO_SETUP_FIELDS as $setupField) {
$stat += intval(!empty($metaBundle->metaGlobalVars[$setupField]));
}
$stat = round($numGrades - (($stat * $numGrades) / $numFields));
if ($stat >= $numGrades) {
$stat = $numGrades - 1;
}
$variables['globalSetupStats'][$stat]++;
$stat = round(($stat / $numFields) * 100);
$variables['globalSetupStat'] = $stat;
// Site Settings grades
$numFields = count(self::SITE_SETUP_FIELDS);
$numGrades = count(self::SETUP_GRADES);
while ($numGrades--) {
$variables['siteSetupStats'][] = 0;
}
$numGrades = count(self::SETUP_GRADES);
$stat = 0;
foreach (self::SITE_SETUP_FIELDS as $setupField) {
$stat += intval(!empty($metaBundle->metaSiteVars[$setupField]));
}
$stat = round($numGrades - (($stat * $numGrades) / $numFields));
if ($stat >= $numGrades) {
$stat = $numGrades - 1;
}
$variables['siteSetupStats'][$stat]++;
$stat = round(($stat / $numFields) * 100);
$variables['siteSetupStat'] = $stat;

// Render the template
return $this->renderTemplate('seomatic/dashboard/index', $variables);
Expand Down Expand Up @@ -449,7 +437,7 @@ public function actionEditContent(
],
[
'label' => $metaBundle->sourceName.' · '.$subSectionTitle,
'url' => UrlHelper::cpUrl("seomatic/content/${subSection}/${sourceBundleType}/${sourceHandle}"),
'url' => UrlHelper::cpUrl("seomatic/edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"),
],
];
$variables['selectedSubnavItem'] = 'content';
Expand Down Expand Up @@ -854,6 +842,11 @@ protected function parseTextSources(string $elementName, &$globalsSettings, &$bu
'{seomatic.site.'.$seoField.'}';
break;

case 'sameAsGlobal':
$globalsSettings[$fieldName] =
'';
break;

case 'fromField':
$globalsSettings[$fieldName] =
'{seomatic.helper.extractTextFromField('
Expand Down
9 changes: 8 additions & 1 deletion src/models/MetaBundleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public static function create(array $config = [])
*/
public $seoTitleField;

/**
* @var string The source that the Twitter site name position should come from
*/
public $siteNamePositionSource;

/**
* @var string The source that the SEO description should come from
*/
Expand Down Expand Up @@ -246,6 +251,7 @@ public function rules()
[
'seoTitleSource',
'seoTitleField',
'siteNamePositionSource',
'seoDescriptionSource',
'seoDescriptionField',
'seoKeywordsSource',
Expand Down Expand Up @@ -310,8 +316,9 @@ public function rules()
],
],
[
['twitterSiteNamePositionSource', 'ogSiteNamePositionSource'], 'in', 'range' => [
['siteNamePositionSource', 'twitterSiteNamePositionSource', 'ogSiteNamePositionSource'], 'in', 'range' => [
'sameAsSeo',
'sameAsGlobal',
'fromCustom',
],
],
Expand Down
3 changes: 0 additions & 3 deletions src/models/SitemapTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ protected function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array
$lines[] = ' <video:content_loc>';
$lines[] = ' '.$asset->getUrl();
$lines[] = ' </video:content_loc>';
$lines[] = ' <video:thumbnail_loc>';
$lines[] = ' '.$asset->getThumbUrl(320);
$lines[] = ' </video:thumbnail_loc>';
// Handle the dynamic field => property mappings
foreach ($metaBundle->metaSitemapVars->sitemapVideoFieldMap as $row) {
$fieldName = $row['field'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/seomatic-config/categorymeta/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

return [
'bundleVersion' => '1.0.5',
'bundleVersion' => '1.0.6',
'sourceBundleType' => MetaBundles::CATEGORYGROUP_META_BUNDLE,
'sourceId' => null,
'sourceName' => null,
Expand Down
5 changes: 3 additions & 2 deletions src/seomatic-config/categorymeta/BundleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'*' => [
'seoTitleSource' => 'fromField',
'seoTitleField' => 'title',
'siteNamePositionSource' => 'sameAsGlobal',
'seoDescriptionSource' => 'fromCustom',
'seoDescriptionField' => '',
'seoKeywordsSource' => 'fromCustom',
Expand All @@ -34,7 +35,7 @@
'twitterCreatorField' => '',
'twitterTitleSource' => 'sameAsSeo',
'twitterTitleField' => '',
'twitterSiteNamePositionSource' => 'fromCustom',
'twitterSiteNamePositionSource' => 'sameAsGlobal',
'twitterDescriptionSource' => 'sameAsSeo',
'twitterDescriptionField' => '',
'twitterImageIds' => [],
Expand All @@ -46,7 +47,7 @@

'ogTitleSource' => 'sameAsSeo',
'ogTitleField' => '',
'ogSiteNamePositionSource' => 'fromCustom',
'ogSiteNamePositionSource' => 'sameAsGlobal',
'ogDescriptionSource' => 'sameAsSeo',
'ogDescriptionField' => '',
'ogImageIds' => [],
Expand Down
2 changes: 1 addition & 1 deletion src/seomatic-config/entrymeta/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

return [
'bundleVersion' => '1.0.5',
'bundleVersion' => '1.0.6',
'sourceBundleType' => MetaBundles::SECTION_META_BUNDLE,
'sourceId' => null,
'sourceName' => null,
Expand Down
5 changes: 3 additions & 2 deletions src/seomatic-config/entrymeta/BundleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'*' => [
'seoTitleSource' => 'fromField',
'seoTitleField' => 'title',
'siteNamePositionSource' => 'sameAsGlobal',
'seoDescriptionSource' => 'fromCustom',
'seoDescriptionField' => '',
'seoKeywordsSource' => 'fromCustom',
Expand All @@ -34,7 +35,7 @@
'twitterCreatorField' => '',
'twitterTitleSource' => 'sameAsSeo',
'twitterTitleField' => '',
'twitterSiteNamePositionSource' => 'fromCustom',
'twitterSiteNamePositionSource' => 'sameAsGlobal',
'twitterDescriptionSource' => 'sameAsSeo',
'twitterDescriptionField' => '',
'twitterImageIds' => [],
Expand All @@ -46,7 +47,7 @@

'ogTitleSource' => 'sameAsSeo',
'ogTitleField' => '',
'ogSiteNamePositionSource' => 'fromCustom',
'ogSiteNamePositionSource' => 'sameAsGlobal',
'ogDescriptionSource' => 'sameAsSeo',
'ogDescriptionField' => '',
'ogImageIds' => [],
Expand Down
2 changes: 1 addition & 1 deletion src/seomatic-config/globalmeta/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

return [
'bundleVersion' => '1.0.13',
'bundleVersion' => '1.0.14',
'sourceBundleType' => MetaBundles::GLOBAL_META_BUNDLE,
'sourceId' => 1,
'sourceName' => MetaBundles::GLOBAL_META_BUNDLE,
Expand Down
1 change: 1 addition & 0 deletions src/seomatic-config/globalmeta/BundleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'*' => [
'seoTitleSource' => 'fromCustom',
'seoTitleField' => '',
'siteNamePositionSource' => 'fromCustom',
'seoDescriptionSource' => 'fromCustom',
'seoDescriptionField' => '',
'seoKeywordsSource' => 'fromCustom',
Expand Down
9 changes: 6 additions & 3 deletions src/services/MetaContainers.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function () use ($uri, $siteId) {
$duration,
$dependency
);
Seomatic::$seomaticVariable->init();
MetaValueHelper::cache();
$this->loadingContainers = false;
}
Expand Down Expand Up @@ -238,11 +239,13 @@ public function parseGlobalVars()
*/
public function previewMetaContainers(string $uri = '', int $siteId = null, bool $parseVariables = false)
{
// It's possible this won't exist at this point
if (!Seomatic::$seomaticVariable) {
// Create our variable and stash it in the plugin for global access
Seomatic::$seomaticVariable = new SeomaticVariable();
}
$this->loadMetaContainers($uri, $siteId);
Seomatic::$previewingMetaContainers = true;
Seomatic::$seomaticVariable = new SeomaticVariable();
Seomatic::$seomaticVariable->init();
MetaValueHelper::cache();
if ($parseVariables) {
$this->parseGlobalVars();
}
Expand Down
Loading

0 comments on commit a0f1065

Please sign in to comment.