Browse Source

support featured images from events

closes #92
pull/93/head
Aaron Parecki 4 years ago
parent
commit
b0b2fc1ee8
No known key found for this signature in database GPG Key ID: 276C2817346D6056
3 changed files with 39 additions and 1 deletions
  1. +1
    -1
      lib/XRay/Formats/Mf2.php
  2. +12
    -0
      tests/ParseTest.php
  3. +26
    -0
      tests/data/source.example.com/h-event-featured

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

@ -637,7 +637,7 @@ class Mf2 extends Format {
$refs = [];
// Single plaintext and URL values
self::collectSingleValues(['name','summary','published','start','end','duration'], ['url'], $item, $url, $data);
self::collectSingleValues(['name','summary','published','start','end','duration'], ['url','featured'], $item, $url, $data);
// These properties are always returned as arrays and may contain plaintext content
self::collectArrayValues(['category','location','attendee'], $item, $data, $refs, $http);

+ 12
- 0
tests/ParseTest.php View File

@ -586,6 +586,18 @@ class ParseTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('Venue', $data['data']['refs']['http://source.example.com/venue']['name']);
}
public function testEventWithFeaturedImage() {
$url = 'http://source.example.com/h-event-featured';
$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('http://source.example.com/featured.jpg', $data['data']['featured']);
}
public function testMf2ReviewOfProduct() {
$url = 'http://source.example.com/h-review-of-product';
$response = $this->parse(['url' => $url]);

+ 26
- 0
tests/data/source.example.com/h-event-featured View File

@ -0,0 +1,26 @@
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
<html>
<head>
<title>Homebrew Website Club</title>
</head>
<body class="h-event">
<h2 class="p-name">Homebrew Website Club</h2>
<a href="/h-event" class="u-url">permalink</a>
<img src="/featured.jpg" class="u-featured">
<time class="dt-start" datetime="2016-03-09T18:30">March 9, 6:30pm</time> - <time class="dt-end" datetime="2016-03-09T19:30">7:30pm</time>
<div class="e-description">
<p>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...</p>
<p>See the <a href="http://tantek.com/2013/332/b1/homebrew-website-club-newsletter">Homebrew Website Club Newsletter Volume 1 Issue 1</a> for a description of the first meeting.</p>
</div>
</body>
</html>

Loading…
Cancel
Save