diff --git a/.gitignore b/.gitignore
index 6345c420b4..ab8e681a28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,7 +23,7 @@ projectFilesBackup
# Ghost DB file
*.db
-/core/admin/assets/js/hbs-tmpl.js
+/core/admin/assets/tmpl/hbs-tmpl.js
/core/admin/assets/css
/core/admin/assets/sass/modules/bourbon
.sass-cache/
diff --git a/Gruntfile.js b/Gruntfile.js
index 331c628156..436ce3607a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -17,7 +17,7 @@
// Lint files in the root, including Gruntfile.js
"*.js",
// Lint core files, but not libs
- ["core/**/*.js", "!**/assets/lib/**/*.js", "!**/assets/**/hbs-tmpl.js"]
+ ["core/**/*.js", "!**/assets/lib/**/*.js"]
]
},
@@ -66,7 +66,7 @@
},
files: {
- "./core/admin/assets/js/hbs-tmpl.js": "./core/admin/assets/tmpl/**/*.hbs"
+ "./core/admin/assets/tmpl/hbs-tmpl.js": "./core/admin/assets/tmpl/**/*.hbs"
}
}
diff --git a/core/admin/assets/js/init.js b/core/admin/assets/js/init.js
index a70e81512d..8f302daa82 100644
--- a/core/admin/assets/js/init.js
+++ b/core/admin/assets/js/init.js
@@ -1,8 +1,27 @@
/*globals window, _, $, Backbone */
(function ($) {
+
"use strict";
- _.extend(Backbone.View.prototype, {
+ var Ghost = {
+ Layout : {},
+ Views : {},
+ Collections : {},
+ Models : {},
+
+ settings: {
+ apiRoot: '/api/v0.1'
+ },
+
+ // This is a helper object to denote legacy things in the
+ // middle of being transitioned.
+ temporary: {},
+
+ currentView: null,
+ router: null
+ };
+
+ Ghost.View = Backbone.View.extend({
// Adds a subview to the current view, which will
// ensure its removal when this view is removed,
@@ -42,24 +61,6 @@
});
- var Ghost = {
- Layout : {},
- Views : {},
- Collections : {},
- Models : {},
-
- settings: {
- apiRoot: '/api/v0.1'
- },
-
- // This is a helper object to denote legacy things in the
- // middle of being transitioned.
- temporary: {},
-
- currentView: null,
- router: null
- };
-
window.Ghost = Ghost;
}());
\ No newline at end of file
diff --git a/core/admin/assets/js/views/blog.js b/core/admin/assets/js/views/blog.js
index 119aa43ec6..bd159ee929 100644
--- a/core/admin/assets/js/views/blog.js
+++ b/core/admin/assets/js/views/blog.js
@@ -17,7 +17,7 @@
// Base view
// ----------
- Ghost.Views.Blog = Backbone.View.extend({
+ Ghost.Views.Blog = Ghost.View.extend({
initialize: function (options) {
this.addSubview(new PreviewContainer({ el: '.js-content-preview', collection: this.collection })).render();
this.addSubview(new ContentList({ el: '.js-content-list', collection: this.collection })).render();
@@ -27,7 +27,7 @@
// Content list (sidebar)
// -----------------------
- ContentList = Backbone.View.extend({
+ ContentList = Ghost.View.extend({
events: {
'click .content-list-content' : 'scrollHandler'
@@ -56,7 +56,7 @@
// Content Item
// -----------------------
- ContentItem = Backbone.View.extend({
+ ContentItem = Ghost.View.extend({
tagName: 'li',
@@ -120,7 +120,7 @@
// Content preview
// ----------------
- PreviewContainer = Backbone.View.extend({
+ PreviewContainer = Ghost.View.extend({
activeId: null,
diff --git a/core/admin/assets/js/views/editor.js b/core/admin/assets/js/views/editor.js
index 885f707588..1e98727821 100644
--- a/core/admin/assets/js/views/editor.js
+++ b/core/admin/assets/js/views/editor.js
@@ -29,7 +29,7 @@
// The publish bar associated with a post, which has the TagWidget and
// Save button and options and such.
// ----------------------------------------
- PublishBar = Backbone.View.extend({
+ PublishBar = Ghost.View.extend({
initialize: function () {
this.addSubview(new TagWidget({el: this.$('#entry-categories'), model: this.model})).render();
@@ -40,13 +40,13 @@
// The Tag UI area associated with a post
// ----------------------------------------
- TagWidget = Backbone.View.extend({
+ TagWidget = Ghost.View.extend({
});
// The Publish, Queue, Publish Now buttons
// ----------------------------------------
- ActionsWidget = Backbone.View.extend({
+ ActionsWidget = Ghost.View.extend({
events: {
'click [data-set-status]': 'handleStatus',
@@ -87,15 +87,27 @@
updatePost: function (e) {
e.preventDefault();
- this.savePost();
+ var model = this.model;
+ this.savePost().then(function () {
+ alert('Your post was saved as ' + model.get('status'));
+ }, function () {
+ alert(model.validationError);
+ });
},
savePost: function (data) {
// TODO: The content getter here isn't great, shouldn't rely on currentView.
- return this.model.save(_.extend({
+ var saved = this.model.save(_.extend({
title: $('#entry-title').val(),
content: Ghost.currentView.editor.getValue()
}, data));
+
+ // TODO: Take this out if #2489 gets merged in Backbone. Or patch Backbone
+ // ourselves for more consistent promises.
+ if (saved) {
+ return saved;
+ }
+ return $.Deferred().reject();
},
render: function () {
@@ -106,7 +118,7 @@
// The entire /editor page's route (TODO: move all views to client side templates)
// ----------------------------------------
- Ghost.Views.Editor = Backbone.View.extend({
+ Ghost.Views.Editor = Ghost.View.extend({
initialize: function () {
diff --git a/core/admin/views/default.hbs b/core/admin/views/default.hbs
index 98abf5a581..dce72828b2 100644
--- a/core/admin/views/default.hbs
+++ b/core/admin/views/default.hbs
@@ -47,7 +47,7 @@
-
+