diff --git a/core/client/assets/lib/uploader.js b/core/client/assets/lib/uploader.js index 28b8ce93ff..2d2144436f 100644 --- a/core/client/assets/lib/uploader.js +++ b/core/client/assets/lib/uploader.js @@ -139,6 +139,10 @@ this.removeExtras(); this.buildExtras(); this.bindFileUpload(); + if (!settings.fileStorage) { + self.initUrl(); + return; + } $dropzone.find('a.image-url').on('click', function () { self.initUrl(); }); @@ -148,7 +152,9 @@ this.removeExtras(); $dropzone.addClass('image-uploader-url').removeClass('pre-image-uploader'); $dropzone.find('.js-fileupload').addClass('right'); - $dropzone.append($cancel); + if (settings.fileStorage) { + $dropzone.append($cancel); + } $dropzone.find('.js-cancel').on('click', function () { $dropzone.find('.js-url').remove(); $dropzone.find('.js-fileupload').removeClass('right'); @@ -162,9 +168,9 @@ $dropzone.find('div.description').before($url); $dropzone.find('.js-button-accept').on('click', function () { + val = $('#uploadurl').val(); $dropzone.trigger('uploadstart', [$dropzone.attr('id')]); $dropzone.find('div.description').hide(); - val = $('#uploadurl').val(); $dropzone.find('.js-fileupload').removeClass('right'); $dropzone.find('.js-url').remove(); $dropzone.find('button.centre').remove(); @@ -205,9 +211,9 @@ $.fn.upload = function (options) { var settings = $.extend({ progressbar: true, - editor: false + editor: false, + fileStorage: true }, options); - return this.each(function () { var $dropzone = $(this), ui; diff --git a/core/client/models/uploadModal.js b/core/client/models/uploadModal.js index 2c8aabb9ea..68dff9ba6e 100644 --- a/core/client/models/uploadModal.js +++ b/core/client/models/uploadModal.js @@ -1,4 +1,4 @@ -/*global Ghost, Backbone */ +/*global Ghost, Backbone, $ */ (function () { 'use strict'; Ghost.Models.uploadModal = Backbone.Model.extend({ @@ -8,8 +8,9 @@ type: 'action', style: ["wide"], animation: 'fade', - afterRender: function () { - this.$('.js-drop-zone').upload(); + afterRender: function (id) { + var filestorage = $('#' + this.options.model.id).data('filestorage'); + this.$('.js-drop-zone').upload({fileStorage: filestorage}); }, confirm: { reject: { diff --git a/core/client/views/editor.js b/core/client/views/editor.js index c8802b5bc5..34e68390f8 100644 --- a/core/client/views/editor.js +++ b/core/client/views/editor.js @@ -432,7 +432,8 @@ }, initUploads: function () { - this.$('.js-drop-zone').upload({editor: true}); + var filestorage = $('#entry-markdown-content').data('filestorage'); + this.$('.js-drop-zone').upload({editor: true, fileStorage: filestorage}); this.$('.js-drop-zone').on('uploadstart', $.proxy(this.disableEditor, this)); this.$('.js-drop-zone').on('uploadstart', this.uploadMgr.handleDownloadStart); this.$('.js-drop-zone').on('uploadfailure', $.proxy(this.enableEditor, this)); diff --git a/core/client/views/settings.js b/core/client/views/settings.js index 3cbbd9fbfc..3ac12b88e0 100644 --- a/core/client/views/settings.js +++ b/core/client/views/settings.js @@ -200,7 +200,7 @@ this.showUpload('cover', settings.cover); }, showUpload: function (key, src) { - var self = this, upload = new Ghost.Models.uploadModal({'key': key, 'src': src, 'accept': { + var self = this, upload = new Ghost.Models.uploadModal({'key': key, 'src': src, 'id': this.id, 'accept': { func: function () { // The function called on acceptance var data = {}; if (this.$('#uploadurl').val()) { @@ -257,7 +257,7 @@ this.showUpload('image', user.image); }, showUpload: function (key, src) { - var self = this, upload = new Ghost.Models.uploadModal({'key': key, 'src': src, 'accept': { + var self = this, upload = new Ghost.Models.uploadModal({'key': key, 'src': src, 'id': this.id, 'accept': { func: function () { // The function called on acceptance var data = {}; if (this.$('#uploadurl').val()) { diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index 85796b64e5..7210e40b88 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -177,6 +177,18 @@ coreHelpers = function (ghost) { ); }); + // ### Filestorage helper + // + // *Usage example:* + // `{{fileStorage}}` + // + // Returns the config value for fileStorage. + ghost.registerThemeHelper('fileStorage', function (context, options) { + if (ghost.config().hasOwnProperty('fileStorage')) { + return ghost.config().fileStorage.toString(); + } + return "true"; + }); ghost.registerThemeHelper('body_class', function (options) { var classes = []; diff --git a/core/server/views/editor.hbs b/core/server/views/editor.hbs index 6ce9836a94..e74bef13d2 100644 --- a/core/server/views/editor.hbs +++ b/core/server/views/editor.hbs @@ -14,7 +14,7 @@ Markdown -
+
{{!.entry-markdown}} diff --git a/core/server/views/settings.hbs b/core/server/views/settings.hbs index 245bdbf553..20146805c4 100644 --- a/core/server/views/settings.hbs +++ b/core/server/views/settings.hbs @@ -4,5 +4,5 @@ -
+
\ No newline at end of file