Change to relative path and /var/attachments to store

This commit is contained in:
Romulus Urakagi Tsai 2020-01-14 06:29:34 +00:00
parent 6ebd6defe9
commit d26bf04bfa
5 changed files with 31 additions and 27 deletions

View file

@ -47,7 +47,7 @@ Template.attachmentsGalery.events({
Template.attachmentsGalery.helpers({ Template.attachmentsGalery.helpers({
url() { url() {
return Attachments.link(this); return Attachments.link(this, 'original', '/');
}, },
isUploaded() { isUploaded() {
return !!this.meta.uploaded; return !!this.meta.uploaded;
@ -62,7 +62,7 @@ Template.previewAttachedImagePopup.events({
Template.previewAttachedImagePopup.helpers({ Template.previewAttachedImagePopup.helpers({
url() { url() {
return Attachments.link(this); return Attachments.link(this, 'original', '/');
} }
}); });

View file

@ -33,6 +33,6 @@ Template.minicard.helpers({
return Meteor.user().hasHiddenMinicardLabelText(); return Meteor.user().hasHiddenMinicardLabelText();
}, },
coverUrl() { coverUrl() {
return Attachments.findOne(this.coverId).link(); return Attachments.findOne(this.coverId).link('original', '/');
}, },
}); });

View file

@ -225,32 +225,33 @@ Template.editor.onRendered(() => {
$summernote.summernote('insertNode', img); $summernote.summernote('insertNode', img);
}; };
const processData = function(fileObj) { const processData = function(fileObj) {
// FIXME: Change to new API
Utils.processUploadedAttachment( Utils.processUploadedAttachment(
currentCard, currentCard,
fileObj, fileObj,
attachment => { { onUploaded:
if (attachment && attachment._id && attachment.isImage) { attachment => {
attachment.one('uploaded', function() { if (attachment && attachment._id && attachment.isImage) {
const maxTry = 3; attachment.one('uploaded', function() {
const checkItvl = 500; const maxTry = 3;
let retry = 0; const checkItvl = 500;
const checkUrl = function() { let retry = 0;
// even though uploaded event fired, attachment.url() is still null somehow //TODO const checkUrl = function() {
const url = attachment.link(); // even though uploaded event fired, attachment.url() is still null somehow //TODO
if (url) { const url = Attachments.link(attachment, 'original', '/');
insertImage( if (url) {
`${location.protocol}//${location.host}${url}`, insertImage(
); `${location.protocol}//${location.host}${url}`,
} else { );
retry++; } else {
if (retry < maxTry) { retry++;
setTimeout(checkUrl, checkItvl); if (retry < maxTry) {
setTimeout(checkUrl, checkItvl);
}
} }
} };
}; checkUrl();
checkUrl(); });
}); }
} }
}, },
); );

View file

@ -291,6 +291,8 @@ if (Meteor.isServer) {
} }
function storagePath(defaultPath) { function storagePath(defaultPath) {
// FIXME
return '/var/attachments';
const storePath = process.env.ATTACHMENTS_STORE_PATH; const storePath = process.env.ATTACHMENTS_STORE_PATH;
return storePath ? storePath : defaultPath; return storePath ? storePath : defaultPath;
} }

View file

@ -257,6 +257,7 @@ const myCommand :Spk.Manifest.Command = (
(key = "OAUTH2_TOKEN_ENDPOINT", value=""), (key = "OAUTH2_TOKEN_ENDPOINT", value=""),
(key = "LDAP_ENABLE", value="false"), (key = "LDAP_ENABLE", value="false"),
(key = "SANDSTORM", value="1"), (key = "SANDSTORM", value="1"),
(key = "METEOR_SETTINGS", value = "{\"public\": {\"sandstorm\": true}}") (key = "METEOR_SETTINGS", value = "{\"public\": {\"sandstorm\": true}}"),
(key = "ATTACHMENTS_STORE_PATH", value = "/var/attachments/")
] ]
); );