diff --git a/customize.dist/fsStore.js b/customize.dist/fsStore.js index c72163c36..e953f8354 100644 --- a/customize.dist/fsStore.js +++ b/customize.dist/fsStore.js @@ -76,8 +76,8 @@ define([ cb(void 0, Object.keys(storeObj)); }; - Store.addPad = function (href, data) { - filesOp.addPad(href, data); + Store.addPad = function (href, path, name) { + filesOp.addPad(href, path, name); }; Store.forgetPad = function (href, cb) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 7241a01af..d12e73c04 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -173,6 +173,11 @@ define([ var getSecrets = common.getSecrets = function (secretHash) { var secret = {}; + if (/#\?path=/.test(window.location.href)) { + var arr = window.location.hash.match(/\?path=(.+)/); + common.initialPath = arr[1] || undefined; + window.location.hash = ''; + } if (!secretHash && !/#/.test(window.location.href)) { secret.keys = Crypto.createEditCryptor(); secret.key = Crypto.createEditCryptor().editKeyStr; @@ -491,7 +496,7 @@ define([ var data = makePad(href, name); renamed.push(data); if (USE_FS_STORE && typeof(getStore().addPad) === "function") { - getStore().addPad(href); + getStore().addPad(href, common.initialPath, name); } } diff --git a/www/file/fileObject.js b/www/file/fileObject.js index 2f470d060..06b1b2ff8 100644 --- a/www/file/fileObject.js +++ b/www/file/fileObject.js @@ -547,10 +547,19 @@ define([ pushToTrash(key, href, [UNSORTED]); }; - var addUnsortedPad = exp.addPad = function (href) { + var addUnsortedPad = exp.addPad = function (href, path, name) { var unsortedFiles = getUnsortedFiles().slice(); var rootFiles = getRootFiles().slice(); var trashFiles = getTrashFiles().slice(); + if (path && name) { + var newPath = decodeURIComponent(path).split(','); + var parentEl = findElement(files, newPath); + if (parentEl) { + var newName = getAvailableName(parentEl, name); + parentEl[newName] = href; + return; + } + } if (unsortedFiles.indexOf(href) === -1 && rootFiles.indexOf(href) === -1 && trashFiles.indexOf(href) === -1) { files[UNSORTED].push(href); } diff --git a/www/file/inner.html b/www/file/inner.html index 2e86b4aca..e35ba1407 100644 --- a/www/file/inner.html +++ b/www/file/inner.html @@ -23,7 +23,7 @@