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 ++++++++++++++++++++++++++-- public/images/services/default.png | Bin 0 -> 1750 bytes public/images/services/facebook.ico | Bin 0 -> 1150 bytes public/images/services/github.ico | Bin 0 -> 6518 bytes public/images/services/twitter.ico | Bin 0 -> 1150 bytes views/new-post.php | 16 +++++++++++++++- 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 public/images/services/default.png create mode 100644 public/images/services/facebook.ico create mode 100644 public/images/services/github.ico create mode 100644 public/images/services/twitter.ico 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, ])); } }); diff --git a/public/images/services/default.png b/public/images/services/default.png new file mode 100644 index 0000000..bb54c74 Binary files /dev/null and b/public/images/services/default.png differ diff --git a/public/images/services/facebook.ico b/public/images/services/facebook.ico new file mode 100644 index 0000000..1bdf7e1 Binary files /dev/null and b/public/images/services/facebook.ico differ diff --git a/public/images/services/github.ico b/public/images/services/github.ico new file mode 100644 index 0000000..133f0ca Binary files /dev/null and b/public/images/services/github.ico differ diff --git a/public/images/services/twitter.ico b/public/images/services/twitter.ico new file mode 100644 index 0000000..b4a7169 Binary files /dev/null and b/public/images/services/twitter.ico differ diff --git a/views/new-post.php b/views/new-post.php index f84f231..726a671 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -16,7 +16,7 @@
-
+
@@ -244,6 +244,13 @@ width: 48px; margin-right: 4px; } +.reply-context .syndications { + float: right; + padding-right: 4px; +} +.reply-context .syndications img { + width: 16px; +} .reply-context .author { color: #777; font-weight: bold; @@ -582,6 +589,13 @@ $(function(){ } else { $("#form_rsvp").addClass("hidden"); } + if(data.syndications) { + $(".reply-context .syndications").html(''); + for(var i in data.syndications) { + var syn = data.syndications[i]; + $(".reply-context .syndications").append(''); + } + } $(".reply-context").removeClass("hidden"); } -- cgit v1.2.3