diff --git a/.travis.yml b/.travis.yml index 134204f..2401067 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,10 @@ before_script: - composer self-update - composer install --prefer-dist --no-interaction before_install: +- cp config.production.php config.php +before_deploy: - openssl aes-256-cbc -K $encrypted_e44c58426490_key -iv $encrypted_e44c58426490_iv -in XRay-67d8fdd0bba3.json.enc -out XRay-67d8fdd0bba3.json -d -- cp config.production.php config.php deploy: skip_cleanup: true provider: gae diff --git a/lib/XRay/Formats/Mf2.php b/lib/XRay/Formats/Mf2.php index 4e6a10f..1740736 100644 --- a/lib/XRay/Formats/Mf2.php +++ b/lib/XRay/Formats/Mf2.php @@ -42,7 +42,7 @@ class Mf2 extends Format { // If there is only one item left on the page, it's a permalink, and just use that if(count($items) == 1) { - $item = $mf2['items'][0]; + $item = $items[0]; if(in_array('h-entry', $item['type']) || in_array('h-cite', $item['type'])) { #Parse::debug("mf2:0: Recognized $url as an h-entry it is the only item on the page"); return self::parseAsHEntry($mf2, $item, $http, $url); diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 86d5380..226b807 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -436,6 +436,18 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Primary Post', $data['data']['name']); } + public function testHEntryWithHCardBeforeIt() { + $url = 'http://source.example.com/h-entry-with-h-card-before-it'; + $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('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + public function testHEntryWithHCardSibling() { $url = 'http://source.example.com/h-entry-with-h-card-sibling'; $response = $this->parse(['url' => $url]); @@ -448,6 +460,18 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Hello World', $data['data']['content']['text']); } + public function testHEntryWithTwoHCardsBeforeIt() { + $url = 'http://source.example.com/h-entry-with-two-h-cards-before-it'; + $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('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + public function testHEntryRedirectWithHCardSibling() { $url = 'http://source.example.com/h-entry-redirect-with-h-card-sibling'; $response = $this->parse(['url' => $url]); diff --git a/tests/data/source.example.com/h-entry-with-h-card-before-it b/tests/data/source.example.com/h-entry-with-h-card-before-it new file mode 100644 index 0000000..01e5ea3 --- /dev/null +++ b/tests/data/source.example.com/h-entry-with-h-card-before-it @@ -0,0 +1,18 @@ +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 + + + + Test + + + Author Name +
+

Hello World

+ permalink +
+ + diff --git a/tests/data/source.example.com/h-entry-with-two-h-cards-before-it b/tests/data/source.example.com/h-entry-with-two-h-cards-before-it new file mode 100644 index 0000000..e73f91c --- /dev/null +++ b/tests/data/source.example.com/h-entry-with-two-h-cards-before-it @@ -0,0 +1,19 @@ +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 + + + + Test + + + Author Name + Author Org +
+

Hello World

+ permalink +
+ +