mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Disable filestorage
closes #937 - fixed bug where ![] is replaced with ![](http://) for image url - added fileStorage setting to uploader - added fileStorage helper (could become standard way of providing config data for frontend???) - added data element to editor and settings - if no config value is set fileStorage: true is default
This commit is contained in:
parent
7b90178e76
commit
0220cf2448
@ -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;
|
||||
|
@ -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: {
|
||||
|
@ -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));
|
||||
|
@ -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()) {
|
||||
|
@ -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 = [];
|
||||
|
@ -14,7 +14,7 @@
|
||||
Markdown
|
||||
<a class="markdown-help" href="#"><span class="hidden">What is Markdown?</span></a>
|
||||
</header>
|
||||
<section class="entry-markdown-content">
|
||||
<section id="entry-markdown-content" class="entry-markdown-content" data-filestorage={{fileStorage}}>
|
||||
<textarea id="entry-markdown"></textarea>
|
||||
</section>
|
||||
</section>{{!.entry-markdown}}
|
||||
|
@ -4,5 +4,5 @@
|
||||
|
||||
</aside>
|
||||
|
||||
<section class="settings-content"></section>
|
||||
<section class="settings-content" data-filestorage={{fileStorage}}></section>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user