mirror of
https://github.com/SunRed/haste-server.git
synced 2024-11-23 17:50:19 +01:00
Added twitter functionality
This commit is contained in:
parent
b9e9bd154c
commit
f54712f9d9
3 changed files with 12 additions and 3 deletions
4
TODO
4
TODO
|
@ -1,9 +1,9 @@
|
||||||
cache headers for static assets
|
rccache headers for static assets
|
||||||
tests
|
tests
|
||||||
test in other browsers and add note to README
|
test in other browsers and add note to README
|
||||||
maximum size of a haste
|
maximum size of a haste
|
||||||
fix any annoying visual quirks
|
fix any annoying visual quirks
|
||||||
|
make twitter posting an option
|
||||||
|
|
||||||
# shared version only
|
# shared version only
|
||||||
twitter posting with ^T
|
|
||||||
some way to do announcements easily (and use for ads)
|
some way to do announcements easily (and use for ads)
|
||||||
|
|
|
@ -12,6 +12,7 @@ haste_document.prototype.load = function(key, callback) {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
_this.locked = true;
|
_this.locked = true;
|
||||||
|
_this.key = key;
|
||||||
_this.data = res.data;
|
_this.data = res.data;
|
||||||
var high = hljs.highlightAuto(res.data);
|
var high = hljs.highlightAuto(res.data);
|
||||||
callback({
|
callback({
|
||||||
|
@ -39,6 +40,7 @@ haste_document.prototype.save = function(data, callback) {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
_this.locked = true;
|
_this.locked = true;
|
||||||
|
_this.key = res.key;
|
||||||
var high = hljs.highlightAuto(data);
|
var high = hljs.highlightAuto(data);
|
||||||
callback({
|
callback({
|
||||||
value: high.value,
|
value: high.value,
|
||||||
|
@ -53,6 +55,7 @@ haste_document.prototype.save = function(data, callback) {
|
||||||
|
|
||||||
var haste = function(appName) {
|
var haste = function(appName) {
|
||||||
this.appName = appName;
|
this.appName = appName;
|
||||||
|
this.baseUrl = window.location.href; // since this is loaded first
|
||||||
this.$textarea = $('textarea');
|
this.$textarea = $('textarea');
|
||||||
this.$box = $('#box');
|
this.$box = $('#box');
|
||||||
this.$code = $('#box code');
|
this.$code = $('#box code');
|
||||||
|
@ -148,6 +151,11 @@ haste.prototype.configureShortcuts = function() {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
_this.duplicateDocument();
|
_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));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
<em>haste</em>
|
<em>haste</em>
|
||||||
^s - save<br>
|
^s - save<br>
|
||||||
^n - new<br>
|
^n - new<br>
|
||||||
^d - duplicate
|
^d - duplicate<br>
|
||||||
|
^t - tweet
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pre id="box" style="display:none;"><code></code></pre>
|
<pre id="box" style="display:none;"><code></code></pre>
|
||||||
|
|
Loading…
Reference in a new issue