Merge branch 'master' of codeplane.com:seejohnrun/haste-server
Conflicts: TODO.md
This commit is contained in:
commit
f651c30981
19 changed files with 477 additions and 183 deletions
|
@ -14,11 +14,16 @@ haste_document.prototype.load = function(key, callback, lang) {
|
|||
_this.locked = true;
|
||||
_this.key = key;
|
||||
_this.data = res.data;
|
||||
var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data);
|
||||
try {
|
||||
var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data);
|
||||
} catch(err) {
|
||||
// failed highlight, fall back on auto
|
||||
high = hljs.highlightAuto(res.data);
|
||||
}
|
||||
callback({
|
||||
value: high.value,
|
||||
key: key,
|
||||
language: lang || high.language
|
||||
language: high.language || lang
|
||||
});
|
||||
},
|
||||
error: function(err) {
|
||||
|
@ -77,11 +82,13 @@ haste.prototype.setTitle = function(ext) {
|
|||
// Show the light key
|
||||
haste.prototype.lightKey = function() {
|
||||
this.configureKey(['new', 'save']);
|
||||
this.removeClip();
|
||||
};
|
||||
|
||||
// Show the full key
|
||||
haste.prototype.fullKey = function() {
|
||||
this.configureKey(['new', 'duplicate', 'twitter', 'link']);
|
||||
this.configureClip();
|
||||
};
|
||||
|
||||
// Set the key up for certain things to be enabled
|
||||
|
@ -116,8 +123,12 @@ haste.prototype.newDocument = function(hideHistory) {
|
|||
|
||||
// Map of common extensions
|
||||
haste.extensionMap = {
|
||||
'rb': 'ruby',
|
||||
'py': 'python'
|
||||
rb: 'ruby', py: 'python', pl: 'perl', php: 'php', scala: 'scala', go: 'go',
|
||||
xml: 'xml', html: 'xml', htm: 'xml', css: 'css', js: 'javascript', vbs: 'vbscript',
|
||||
lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec',
|
||||
vala: 'vala', cs: 'cs', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini',
|
||||
diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell',
|
||||
md: 'markdown'
|
||||
};
|
||||
|
||||
// Map an extension to a language
|
||||
|
@ -171,14 +182,32 @@ haste.prototype.lockDocument = function() {
|
|||
title += ' - ' + ret.language;
|
||||
}
|
||||
_this.setTitle(title);
|
||||
_this.fullKey();
|
||||
window.history.pushState(null, _this.appName + '-' + ret.key, '/' + ret.key);
|
||||
_this.fullKey();
|
||||
_this.$textarea.val('').hide();
|
||||
_this.$box.show().focus();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// set up a clip that will copy the current url
|
||||
haste.prototype.configureClip = function() {
|
||||
var clip = this.clipper = new ZeroClipboard.Client();
|
||||
this.clipper.setHandCursor(true);
|
||||
this.clipper.setCSSEffects(false);
|
||||
// and then set and show
|
||||
this.clipper.setText(window.location.href);
|
||||
$('#key .box2 .link').html(this.clipper.getHTML(32, 37));
|
||||
};
|
||||
|
||||
// hide the current clip, if it exists
|
||||
haste.prototype.removeClip = function() {
|
||||
if (this.clipper) {
|
||||
this.clipper.destroy();
|
||||
}
|
||||
$('#key .box2 .link').html('');
|
||||
};
|
||||
|
||||
haste.prototype.configureButtons = function() {
|
||||
var _this = this;
|
||||
this.buttons = [
|
||||
|
@ -231,9 +260,8 @@ haste.prototype.configureButtons = function() {
|
|||
{
|
||||
$where: $('#key .box2 .link'),
|
||||
label: 'Copy URL',
|
||||
action: function() {
|
||||
alert('not yet implemented');
|
||||
}
|
||||
letBubble: true,
|
||||
action: function() { }
|
||||
}
|
||||
];
|
||||
for (var i = 0; i < this.buttons.length; i++) {
|
||||
|
@ -271,7 +299,9 @@ haste.prototype.configureShortcuts = function() {
|
|||
for (var i = 0 ; i < _this.buttons.length; i++) {
|
||||
button = _this.buttons[i];
|
||||
if (button.shortcut && button.shortcut(evt)) {
|
||||
evt.preventDefault();
|
||||
if (!button.letBubble) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
button.action();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue