0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Add setting filter

closes #172
- added type to ghost.settings()
- added /api/settings?type=<filter>
- added availableThemes to settingsCache
- removed cachedSettingsRequestHandler
- removed /api/themes (including front end)
- changed activePlugins to type "plugin" in default-settings.json
This commit is contained in:
Sebastian Gierlinger 2013-09-15 18:03:31 +02:00
parent 27a78c82e4
commit d7bafd4b2a
3 changed files with 6 additions and 28 deletions

View file

@ -3,7 +3,7 @@
"use strict";
//id:0 is used to issue PUT requests
Ghost.Models.Settings = Backbone.Model.extend({
url: Ghost.settings.apiRoot + '/settings',
url: Ghost.settings.apiRoot + '/settings?type=blog,theme',
id: "0"
});

View file

@ -1,9 +0,0 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
Ghost.Models.Themes = Backbone.Model.extend({
url: Ghost.settings.apiRoot + '/themes'
});
}());

View file

@ -57,8 +57,7 @@
showContent: function (id) {
var self = this,
model,
themes;
model;
Ghost.router.navigate('/settings/' + id);
Ghost.trigger('urlchange');
@ -70,13 +69,9 @@
this.pane = new Settings[id]({ el: '.settings-content'});
if (!this.models.hasOwnProperty(this.pane.options.modelType)) {
themes = this.models.Themes = new Ghost.Models.Themes();
model = this.models[this.pane.options.modelType] = new Ghost.Models[this.pane.options.modelType]();
themes.fetch().then(function () {
model.fetch().then(function () {
model.set({availableThemes: themes.toJSON()});
self.renderPane(model);
});
model.fetch().then(function () {
self.renderPane(model);
});
} else {
model = this.models[this.pane.options.modelType];
@ -157,8 +152,7 @@
},
saveSettings: function () {
var themes = this.model.get('availableThemes'),
title = this.$('#blog-title').val(),
var title = this.$('#blog-title').val(),
description = this.$('#blog-description').val(),
email = this.$('#email-address').val(),
postsPerPage = this.$('#postsPerPage').val();
@ -180,8 +174,6 @@
if (Ghost.Validate._errors.length > 0) {
Ghost.Validate.handleErrors();
} else {
this.model.unset('availableThemes');
this.model.save({
title: title,
description: description,
@ -194,7 +186,6 @@
success: this.saveSuccess,
error: this.saveError
});
this.model.set({availableThemes: themes});
}
},
showLogo: function () {
@ -208,16 +199,12 @@
showUpload: function (id, key, src) {
var self = this, upload = new Ghost.Models.uploadModal({'id': id, 'key': key, 'src': src, 'accept': {
func: function () { // The function called on acceptance
var data = {},
themes;
var data = {};
data[key] = this.$('.js-upload-target').attr('src');
themes = self.model.get('availableThemes');
self.model.unset('availableThemes');
self.model.save(data, {
success: self.saveSuccess,
error: self.saveError
});
self.model.set({availableThemes: themes});
self.render();
return true;
},