summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS.md1
-rw-r--r--src/Readability.php34
2 files changed, 32 insertions, 3 deletions
diff --git a/AUTHORS.md b/AUTHORS.md
index 589e2c3..cc420e3 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -10,3 +10,4 @@ The AUTHORS/Contributors are (and/or have been):
* Andres Rey
* Sergiy Lavryk
* Pedro Amorim
+* Malu Decks
diff --git a/src/Readability.php b/src/Readability.php
index 8c55e69..313b0ba 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -57,6 +57,13 @@ class Readability
protected $author = null;
/**
+ * Website name.
+ *
+ * @var string|null
+ */
+ protected $siteName = null;
+
+ /**
* Direction of the text.
*
* @var string|null
@@ -287,10 +294,10 @@ class Readability
$values = [];
// property is a space-separated list of values
- $propertyPattern = '/\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|image)(?!:)\s*/i';
+ $propertyPattern = '/\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|image|site_name)(?!:)\s*/i';
// name is a single value
- $namePattern = '/^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|image)(?!:)\s*$/i';
+ $namePattern = '/^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|image|site_name)(?!:)\s*$/i';
// Find description tags.
foreach ($this->dom->getElementsByTagName('meta') as $meta) {
@@ -332,7 +339,6 @@ class Readability
* This could be easily replaced with an ugly set of isset($values['key']) or a bunch of ??s.
* Will probably replace it with ??s after dropping support of PHP5.6
*/
-
$key = current(array_intersect([
'dc:title',
'dcterm:title',
@@ -378,6 +384,12 @@ class Readability
], array_keys($values)));
$this->setImage(isset($values[$key]) ? $values[$key] : null);
+
+ $key = current(array_intersect([
+ 'og:site_name'
+ ], array_keys($values)));
+
+ $this->setSiteName(isset($values[$key]) ? $values[$key] : null);
}
/**
@@ -1757,6 +1769,22 @@ class Readability
}
/**
+ * @return string|null
+ */
+ public function getSiteName()
+ {
+ return $this->siteName;
+ }
+
+ /**
+ * @param string $siteName
+ */
+ protected function setSiteName($siteName)
+ {
+ $this->siteName = $siteName;
+ }
+
+ /**
* @return null|string
*/
public function getDirection()