diff --git a/lib/XRay/Formats/Mf2.php b/lib/XRay/Formats/Mf2.php index 47d5903..7023f1b 100644 --- a/lib/XRay/Formats/Mf2.php +++ b/lib/XRay/Formats/Mf2.php @@ -617,10 +617,15 @@ class Mf2 extends Format { // If the value is an h-* object with a URL, the URL is used and a "ref" is added as well self::collectArrayURLValues(['photo','video','audio','syndication'], $item, $data, $refs, $http); - // If there is a description, always return the plaintext description, and return HTML description if it's different - $description = self::parseHTMLValue('description', $item); - if($description) { - $data['description'] = $description; + // If there is a description, always return the plaintext content, and return HTML content if it's different + $content = self::parseHTMLValue('content', $item); + if($content) { + $data['content'] = $content; + } else { + // Fall back to looking for "description" + $content = self::parseHTMLValue('description', $item); + if($content) + $data['content'] = $content; } $data['post-type'] = \p3k\XRay\PostType::discover($data); diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 474c388..141b7fb 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -498,10 +498,10 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertEquals($url, $data['data']['url']); $this->assertEquals('2016-03-09T18:30', $data['data']['start']); $this->assertEquals('2016-03-09T19:30', $data['data']['end']); - $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['description']['text']); - $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['description']['text']); - $this->assertStringStartsWith("
Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...
", $data['data']['description']['html']); - $this->assertStringEndsWith('See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.
', $data['data']['description']['html']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); + $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...
", $data['data']['content']['html']); + $this->assertStringEndsWith('See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.
', $data['data']['content']['html']); } public function testEventWithTextDescription() { @@ -518,9 +518,28 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertEquals($url, $data['data']['url']); $this->assertEquals('2016-03-09T18:30', $data['data']['start']); $this->assertEquals('2016-03-09T19:30', $data['data']['end']); - $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['description']['text']); - $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['description']['text']); - $this->assertArrayNotHasKey('html', $data['data']['description']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); + $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); + } + + public function testEventWithTextContent() { + $url = 'http://source.example.com/h-event-text-content'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('event', $data['data']['type']); + $this->assertEquals('event', $data['data']['post-type']); + $this->assertEquals('Homebrew Website Club', $data['data']['name']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('2016-03-09T18:30', $data['data']['start']); + $this->assertEquals('2016-03-09T19:30', $data['data']['end']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); + $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); } public function testEventWithHCardLocation() { diff --git a/tests/data/source.example.com/h-event-text-content b/tests/data/source.example.com/h-event-text-content new file mode 100644 index 0000000..4722816 --- /dev/null +++ b/tests/data/source.example.com/h-event-text-content @@ -0,0 +1,24 @@ +HTTP/1.1 200 OK +Server: Apache +Date: Wed, 09 Dec 2015 03:29:14 GMT +Content-Type: text/html; charset=utf-8 +Connection: keep-alive + + + +Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...
+See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.
+