Browse Source

parse quotation-of from HTML as well

closes #73
pull/78/head v1.4.32
Aaron Parecki 5 years ago
parent
commit
112b75b623
No known key found for this signature in database GPG Key ID: 276C2817346D6056
3 changed files with 72 additions and 1 deletions
  1. +1
    -1
      lib/XRay/Formats/Mf2.php
  2. +16
    -0
      tests/ParseTest.php
  3. +55
    -0
      tests/data/source.example.com/quotation-of

+ 1
- 1
lib/XRay/Formats/Mf2.php View File

@ -431,7 +431,7 @@ class Mf2 extends Format {
// These properties are always returned as arrays and always URLs
// 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','in-reply-to','like-of','repost-of','bookmark-of'], $item, $data, $refs, $http);
self::collectArrayURLValues(['photo','video','audio','syndication','in-reply-to','like-of','repost-of','bookmark-of','quotation-of'], $item, $data, $refs, $http);
self::determineNameAndContent($item, $data);

+ 16
- 0
tests/ParseTest.php View File

@ -779,6 +779,22 @@ class ParseTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(1, count($data['data']['like-of']));
}
public function testQuotationOf() {
$url = 'http://source.example.com/quotation-of';
$response = $this->parse(['url' => $url]);
$body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body, true);
$this->assertEquals('I’m so making this into a t-shirt', $data['data']['content']['text']);
$this->assertEquals('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['quotation-of'][0]);
$this->assertArrayHasKey('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['refs']);
$q = $data['data']['refs']['https://twitter.com/gitlost/status/1015005409726357504'];
$this->assertEquals("Still can't git fer shit", $q['content']['text']);
$this->assertEquals('2018-07-05T22:52:02+00:00', $q['published']);
}
public function testHTML5Markup() {
$url = 'http://source.example.com/html5-tags';
$response = $this->parse(['url' => $url]);

+ 55
- 0
tests/data/source.example.com/quotation-of View File

@ -0,0 +1,55 @@
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
<article class="h-entry">
<span class="p-uid">tag:twitter.com:1015014506651668480</span>
<time class="dt-published" datetime="2018-07-05T23:28:11+00:00">2018-07-05T23:28:11+00:00</time>
<span class="p-author h-card">
<data class="p-uid" value="tag:twitter.com:miklb"></data>
<data class="p-numeric-id" value="6187652"></data>
<a class="p-name u-url" href="https://miklb.com">Michael Bishop</a>
<span class="p-nickname">miklb</span>
<img class="u-photo" src="https://pbs.twimg.com/profile_images/799821749386874880/X_vv7MnK.jpg" alt="" />
</span>
<a class="u-url" href="https://twitter.com/miklb/status/1015014506651668480">https://twitter.com/miklb/status/1015014506651668480</a>
<div class="e-content p-name">
I’m so making this into a t-shirt
</div>
<article class="u-quotation-of h-cite">
<span class="p-uid">tag:twitter.com:1015005409726357504</span>
<time class="dt-published" datetime="2018-07-05T22:52:02+00:00">2018-07-05T22:52:02+00:00</time>
<span class="p-author h-card">
<data class="p-uid" value="tag:twitter.com:gitlost"></data>
<data class="p-numeric-id" value="1240421984"></data>
<a class="p-name u-url" href="https://twitter.com/gitlost">Developers Swearing</a>
<span class="p-nickname">gitlost</span>
<img class="u-photo" src="https://pbs.twimg.com/profile_images/3336578378/a60d4b744784d4ab05ee1846234e0708.jpeg" alt="" />
</span>
<a class="u-url" href="https://twitter.com/gitlost/status/1015005409726357504">https://twitter.com/gitlost/status/1015005409726357504</a>
<div class="e-content p-name">
Still can't git fer shit
</div>
</article>

Loading…
Cancel
Save