summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-09-25 16:07:09 -0700
committerAaron Parecki <aaron@parecki.com>2017-09-25 16:07:09 -0700
commitdb65ef5b5d9b979d4a15bef6b54227904119ef66 (patch)
tree1ae22e1ebcda1a896aa8705479aefb617f6f6866 /controllers
parent1395055d8a9f36f816e0ae3cea9af69674d35fc8 (diff)
show syndication links with icons in reply context
Diffstat (limited to 'controllers')
-rw-r--r--controllers/controllers.php28
1 files changed, 26 insertions, 2 deletions
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,
]));
}
});