Browse Source

add follow-of posts

replaces #78
pull/83/head v1.8.0
Aaron Parecki 6 years ago
parent
commit
87b2cf10d8
No known key found for this signature in database GPG Key ID: 276C2817346D6056
6 changed files with 105 additions and 1 deletions
  1. +2
    -0
      README.md
  2. +1
    -1
      lib/XRay/Formats/Mf2.php
  3. +3
    -0
      lib/XRay/PostType.php
  4. +23
    -0
      tests/ParseTest.php
  5. +38
    -0
      tests/data/source.example.com/bridgy-follow
  6. +38
    -0
      tests/data/source.example.com/follow-of-h-card

+ 2
- 0
README.md View File

@ -384,6 +384,7 @@ If a property supports multiple values, it will always be returned as an array.
* `like-of` * `like-of`
* `repost-of` * `repost-of`
* `bookmark-of` * `bookmark-of`
* `follow-of`
* `syndication` * `syndication`
* `photo` (of an entry, not of a card) * `photo` (of an entry, not of a card)
* `video` * `video`
@ -410,6 +411,7 @@ The following post types are returned, which are slightly expanded from what is
* `like` * `like`
* `reply` * `reply`
* `bookmark` * `bookmark`
* `follow`
* `checkin` * `checkin`
* `video` * `video`
* `audio` * `audio`

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

@ -430,7 +430,7 @@ class Mf2 extends Format {
$refs = []; $refs = [];
// Single plaintext and URL values // Single plaintext and URL values
self::collectSingleValues(['published','summary','rsvp','swarm-coins'], ['url','featured'], $item, $url, $data);
self::collectSingleValues(['published','summary','rsvp','swarm-coins'], ['url','featured','follow-of'], $item, $url, $data);
if(isset($data['rsvp'])) if(isset($data['rsvp']))
$data['rsvp'] = strtolower($data['rsvp']); $data['rsvp'] = strtolower($data['rsvp']);

+ 3
- 0
lib/XRay/PostType.php View File

@ -26,6 +26,9 @@ class PostType {
if(isset($post['bookmark-of'])) if(isset($post['bookmark-of']))
return 'bookmark'; return 'bookmark';
if(isset($post['follow-of']))
return 'follow';
if(isset($post['checkin'])) if(isset($post['checkin']))
return 'checkin'; return 'checkin';

+ 23
- 0
tests/ParseTest.php View File

@ -970,4 +970,27 @@ class ParseTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('mf2+html', $data['source-format']); $this->assertEquals('mf2+html', $data['source-format']);
} }
public function testFollowOf() {
$url = 'http://source.example.com/bridgy-follow';
$response = $this->parse(['url' => $url]);
$body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body, true);
$this->assertEquals('https://realize.be/', $data['data']['follow-of']);
$this->assertEquals('follow', $data['data']['post-type']);
}
public function testFollowOfHCard() {
$url = 'http://source.example.com/follow-of-h-card';
$response = $this->parse(['url' => $url]);
$body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body, true);
$this->assertEquals('https://realize.be/', $data['data']['follow-of']);
$this->assertEquals('follow', $data['data']['post-type']);
}
} }

+ 38
- 0
tests/data/source.example.com/bridgy-follow View File

@ -0,0 +1,38 @@
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
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body>
<article class="h-entry">
<span class="p-uid">https://mastodon.social/b8177a60-8f80-47a0-b943-a9df876cf5d5</span>
<span class="p-author h-card">
<data class="p-uid" value="https://mastodon.social/users/swentel"></data>
<a class="u-url" href="https://mastodon.social/@swentel">https://mastodon.social/@swentel</a>
</span>
<span class="p-name"></span>
<div class="">
</div>
<a class="u-follow-of" href="https://realize.be/"></a>
</article>
</body>
</html>

+ 38
- 0
tests/data/source.example.com/follow-of-h-card View File

@ -0,0 +1,38 @@
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
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body>
<article class="h-entry">
<span class="p-uid">https://mastodon.social/b8177a60-8f80-47a0-b943-a9df876cf5d5</span>
<span class="p-author h-card">
<data class="p-uid" value="https://mastodon.social/users/swentel"></data>
<a class="u-url" href="https://mastodon.social/@swentel">https://mastodon.social/@swentel</a>
</span>
<span class="p-name"></span>
<div class="">
</div>
<a class="u-follow-of h-card" href="https://realize.be/">swentel</a>
</article>
</body>
</html>

Loading…
Cancel
Save