Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.53'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Oct 6, 2017
2 parents c6598ef + 5c6a993 commit 3d37a00
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SEOmatic Changelog

## 1.1.53 - 2017.10.06
### Changed
* Fixed a regression with certain types of localized sites

## 1.1.52 - 2017.10.02
### Changed
* Fixed breadcrumbs (and other URLs) for certain multi-locale setups
Expand Down
43 changes: 43 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,49 @@ Here's an example of how you might add a `startDate` to an `Event` schema type:

Note that `Event` schema types require `startDate` and `location` to be set, which SEOmatic is unable to automatically fill in for you. Additionally, you may want to add more information to any of the schema types used for Main Entity of Page to give search engines more information to add to their knowledge graph.

### Gated or Subscription Content

Google recommends the use of JSON-LD Structured Data for [Subscription and paywalled content](https://developers.google.com/search/docs/data-types/paywalled-content). This is strongly encouraged, so that you are not errantly punished for violating Google's [cloaking](https://support.google.com/webmasters/answer/66355) policies or [guidelines](https://support.google.com/webmasters/answer/35769).

Whether your content is available only after a free registration process, or it's available only to people who subscribe to your website, it's recommended that you use this markup to help Google understand your content.

SEOmatic makes it easy to add this to your `MainEntityOfPage` using markup such as this in your Twig template:

```
{% if seomaticMainEntityOfPage is defined %}
{% set seomaticMainEntityOfPage = seomaticMainEntityOfPage | merge({
'isAccessibleForFree': 'False',
'hasPart': {
'type': 'WebPageElement',
'isAccessibleForFree': 'False',
'cssSelector': '.paywall',
}
}) %}
{% endif %}
```

Where the `.paywall` class is whatever your CSS selector is for blocking access to your content. If you have more then one, you'd do something like:

```
{% if seomaticMainEntityOfPage is defined %}
{% set seomaticMainEntityOfPage = seomaticMainEntityOfPage | merge({
'isAccessibleForFree': 'False',
'hasPart': [
{
'type': 'WebPageElement',
'isAccessibleForFree': 'False',
'cssSelector': '.paywall',
},
{
'type': 'WebPageElement',
'isAccessibleForFree': 'False',
'cssSelector': '#blocksContent',
}
]
}) %}
{% endif %}
```
For more information, see Googe's support article [Subscription and paywalled content](https://developers.google.com/search/docs/data-types/paywalled-content).
## Breadcrumbs Microdata

![Screenshot](resources/screenshots/seomatic06.png)
Expand Down
2 changes: 1 addition & 1 deletion SeomaticPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getReleaseFeedUrl()

public function getVersion()
{
return '1.1.52';
return '1.1.53';
}

public function getSchemaVersion()
Expand Down
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"version": "1.1.53",
"downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip",
"date": "2017-10-06T11:00:00-11:00",
"notes": [
"[Fixed] Fixed a regression with certain types of localized sites"
]
},
{
"version": "1.1.52",
"downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip",
Expand Down
106 changes: 74 additions & 32 deletions services/SeomaticService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3092,46 +3092,35 @@ public function getFullyQualifiedUrl($url)
$result = $url;
if (!isset($result) || $result == "")
return $result;
$srcUrlParts = parse_url($result);
if (UrlHelper::isAbsoluteUrl($url) || UrlHelper::isProtocolRelativeUrl($url))
{
/* -- The URL is already a fully qualfied URL, do nothing */
}
else
{
$siteUrlOverride = craft()->config->get("siteUrlOverride", "seomatic");
if ($siteUrlOverride)
if ($siteUrlOverride) {
$siteUrl = $siteUrlOverride;
else
if (($siteUrl[strlen($siteUrl) -1] == '/') && ($result[0] == '/')) {
$siteUrl = rtrim($siteUrl, '/');
}
$result = $siteUrl . $result;
} else {
$siteUrl = UrlHelper::getSiteUrl('', null, null, craft()->language);

if (UrlHelper::isAbsoluteUrl($siteUrl) || UrlHelper::isProtocolRelativeUrl($siteUrl))
{
/* -- The URL is already a fully qualfied URL, do nothing */
}
else
{
$urlParts = parse_url($siteUrl);
$port = "";
if (isset($urlParts['port']))
$port = ":" . $urlParts['port'];
if (isset($urlParts['scheme']) && isset($urlParts['host']))
$siteUrl = $urlParts['scheme'] . "://" . $urlParts['host'] . $port . "/";
else
$siteUrl = "/";
}
if (($siteUrl[strlen($siteUrl) -1] == '/') && ($result[0] == '/'))
{
// Do this to prevent duplicate locales in the URL, e.g.: https://example.com/en/en/
$siteUrl = rtrim($siteUrl, '/');
$result = $this->replaceOverlap($siteUrl, $url);
if ($result === false) {
$result = UrlHelper::getSiteUrl($url, null, null, craft()->language);
}
}
// Add a trailing / if `addTrailingSlashesToUrls` is set, but only if there's one extension
if (craft()->config->get('addTrailingSlashesToUrls')) {
$path = parse_url($result, PHP_URL_PATH);
$pathExtension = pathinfo($path,PATHINFO_EXTENSION);
if (empty($pathExtension))
$result = rtrim($result, '/') . '/';
}
$result = $siteUrl . $result;
}
// Add a trailing / if `addTrailingSlashesToUrls` is set, but only if there's on extension
if (craft()->config->get('addTrailingSlashesToUrls')) {
$path = parse_url($result, PHP_URL_PATH);
$pathExtension = pathinfo($path,PATHINFO_EXTENSION);
if (empty($pathExtension))
$result = rtrim($result, '/') . '/';
}

return $result;
Expand Down Expand Up @@ -3255,9 +3244,62 @@ public function sanitizeArray(&$theArray)
}
} /* -- sanitizeArray */

/* --------------------------------------------------------------------------------
Cleanup text before extracting keywords/summary
-------------------------------------------------------------------------------- */
/**
* As per https://stackoverflow.com/questions/2945446/built-in-function-to-combine-overlapping-string-sequences-in-php
* @param $str1
* @param $str2
*
* @return array|bool
*/
private function findOverlap($str1, $str2){
$return = array();
$sl1 = strlen($str1);
$sl2 = strlen($str2);
$max = $sl1>$sl2?$sl2:$sl1;
$i=1;
while($i<=$max){
$s1 = substr($str1, -$i);
$s2 = substr($str2, 0, $i);
if($s1 == $s2){
$return[] = $s1;
}
$i++;
}
if(!empty($return)){
return $return;
}
return false;
}

/**
* As per: https://stackoverflow.com/questions/2945446/built-in-function-to-combine-overlapping-string-sequences-in-php
* @param $str1
* @param $str2
* @param string $length
*
* @return bool|string
*/
private function replaceOverlap($str1, $str2, $length = "long"){
if($overlap = $this->findOverlap($str1, $str2)){
switch($length){
case "short":
$overlap = $overlap[0];
break;
case "long":
default:
$overlap = $overlap[count($overlap)-1];
break;
}
$str1 = substr($str1, 0, -strlen($overlap));
$str2 = substr($str2, strlen($overlap));
return $str1.$overlap.$str2;
}
return false;
}

/* --------------------------------------------------------------------------------
Cleanup text before extracting keywords/summary
-------------------------------------------------------------------------------- */

private function _cleanupText($text = null)
{
Expand Down

0 comments on commit 3d37a00

Please sign in to comment.