Skip to content

Commit

Permalink
[ReutersBridge] Change timestamp, add new feed, add alt text to image.
Browse files Browse the repository at this point in the history
- Change timestamp for each article from modified date to published date.
- Add new 'Fact Check' feed.
- Add support for Twitter embed.
- Add alt text for each images (not include those chart/graphic).
  • Loading branch information
csisoap committed Jun 7, 2021
1 parent 3f82f52 commit 5a7b7d8
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions bridges/ReutersBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ReutersBridge extends BridgeAbstract
'Energy' => 'energy',
'Entertainment' => 'chan:8ym8q8dl',
'Environment' => 'chan:6u4f0jgs',
'Fact Check' => 'chan:abtpk0vm',
'Health' => 'chan:8hw7807a',
'Lifestyle' => 'life',
'Markets' => 'markets',
Expand Down Expand Up @@ -128,12 +129,14 @@ private function getArticle($feed_uri)
$authorlist = $first['story']['authors'];
$category = $first['story']['channel']['name'];
$image_list = $first['story']['images'];
$published_at = $first['story']['published_at'];

$content_detail = array(
'content' => $this->handleArticleContent($article_content),
'author' => $this->handleAuthorName($authorlist),
'category' => $category,
'images' => $this->handleImage($image_list),
'published_at' => $published_at
);
return $content_detail;
}
Expand All @@ -144,7 +147,7 @@ private function handleImage($images) {
foreach($images as $image) { // Add more image to article.
$image_url = $image['url'];
$image_caption = $image['caption'];
$img = "<img src=\"$image_url\">";
$img = "<img src=\"$image_url\" alt=\"$image_caption\">";
$img_caption = "<figcaption style=\"text-align: center;\"><i>$image_caption</i></figcaption>";
$figure = "<figure>$img \t $img_caption</figure>";
$img_placeholder = $img_placeholder . $figure;
Expand Down Expand Up @@ -202,6 +205,22 @@ private function handleArticleContent($contents) {
case 'p_table':
$description = $description . $content['content'];
break;
case 'upstream_embed':
$media_type = $content['media_type'];
$cid = $content['cid'];
$embed = '';
if($media_type == 'tweet') {
$embed .= "<iframe
src=\"https://platform.twitter.com/embed/Tweet.html?id=$cid\"
title=\"Twitter Tweet\"
scrolling=\"no\"
frameborder=\"0\"
allowtransparency=\"true\"
allowfullscreen=\"true\"
style=\"width: 550px;height: 225px;\">
</iframe>";
}
$description .= $embed;
}
}

Expand Down Expand Up @@ -253,7 +272,7 @@ public function collectData()
}

$item['title'] = $story['story']['hed'];
$item['timestamp'] = $story['story']['updated_at'];
$item['timestamp'] = $content_detail['published_at'];
$item['uri'] = $story['template_action']['url'];
$this->items[] = $item;
}
Expand Down

0 comments on commit 5a7b7d8

Please sign in to comment.