From db65ef5b5d9b979d4a15bef6b54227904119ef66 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 25 Sep 2017 16:07:09 -0700 Subject: [PATCH] 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 0000000000000000000000000000000000000000..bb54c74975282c7720ae438af079d5368807387a GIT binary patch literal 1750 zcmaJ?Yfuwc7>y#2f+>U6Dwd`@!3U^hlRyHy5GW);f`mtih!!zRvOt7nW3osBDoB+= z6)h;JBLYe+Ra8{a5s@N_GQI$7L68cxfDv24qN1Q;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_IqAy3cMZ0!a`bIFb96X`;vbNc7MvTLS+(Zw-N@y`MUkq-ZM|nHkxyVm{a23N zx*4~c>uAl9C3Xe7?{z^d{I31c=CAxLGsnK=x(Es6_c2C?O0U-ElQa6B!sjkTLLODt z?6jAX=`RL{kC#mon7$P~JW=F-BahvpJG&))es0>nuEq8u{dZfrx-#a7iS=Q!pmy7m zlKo$n1@Vs@DrhvkZ#>meuoAa@)GCuXRV=YzqtmYsn-kny&FC~aO5-HnpM@Lw;HLA7UJ>}Iu_Ba2!akNpBVmgm>C~s*0W7*3l PvYhz#zuJz@P!dKp~(AL>x#lFaYIf0Tv{<9$uW}@gE!h4+ZFQ zixS+Az}$i^hs?*NAEahD>u>V2`VYb|0OL=JaDaz1KL5k?q0`6LEul#N$LEiU(hrM6 znEkV2UEum)a`@a2Q}grNSFjOF>hi(i0SX7095MRuo!Ad^0-PpA|Ek=u|Bucc`~TMNDs{Y4ZdcFVev~W4blVCPYL}W=!ynL@-Rp*09J?x AMgRZ+ literal 0 HcmV?d00001 diff --git a/public/images/services/github.ico b/public/images/services/github.ico new file mode 100644 index 0000000000000000000000000000000000000000..133f0ca35428bf551b9e37376997c1b681f44cad GIT binary patch literal 6518 zcmeH~KWrRD6vp>1XB|TKf7ixoz@b1XKnf)MM_{F(LQo?`fG`NCCGT zi=t9gj#{mVelFTQ6-C!YQ8YJ~jgu(4AKz|#q>$0|(?t>fVZU}eelCvVFB*+T$8wv^ zX1m=^KEnT$`SSWCNnVTNWP^5!_)eEIJ3W2XrW*V&JAco_zXI+zgsw(UrTbr<*cs#K zbdnEz5ZyNvo0@80U$55>G#bqnIIguEo@HOF)k^h^gJ*eFaq{*w>&;Ef^QBVhRJmN< zq@9K5Hp5q|)p>j;4QoBM-Vnz#Zzaj}CfE(8>0+(czSD4FU$3|C;5mLaJT<&Y``(Qo z2r=Q9=eW=1{{Y`vjhTbr$t{QZIpZ>zKZFsMb}qvo&&kbop>;gNp98<1+2@(dUAX|~ zr2cEb{FPzWSy%7KR?~ZOsktT^^Oi5H-jj_xozCkSs78OKBha{{v2rZm-Z4B&@@WlH z!!4w}L~M<9_MMvM2;adaP|&LsdD- z1#^%*?T_vLO03Dp;QPg|S@vmohWGdt^SNM8!tpo>=^pJR4l(qN;u${nTxMU6zG1{A z&LOgCI6KEy4a=GM8FTq8x{tu~JV{p!;t8MMIMg#2tKuGn&HS_Etr?E}{`8RizHpI# zR>K;A**?%eg9^|0xoK0!Ckly^wm>Z}Fo*Zz3eUG5L#G+)^B?$f(mF8hd1afG}!mNxOXZR~sI z`Wqy+tkV%?eOg6ap4)6`6Z_i6zUTcs&HR*rCQSXzDZ-euxIksp< zATDv{=p1DaEQfxLIr|^|xAeu8ry*_5%O~< z{tuTG3)ihUjL-Md^xV{Q*vDn_-VS6rRd^Q2Innher`b>6@{L|mlTGY&7CWI_aOpi= z99wyl!(Ll9m^K{8d@f`5NAf-`{a^26!)#$PY~TLIcT8HLepbWY?Pv|F#p2>ddvBh$ z`H1iTFKWoN_nS^pPYpMczixGp+lxz_MVeu(duGOmz+T#}zObynL*bqXwTi~wxrmqH yx;Sbb%0+kia-X@V4)%5e-vW1*CBNTP6METxOqP_R+#;??Y%&9r8JNs~X5er7V8d(x literal 0 HcmV?d00001 diff --git a/public/images/services/twitter.ico b/public/images/services/twitter.ico new file mode 100644 index 0000000000000000000000000000000000000000..b4a71699a727c7642612dfa116c748df3c530fe1 GIT binary patch literal 1150 zcmd5)O-lk%6un{KMi>_n?QH2z|AEpUs8vFnq*c3Gwi4VWK~P9g#F)@V5VDO#m`Wj1 zi6iuZF_nfwAvhW{l=i{vUUYJrrd$QR;mo~r?>*-o-Wz}ce5_W$_bAK`0t^Fy9f2jR zbm|xYu%};)G5ANYpck74Bbb{J{XCj*#{Sw6yiXUtu!>fR54lA4 zHxysAN(TX8VhETN?Lj%6j=#4XuHQ7e+FZMypOP~Zhgv@6j|r#P)iCrxe7TzR)b|{s zo~wS72F}r$7-?9PGhaxGak4sZ6qRee>dpf4>0kNuQHi@wj#q#YkM5It&HKEw zvi;RVDGcl(%E?Mi7}N4|k@4L-f%j@_lpk$43b`P#!WuBr&uqC<$yHmqQs8H_v+ADO z8s${K$u7?qQ$D|{Pqm-s_58p820X(Kni$hAfR+uQ$pMtj9i+Q4YXT@CSgFVP0GFBa AX8-^I literal 0 HcmV?d00001 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"); }