From f54712f9d916567614fac6c15e2f28863f694733 Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Sat, 19 Nov 2011 00:23:53 -0500 Subject: [PATCH] Added twitter functionality --- TODO | 4 ++-- static/application.js | 8 ++++++++ static/index.html | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 9a3a534..b19d6b3 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,9 @@ -cache headers for static assets +rccache headers for static assets tests test in other browsers and add note to README maximum size of a haste fix any annoying visual quirks +make twitter posting an option # shared version only -twitter posting with ^T some way to do announcements easily (and use for ads) diff --git a/static/application.js b/static/application.js index 3a5fa4d..d9e7eb3 100644 --- a/static/application.js +++ b/static/application.js @@ -12,6 +12,7 @@ haste_document.prototype.load = function(key, callback) { dataType: 'json', success: function(res) { _this.locked = true; + _this.key = key; _this.data = res.data; var high = hljs.highlightAuto(res.data); callback({ @@ -39,6 +40,7 @@ haste_document.prototype.save = function(data, callback) { dataType: 'json', success: function(res) { _this.locked = true; + _this.key = res.key; var high = hljs.highlightAuto(data); callback({ value: high.value, @@ -53,6 +55,7 @@ haste_document.prototype.save = function(data, callback) { var haste = function(appName) { this.appName = appName; + this.baseUrl = window.location.href; // since this is loaded first this.$textarea = $('textarea'); this.$box = $('#box'); this.$code = $('#box code'); @@ -148,6 +151,11 @@ haste.prototype.configureShortcuts = function() { evt.preventDefault(); _this.duplicateDocument(); } + // ^T for redirecting to twitter + else if (_this.doc.locked && evt.ctrlKey && evt.keyCode == 84) { + evt.preventDefault(); + window.open('https://twitter.com/share?url=' + encodeURI(_this.baseUrl + _this.doc.key)); + } }); }; diff --git a/static/index.html b/static/index.html index 49a1cb8..8d321b8 100644 --- a/static/index.html +++ b/static/index.html @@ -36,7 +36,8 @@ haste ^s - save
^n - new
- ^d - duplicate + ^d - duplicate
+ ^t - tweet