From 5b01f32bb66ca104addb51cfef7c773f101d0645 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 25 May 2013 18:45:44 +0100 Subject: [PATCH] GitHub gist media messages --- client/assets/css/style.css | 1 + client/assets/src/views/mediamessage.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/client/assets/css/style.css b/client/assets/css/style.css index d6a9211..a3f6e33 100644 --- a/client/assets/css/style.css +++ b/client/assets/css/style.css @@ -98,6 +98,7 @@ html, body { height:100%; } #kiwi .messages .msg.global_nick_highlight { } #kiwi .messages .msg.highlight { } +#kiwi .messages .msg .media .media_content { white-space: normal; } /* A member/nick list per channel */ diff --git a/client/assets/src/views/mediamessage.js b/client/assets/src/views/mediamessage.js index 2f80282..9a86d0d 100644 --- a/client/assets/src/views/mediamessage.js +++ b/client/assets/src/views/mediamessage.js @@ -111,6 +111,19 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ that.$content.find('.content').html(yt_html); return $(''); + }, + + + gist: function () { + var that = this, + matches = (/https?:\/\/gist\.github\.com\/(?:[a-z0-9-]*\/)?([a-z0-9]+)(\#(.+))?$/i).exec(this.url); + + $.getJSON('https://gist.github.com/'+matches[1]+'.json?callback=?' + (matches[2] || ''), function (data) { + $('body').append(''); + that.$content.find('.content').html(data.div); + }); + + return $('
Loading gist..
'); } } }, { @@ -148,6 +161,12 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ html += ''; } + // Is a github gist? + matches = (/https?:\/\/gist\.github\.com\/(?:[a-z0-9-]*\/)?([a-z0-9]+)(\#(.+))?$/i).exec(url); + if (matches) { + html += ''; + } + return html; } }); -- 2.25.1