pull/1/head
yflory 7 years ago
parent c85a551546
commit 470f404a24

@ -761,7 +761,7 @@ define([
UI.getFileIcon = function (data) { UI.getFileIcon = function (data) {
var $icon = UI.getIcon(); var $icon = UI.getIcon();
if (!data) { return $icon; } if (!data) { return $icon; }
var href = data.href; var href = data.href || data.roHref;
var type = data.type; var type = data.type;
if (!href && !type) { return $icon; } if (!href && !type) { return $icon; }

@ -73,6 +73,8 @@ define([
data.password = val; data.password = val;
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
var base = common.getMetadataMgr().getPrivateData().origin;
/* XXX
common.getPadAttribute('href', waitFor(function (err, val) { common.getPadAttribute('href', waitFor(function (err, val) {
var base = common.getMetadataMgr().getPrivateData().origin; var base = common.getMetadataMgr().getPrivateData().origin;
@ -93,6 +95,12 @@ define([
if (!hrefsecret.keys) { return; } if (!hrefsecret.keys) { return; }
var viewHash = Hash.getViewHashFromKeys(hrefsecret); var viewHash = Hash.getViewHashFromKeys(hrefsecret);
data.roHref = hBase + viewHash; data.roHref = hBase + viewHash;
}));*/
common.getPadAttribute('href', waitFor(function (err, val) {
data.href = base + val;
}));
common.getPadAttribute('roHref', waitFor(function (err, val) {
data.roHref = base + val;
})); }));
common.getPadAttribute('channel', waitFor(function (err, val) { common.getPadAttribute('channel', waitFor(function (err, val) {
data.channel = val; data.channel = val;
@ -162,7 +170,7 @@ define([
$d.append(password); $d.append(password);
} }
var parsed = Hash.parsePadUrl(data.href); var parsed = Hash.parsePadUrl(data.href || data.roHref);
if (owned && parsed.hashData.type === 'pad') { if (owned && parsed.hashData.type === 'pad') {
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var changePwTitle = Messages.properties_changePassword; var changePwTitle = Messages.properties_changePassword;
@ -186,7 +194,7 @@ define([
UI.confirm(changePwConfirm, function (yes) { UI.confirm(changePwConfirm, function (yes) {
if (!yes) { return; } if (!yes) { return; }
sframeChan.query("Q_PAD_PASSWORD_CHANGE", { sframeChan.query("Q_PAD_PASSWORD_CHANGE", {
href: data.href, href: data.href || data.roHref,
password: $(newPassword).find('input').val() password: $(newPassword).find('input').val()
}, function (err, data) { }, function (err, data) {
if (err || data.error) { if (err || data.error) {
@ -195,11 +203,11 @@ define([
UI.findOKButton().click(); UI.findOKButton().click();
if (data.warning) { if (data.warning) {
return void UI.alert(Messages.properties_passwordWarning, function () { return void UI.alert(Messages.properties_passwordWarning, function () {
common.gotoURL(hasPassword ? undefined : data.href); common.gotoURL(hasPassword ? undefined : (data.href || data.roHref));
}, {force: true}); }, {force: true});
} }
return void UI.alert(Messages.properties_passwordSuccess, function () { return void UI.alert(Messages.properties_passwordSuccess, function () {
common.gotoURL(hasPassword ? undefined : data.href); common.gotoURL(hasPassword ? undefined : (data.href || data.roHref));
}, {force: true}); }, {force: true});
}); });
}); });

@ -613,7 +613,7 @@ define([
if (!parsed.hash) { return void cb({ error: 'EINVAL_HREF' }); } if (!parsed.hash) { return void cb({ error: 'EINVAL_HREF' }); }
var warning = false; var warning = false;
var newHash; var newHash, newRoHref;
var oldChannel; var oldChannel;
if (parsed.hashData.password) { if (parsed.hashData.password) {
newHash = parsed.hash; newHash = parsed.hash;
@ -678,6 +678,11 @@ define([
common.setPadAttribute('channel', secret.channel, waitFor(function (err) { common.setPadAttribute('channel', secret.channel, waitFor(function (err) {
if (err) { warning = true; } if (err) { warning = true; }
}), href); }), href);
var viewHash = Hash.getViewHashFromKeys(secret);
newRoHref = '/' + parsed.type + '/#' + viewHash;
common.setPadAttribute('roHref', newRoHref, waitFor(function (err) {
if (err) { warning = true; }
}), href);
if (parsed.hashData.password) { return; } // same hash if (parsed.hashData.password) { return; } // same hash
common.setPadAttribute('href', newHref, waitFor(function (err) { common.setPadAttribute('href', newHref, waitFor(function (err) {
@ -687,7 +692,8 @@ define([
cb({ cb({
warning: warning, warning: warning,
hash: newHash, hash: newHash,
href: newHref href: newHref,
roHref: newRoHref
}); });
}); });
}; };

@ -666,10 +666,10 @@ define([
var openFile = function (el, href) { var openFile = function (el, href) {
if (!href) { if (!href) {
var data = filesOp.getFileData(el); var data = filesOp.getFileData(el);
if (!data || !data.href) { if (!data || (!data.href && !data.roHref)) {
return void logError("Missing data for the file", el, data); return void logError("Missing data for the file", el, data);
} }
href = data.href; href = data.href || data.roHref;
} }
window.open(APP.origin + href); window.open(APP.origin + href);
}; };
@ -1271,9 +1271,10 @@ define([
if (!filesOp.isFile(element)) { return; } if (!filesOp.isFile(element)) { return; }
var data = filesOp.getFileData(element); var data = filesOp.getFileData(element);
var href = data.href || data.roHref;
if (!data) { return void logError("No data for the file", element); } if (!data) { return void logError("No data for the file", element); }
var hrefData = Hash.parsePadUrl(data.href); var hrefData = Hash.parsePadUrl(href);
if (hrefData.type) { if (hrefData.type) {
$span.addClass('cp-border-color-'+hrefData.type); $span.addClass('cp-border-color-'+hrefData.type);
} }
@ -1305,7 +1306,7 @@ define([
$span.attr('title', name); $span.attr('title', name);
var type = Messages.type[hrefData.type] || hrefData.type; var type = Messages.type[hrefData.type] || hrefData.type;
common.displayThumbnail(data.href, data.channel, data.password, $span, function ($thumb) { common.displayThumbnail(href || data.roHref, data.channel, data.password, $span, function ($thumb) {
// Called only if the thumbnail exists // Called only if the thumbnail exists
// Remove the .hide() added by displayThumnail() because it hides the icon in // Remove the .hide() added by displayThumnail() because it hides the icon in
// list mode too // list mode too
@ -1847,7 +1848,7 @@ define([
var data = filesOp.getFileData(id); var data = filesOp.getFileData(id);
if (!data) { return ''; } if (!data) { return ''; }
if (prop === 'type') { if (prop === 'type') {
var hrefData = Hash.parsePadUrl(data.href); var hrefData = Hash.parsePadUrl(data.href || data.roHref);
return hrefData.type; return hrefData.type;
} }
if (prop === 'atime' || prop === 'ctime') { if (prop === 'atime' || prop === 'ctime') {
@ -1882,7 +1883,7 @@ define([
}; };
} }
if (prop === 'type') { if (prop === 'type') {
var hrefData = Hash.parsePadUrl(e.href); var hrefData = Hash.parsePadUrl(e.href || e.roHref);
return hrefData.type; return hrefData.type;
} }
if (prop === 'atime' || prop === 'ctime') { if (prop === 'atime' || prop === 'ctime') {
@ -2690,10 +2691,12 @@ define([
return $div.html(); return $div.html();
}; };
/* XXX
var getReadOnlyUrl = APP.getRO = function (id) { var getReadOnlyUrl = APP.getRO = function (id) {
if (!filesOp.isFile(id)) { return; } if (!filesOp.isFile(id)) { return; }
var data = filesOp.getFileData(id); var data = filesOp.getFileData(id);
if (!data) { return; } if (!data) { return; }
if (data.roHref) { return data.roHref; }
var parsed = Hash.parsePadUrl(data.href); var parsed = Hash.parsePadUrl(data.href);
if (parsed.hashData.type !== "pad") { return; } if (parsed.hashData.type !== "pad") { return; }
var i = data.href.indexOf('#') + 1; var i = data.href.indexOf('#') + 1;
@ -2702,7 +2705,7 @@ define([
if (!hrefsecret.keys) { return; } if (!hrefsecret.keys) { return; }
var viewHash = Hash.getViewHashFromKeys(hrefsecret); var viewHash = Hash.getViewHashFromKeys(hrefsecret);
return base + viewHash; return base + viewHash;
}; };*/
// Disable middle click in the context menu to avoid opening /drive/inner.html# in new tabs // Disable middle click in the context menu to avoid opening /drive/inner.html# in new tabs
$(window).click(function (e) { $(window).click(function (e) {
@ -2717,12 +2720,14 @@ define([
if (!filesOp.isFile(el)) { if (!filesOp.isFile(el)) {
return void cb('NOT_FILE'); return void cb('NOT_FILE');
} }
var ro = filesOp.isReadOnlyFile(el); //var ro = filesOp.isReadOnlyFile(el);
var base = APP.origin; var base = APP.origin;
var data = JSON.parse(JSON.stringify(filesOp.getFileData(el))); var data = JSON.parse(JSON.stringify(filesOp.getFileData(el)));
if (!data || !data.href) { return void cb('INVALID_FILE'); } if (!data || !data.href) { return void cb('INVALID_FILE'); }
data.href = base + data.href; data.href = base + data.href;
data.roHref = base + data.roHref;
/* XXX
var roUrl; var roUrl;
if (ro) { if (ro) {
data.roHref = data.href; data.roHref = data.href;
@ -2731,6 +2736,7 @@ define([
roUrl = getReadOnlyUrl(el); roUrl = getReadOnlyUrl(el);
if (roUrl) { data.roHref = base + roUrl; } if (roUrl) { data.roHref = base + roUrl; }
} }
*/
UIElements.getProperties(common, data, cb); UIElements.getProperties(common, data, cb);
}; };
@ -2806,8 +2812,9 @@ define([
var el = filesOp.find(p.path); var el = filesOp.find(p.path);
if (filesOp.isPathIn(p.path, [FILES_DATA])) { el = el.href; } if (filesOp.isPathIn(p.path, [FILES_DATA])) { el = el.href; }
if (!el || filesOp.isFolder(el)) { return; } if (!el || filesOp.isFolder(el)) { return; }
var roUrl = getReadOnlyUrl(el); // var roUrl = getReadOnlyUrl(el);
openFile(null, roUrl); openFile(el);
//, roUrl); XXX
}); });
} }
else if ($(this).hasClass('cp-app-drive-context-newfolder')) { else if ($(this).hasClass('cp-app-drive-context-newfolder')) {
@ -2847,7 +2854,7 @@ define([
el = filesOp.find(paths[0].path); el = filesOp.find(paths[0].path);
var data = filesOp.getFileData(el); var data = filesOp.getFileData(el);
if (!data) { return void console.error("Expected to find a file"); } if (!data) { return void console.error("Expected to find a file"); }
var href = data.href; var href = data.href || data.roHref;
common.updateTags(href); common.updateTags(href);
} }
else if ($(this).hasClass("cp-app-drive-context-empty")) { else if ($(this).hasClass("cp-app-drive-context-empty")) {

Loading…
Cancel
Save