GitHub gist media messages
authorDarren <darren@Darrens-MacBook-Pro.local>
Sat, 25 May 2013 17:45:44 +0000 (18:45 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Sat, 25 May 2013 17:45:44 +0000 (18:45 +0100)
client/assets/css/style.css
client/assets/src/views/mediamessage.js

index d6a92115a3af4bba4e79db740681daf87e87f724..a3f6e3375bec93f3fa920c251fb4d3dae4748c30 100644 (file)
@@ -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 */
index 2f8028209653d729cbc2abedbc296b54202e9314..9a86d0d1876d5266a767a9706384870031fe0570 100644 (file)
@@ -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('<link rel="stylesheet" href="' + data.stylesheet + '" type="text/css" />');
+                that.$content.find('.content').html(data.div);
+            });
+
+            return $('<div>Loading gist..</div>');
         }
     }
     }, {
@@ -148,6 +161,12 @@ _kiwi.view.MediaMessage = Backbone.View.extend({
             html += '<span class="media youtube" data-type="youtube" data-url="' + url + '" data-ytid="' + matches[1] + '" title="YouTube Video"><a class="open"><i class="icon-chevron-right"></i></a></span>';
         }
 
+        // Is a github gist?
+        matches = (/https?:\/\/gist\.github\.com\/(?:[a-z0-9-]*\/)?([a-z0-9]+)(\#(.+))?$/i).exec(url);
+        if (matches) {
+            html += '<span class="media gist" data-type="gist" data-url="' + url + '" data-gist_id="' + matches[1] + '" title="GitHub Gist"><a class="open"><i class="icon-chevron-right"></i></a></span>';
+        }
+
         return html;
     }
 });