From db65ef5b5d9b979d4a15bef6b54227904119ef66 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 25 Sep 2017 16:07:09 -0700 Subject: show syndication links with icons in reply context --- controllers/controllers.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'controllers') diff --git a/controllers/controllers.php b/controllers/controllers.php index b097bad..b028193 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -767,14 +767,38 @@ $app->get('/reply/preview', function() use($app) { } $mentions = array_values(array_unique($mentions)); + } - } + $syndications = []; + if($entry && isset($entry['syndication'])) { + foreach($entry['syndication'] as $s) { + $host = parse_url($s, PHP_URL_HOST); + switch($host) { + case 'twitter.com': + case 'www.twitter.com': + $icon = 'twitter.ico'; break; + case 'facebook.com': + case 'www.facebook.com': + $icon = 'facebook.ico'; break; + case 'github.com': + case 'www.github.com': + $icon = 'github.ico'; break; + default: + $icon = 'default.png'; break; + } + $syndications[] = [ + 'url' => $s, + 'icon' => $icon + ]; + } + } $app->response()['Content-type'] = 'application/json'; $app->response()->body(json_encode([ 'canonical_reply_url' => $reply_url, 'entry' => $entry, - 'mentions' => $mentions + 'mentions' => $mentions, + 'syndications' => $syndications, ])); } }); -- cgit v1.2.3