From 1213ee080d56d5c20aee58b88d998097bc4636e2 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sun, 13 Oct 2019 11:11:19 -0700 Subject: [PATCH] include author for events for https://github.com/aaronpk/Aperture/issues/56 --- lib/XRay/Formats/Mf2.php | 3 +++ tests/ParseTest.php | 4 ++++ tests/data/source.example.com/h-event-text-content | 2 ++ 3 files changed, 9 insertions(+) diff --git a/lib/XRay/Formats/Mf2.php b/lib/XRay/Formats/Mf2.php index 2d15acf..4f61459 100644 --- a/lib/XRay/Formats/Mf2.php +++ b/lib/XRay/Formats/Mf2.php @@ -657,6 +657,9 @@ class Mf2 extends Format { $data['content'] = $content; } + if($author = self::findAuthor($mf2, $item, $http, $url)) + $data['author'] = $author; + $data['post-type'] = \p3k\XRay\PostType::discover($data); $response = [ diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 0695ca0..49ffd4b 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -554,6 +554,7 @@ class ParseTest extends PHPUnit_Framework_TestCase { $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']); @@ -564,6 +565,9 @@ class ParseTest extends PHPUnit_Framework_TestCase { $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']); + $this->assertEquals('card', $data['data']['author']['type']); + $this->assertEquals('Event Author', $data['data']['author']['name']); + $this->assertEquals('http://source.example.com/', $data['data']['author']['url']); } 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 index 4722816..10d7b4a 100644 --- a/tests/data/source.example.com/h-event-text-content +++ b/tests/data/source.example.com/h-event-text-content @@ -20,5 +20,7 @@ Connection: keep-alive

See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.

+ Event Author +