mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05: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
7 changed files with 32 additions and 12 deletions
|
@ -139,6 +139,10 @@
|
||||||
this.removeExtras();
|
this.removeExtras();
|
||||||
this.buildExtras();
|
this.buildExtras();
|
||||||
this.bindFileUpload();
|
this.bindFileUpload();
|
||||||
|
if (!settings.fileStorage) {
|
||||||
|
self.initUrl();
|
||||||
|
return;
|
||||||
|
}
|
||||||
$dropzone.find('a.image-url').on('click', function () {
|
$dropzone.find('a.image-url').on('click', function () {
|
||||||
self.initUrl();
|
self.initUrl();
|
||||||
});
|
});
|
||||||
|
@ -148,7 +152,9 @@
|
||||||
this.removeExtras();
|
this.removeExtras();
|
||||||
$dropzone.addClass('image-uploader-url').removeClass('pre-image-uploader');
|
$dropzone.addClass('image-uploader-url').removeClass('pre-image-uploader');
|
||||||
$dropzone.find('.js-fileupload').addClass('right');
|
$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-cancel').on('click', function () {
|
||||||
$dropzone.find('.js-url').remove();
|
$dropzone.find('.js-url').remove();
|
||||||
$dropzone.find('.js-fileupload').removeClass('right');
|
$dropzone.find('.js-fileupload').removeClass('right');
|
||||||
|
@ -162,9 +168,9 @@
|
||||||
$dropzone.find('div.description').before($url);
|
$dropzone.find('div.description').before($url);
|
||||||
|
|
||||||
$dropzone.find('.js-button-accept').on('click', function () {
|
$dropzone.find('.js-button-accept').on('click', function () {
|
||||||
|
val = $('#uploadurl').val();
|
||||||
$dropzone.trigger('uploadstart', [$dropzone.attr('id')]);
|
$dropzone.trigger('uploadstart', [$dropzone.attr('id')]);
|
||||||
$dropzone.find('div.description').hide();
|
$dropzone.find('div.description').hide();
|
||||||
val = $('#uploadurl').val();
|
|
||||||
$dropzone.find('.js-fileupload').removeClass('right');
|
$dropzone.find('.js-fileupload').removeClass('right');
|
||||||
$dropzone.find('.js-url').remove();
|
$dropzone.find('.js-url').remove();
|
||||||
$dropzone.find('button.centre').remove();
|
$dropzone.find('button.centre').remove();
|
||||||
|
@ -205,9 +211,9 @@
|
||||||
$.fn.upload = function (options) {
|
$.fn.upload = function (options) {
|
||||||
var settings = $.extend({
|
var settings = $.extend({
|
||||||
progressbar: true,
|
progressbar: true,
|
||||||
editor: false
|
editor: false,
|
||||||
|
fileStorage: true
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var $dropzone = $(this),
|
var $dropzone = $(this),
|
||||||
ui;
|
ui;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*global Ghost, Backbone */
|
/*global Ghost, Backbone, $ */
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
Ghost.Models.uploadModal = Backbone.Model.extend({
|
Ghost.Models.uploadModal = Backbone.Model.extend({
|
||||||
|
@ -8,8 +8,9 @@
|
||||||
type: 'action',
|
type: 'action',
|
||||||
style: ["wide"],
|
style: ["wide"],
|
||||||
animation: 'fade',
|
animation: 'fade',
|
||||||
afterRender: function () {
|
afterRender: function (id) {
|
||||||
this.$('.js-drop-zone').upload();
|
var filestorage = $('#' + this.options.model.id).data('filestorage');
|
||||||
|
this.$('.js-drop-zone').upload({fileStorage: filestorage});
|
||||||
},
|
},
|
||||||
confirm: {
|
confirm: {
|
||||||
reject: {
|
reject: {
|
||||||
|
|
|
@ -432,7 +432,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
initUploads: function () {
|
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', $.proxy(this.disableEditor, this));
|
||||||
this.$('.js-drop-zone').on('uploadstart', this.uploadMgr.handleDownloadStart);
|
this.$('.js-drop-zone').on('uploadstart', this.uploadMgr.handleDownloadStart);
|
||||||
this.$('.js-drop-zone').on('uploadfailure', $.proxy(this.enableEditor, this));
|
this.$('.js-drop-zone').on('uploadfailure', $.proxy(this.enableEditor, this));
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
this.showUpload('cover', settings.cover);
|
this.showUpload('cover', settings.cover);
|
||||||
},
|
},
|
||||||
showUpload: function (key, src) {
|
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
|
func: function () { // The function called on acceptance
|
||||||
var data = {};
|
var data = {};
|
||||||
if (this.$('#uploadurl').val()) {
|
if (this.$('#uploadurl').val()) {
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
this.showUpload('image', user.image);
|
this.showUpload('image', user.image);
|
||||||
},
|
},
|
||||||
showUpload: function (key, src) {
|
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
|
func: function () { // The function called on acceptance
|
||||||
var data = {};
|
var data = {};
|
||||||
if (this.$('#uploadurl').val()) {
|
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) {
|
ghost.registerThemeHelper('body_class', function (options) {
|
||||||
var classes = [];
|
var classes = [];
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
Markdown
|
Markdown
|
||||||
<a class="markdown-help" href="#"><span class="hidden">What is Markdown?</span></a>
|
<a class="markdown-help" href="#"><span class="hidden">What is Markdown?</span></a>
|
||||||
</header>
|
</header>
|
||||||
<section class="entry-markdown-content">
|
<section id="entry-markdown-content" class="entry-markdown-content" data-filestorage={{fileStorage}}>
|
||||||
<textarea id="entry-markdown"></textarea>
|
<textarea id="entry-markdown"></textarea>
|
||||||
</section>
|
</section>
|
||||||
</section>{{!.entry-markdown}}
|
</section>{{!.entry-markdown}}
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<section class="settings-content"></section>
|
<section class="settings-content" data-filestorage={{fileStorage}}></section>
|
||||||
</div>
|
</div>
|
Loading…
Add table
Reference in a new issue