moving handlebars compile target, adding notification when saving post, using Ghost.View rather than modifying Backbone.View's prototype
This commit is contained in:
parent
524462e164
commit
c4f6c99ca1
2
.gitignore
vendored
2
.gitignore
vendored
@ -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/
|
||||
|
@ -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"
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}());
|
@ -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,
|
||||
|
||||
|
@ -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 () {
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
<script src="/core/admin/assets/lib/countable.js"></script>
|
||||
|
||||
<script src="/core/admin/assets/js/init.js"></script>
|
||||
<script src="/core/admin/assets/js/hbs-tmpl.js"></script>
|
||||
<script src="/core/admin/assets/tmpl/hbs-tmpl.js"></script>
|
||||
<script src="/core/admin/assets/js/toggle.js"></script>
|
||||
<script src="/core/admin/assets/js/admin-ui-temp.js"></script>
|
||||
<script src="/core/admin/assets/js/markdown-actions.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user