Merge branch 'staging' into framework
This commit is contained in:
@@ -76,6 +76,7 @@ define([
|
||||
common.renamePad(title || "", href, function (err) {
|
||||
if (err) { return void console.error(err); }
|
||||
onComplete(href);
|
||||
common.setPadAttribute('fileType', metadata.type, null, href);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -179,9 +179,11 @@ define([
|
||||
var tagger = dialog.frame([
|
||||
dialog.message([
|
||||
Messages.tags_add,
|
||||
h('p', Messages.tags_searchHint)
|
||||
h('br'),
|
||||
Messages.tags_searchHint,
|
||||
]),
|
||||
input,
|
||||
h('center', h('small', Messages.tags_notShared)),
|
||||
dialog.nav(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -489,8 +489,8 @@ define([
|
||||
};
|
||||
|
||||
// STORAGE
|
||||
common.setPadAttribute = function (attr, value, cb) {
|
||||
var href = getRelativeHref(window.location.href);
|
||||
common.setPadAttribute = function (attr, value, cb, href) {
|
||||
href = getRelativeHref(href || window.location.href);
|
||||
getStore().setPadAttribute(href, attr, value, cb);
|
||||
};
|
||||
common.setDisplayName = function (value, cb) {
|
||||
@@ -1204,8 +1204,8 @@ define([
|
||||
};
|
||||
|
||||
// Forget button
|
||||
var moveToTrash = common.moveToTrash = function (cb) {
|
||||
var href = window.location.href;
|
||||
var moveToTrash = common.moveToTrash = function (cb, href) {
|
||||
href = href || window.location.href;
|
||||
common.forgetPad(href, function (err) {
|
||||
if (err) {
|
||||
console.log("unable to forget pad");
|
||||
|
||||
@@ -62,6 +62,46 @@ define([
|
||||
editor.scrollTo(scroll.left, scroll.top);
|
||||
};
|
||||
|
||||
module.getHeadingText = function (editor) {
|
||||
var lines = editor.getValue().split(/\n/);
|
||||
|
||||
var text = '';
|
||||
lines.some(function (line) {
|
||||
// lines including a c-style comment are also valuable
|
||||
var clike = /^\s*(\/\*|\/\/)(.*)?(\*\/)*$/;
|
||||
if (clike.test(line)) {
|
||||
line.replace(clike, function (a, one, two) {
|
||||
if (!(two && two.replace)) { return; }
|
||||
text = two.replace(/\*\/\s*$/, '').trim();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// lisps?
|
||||
var lispy = /^\s*(;|#\|)+(.*?)$/;
|
||||
if (lispy.test(line)) {
|
||||
line.replace(lispy, function (a, one, two) {
|
||||
text = two;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// lines beginning with a hash are potentially valuable
|
||||
// works for markdown, python, bash, etc.
|
||||
var hash = /^#+(.*?)$/;
|
||||
if (hash.test(line)) {
|
||||
line.replace(hash, function (a, one) {
|
||||
text = one;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO make one more pass for multiline comments
|
||||
});
|
||||
|
||||
return text.trim();
|
||||
};
|
||||
|
||||
module.create = function (Common, defaultMode, CMeditor) {
|
||||
var exp = {};
|
||||
var Messages = Cryptpad.Messages;
|
||||
@@ -152,43 +192,7 @@ define([
|
||||
}());
|
||||
|
||||
exp.getHeadingText = function () {
|
||||
var lines = editor.getValue().split(/\n/);
|
||||
|
||||
var text = '';
|
||||
lines.some(function (line) {
|
||||
// lines including a c-style comment are also valuable
|
||||
var clike = /^\s*(\/\*|\/\/)(.*)?(\*\/)*$/;
|
||||
if (clike.test(line)) {
|
||||
line.replace(clike, function (a, one, two) {
|
||||
if (!(two && two.replace)) { return; }
|
||||
text = two.replace(/\*\/\s*$/, '').trim();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// lisps?
|
||||
var lispy = /^\s*(;|#\|)+(.*?)$/;
|
||||
if (lispy.test(line)) {
|
||||
line.replace(lispy, function (a, one, two) {
|
||||
text = two;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// lines beginning with a hash are potentially valuable
|
||||
// works for markdown, python, bash, etc.
|
||||
var hash = /^#+(.*?)$/;
|
||||
if (hash.test(line)) {
|
||||
line.replace(hash, function (a, one) {
|
||||
text = one;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO make one more pass for multiline comments
|
||||
});
|
||||
|
||||
return text.trim();
|
||||
return module.getHeadingText(editor);
|
||||
};
|
||||
|
||||
exp.configureLanguage = function (cb, onModeChanged) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/file/file-crypto.js',
|
||||
'/common/common-thumbnail.js',
|
||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||
], function ($, FileCrypto) {
|
||||
], function ($, FileCrypto, Thumb) {
|
||||
var Nacl = window.nacl;
|
||||
var module = {};
|
||||
|
||||
@@ -220,30 +221,46 @@ define([
|
||||
|
||||
var handleFile = File.handleFile = function (file, e, thumbnail) {
|
||||
var thumb;
|
||||
var finish = function (arrayBuffer) {
|
||||
var file_arraybuffer;
|
||||
var finish = function () {
|
||||
var metadata = {
|
||||
name: file.name,
|
||||
type: file.type,
|
||||
};
|
||||
if (thumb) { metadata.thumbnail = thumb; }
|
||||
queue.push({
|
||||
blob: arrayBuffer,
|
||||
blob: file_arraybuffer,
|
||||
metadata: metadata,
|
||||
dropEvent: e
|
||||
});
|
||||
};
|
||||
|
||||
var processFile = function () {
|
||||
blobToArrayBuffer(file, function (e, buffer) {
|
||||
finish(buffer);
|
||||
});
|
||||
};
|
||||
|
||||
if (!thumbnail) { return void processFile(); }
|
||||
blobToArrayBuffer(thumbnail, function (e, buffer) {
|
||||
blobToArrayBuffer(file, function (e, buffer) {
|
||||
if (e) { console.error(e); }
|
||||
thumb = arrayBufferToString(buffer);
|
||||
processFile();
|
||||
file_arraybuffer = buffer;
|
||||
if (thumbnail) { // there is already a thumbnail
|
||||
return blobToArrayBuffer(thumbnail, function (e, buffer) {
|
||||
if (e) { console.error(e); }
|
||||
thumb = arrayBufferToString(buffer);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
if (!Thumb.isSupportedType(file.type)) { return finish(); }
|
||||
// make a resized thumbnail from the image..
|
||||
Thumb.fromImageBlob(file, function (e, thumb_blob) {
|
||||
if (e) { console.error(e); }
|
||||
if (!thumb_blob) { return finish(); }
|
||||
|
||||
blobToArrayBuffer(thumb_blob, function (e, buffer) {
|
||||
if (e) {
|
||||
console.error(e);
|
||||
return finish();
|
||||
}
|
||||
thumb = arrayBufferToString(buffer);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -150,9 +150,6 @@ define([
|
||||
'class': "fa fa-trash cryptpad-forget",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
if (!common.isStrongestStored()) {
|
||||
button.addClass('cp-toolbar-hidden');
|
||||
}
|
||||
if (callback) {
|
||||
button
|
||||
.click(common.prepareFeedback(type))
|
||||
@@ -216,7 +213,7 @@ define([
|
||||
title: Messages.tags_title,
|
||||
})
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function () { UI.updateTags(null); });
|
||||
.click(function () { UI.updateTags(common, null); });
|
||||
break;
|
||||
default:
|
||||
button = $('<button>', {
|
||||
|
||||
@@ -216,6 +216,12 @@ define([
|
||||
});
|
||||
|
||||
sframeChan.on('Q_MOVE_TO_TRASH', function (data, cb) {
|
||||
cb = cb || $.noop;
|
||||
if (readOnly && hashes.editHash) {
|
||||
var appPath = window.location.pathname;
|
||||
Cryptpad.moveToTrash(cb, appPath + '#' + hashes.editHash);
|
||||
return;
|
||||
}
|
||||
Cryptpad.moveToTrash(cb);
|
||||
});
|
||||
|
||||
@@ -262,7 +268,7 @@ define([
|
||||
msg = parsed[1][4];
|
||||
if (msg) {
|
||||
msg = msg.replace(/^cp\|/, '');
|
||||
var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey);
|
||||
var decryptedMsg = crypto.decrypt(msg, true);
|
||||
msgs.push(decryptedMsg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -657,9 +657,10 @@ define([
|
||||
// We need to override the "a" tag action here because it is inside the iframe!
|
||||
var inDrive = /^\/drive/;
|
||||
|
||||
var origin = config.metadataMgr.getPrivateData().origin;
|
||||
|
||||
var href = inDrive.test(origin) ? origin+'/index.html' : origin+'/drive/';
|
||||
var privateData = config.metadataMgr.getPrivateData();
|
||||
var origin = privateData.origin;
|
||||
var pathname = privateData.pathname;
|
||||
var href = inDrive.test(pathname) ? origin+'/index.html' : origin+'/drive/';
|
||||
var buttonTitle = inDrive ? Messages.header_homeTitle : Messages.header_logoTitle;
|
||||
|
||||
var $aTag = $('<a>', {
|
||||
|
||||
Reference in New Issue
Block a user