2013-10-08 19:39:07 +04:00
|
|
|
/*global window, document, Ghost, Backbone, $, _, NProgress */
|
2013-06-02 03:45:02 +04:00
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Ghost.Router = Backbone.Router.extend({
|
|
|
|
|
|
|
|
routes: {
|
2013-09-11 18:38:09 +04:00
|
|
|
'' : 'blog',
|
2013-06-08 09:05:40 +04:00
|
|
|
'content/' : 'blog',
|
2013-09-15 15:13:06 +04:00
|
|
|
'settings(/:pane)/' : 'settings',
|
|
|
|
'editor(/:id)/' : 'editor',
|
2013-08-01 05:11:45 +04:00
|
|
|
'debug/' : 'debug',
|
|
|
|
'register/' : 'register',
|
|
|
|
'signup/' : 'signup',
|
2013-09-01 02:20:12 +04:00
|
|
|
'signin/' : 'login',
|
|
|
|
'forgotten/' : 'forgotten'
|
2013-08-01 05:11:45 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
signup: function () {
|
2013-09-12 12:59:58 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Signup({ el: '.js-signup-box' });
|
2013-08-01 05:11:45 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
login: function () {
|
2013-09-08 19:12:25 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Login({ el: '.js-login-box' });
|
2013-09-01 02:20:12 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
forgotten: function () {
|
2013-09-12 12:59:58 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Forgotten({ el: '.js-forgotten-box' });
|
2013-06-02 03:45:02 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
blog: function () {
|
|
|
|
var posts = new Ghost.Collections.Posts();
|
2013-10-08 19:39:07 +04:00
|
|
|
NProgress.start();
|
2013-10-17 09:21:56 +04:00
|
|
|
posts.fetch({ data: { status: 'all', orderBy: ['updated_at', 'DESC'], where: { page: 'all' } } }).then(function () {
|
2013-06-02 03:45:02 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
|
2013-10-08 19:39:07 +04:00
|
|
|
NProgress.done();
|
2013-06-02 03:45:02 +04:00
|
|
|
});
|
2013-06-08 09:05:40 +04:00
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-08 09:05:40 +04:00
|
|
|
settings: function (pane) {
|
2013-09-02 07:54:19 +04:00
|
|
|
if (!pane) {
|
|
|
|
// Redirect to settings/general if no pane supplied
|
2013-09-15 15:13:06 +04:00
|
|
|
this.navigate('/settings/general/', {
|
2013-09-02 07:54:19 +04:00
|
|
|
trigger: true,
|
|
|
|
replace: true
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-21 14:50:49 +04:00
|
|
|
// only update the currentView if we don't already have a Settings view
|
|
|
|
if (!Ghost.currentView || !(Ghost.currentView instanceof Ghost.Views.Settings)) {
|
|
|
|
Ghost.currentView = new Ghost.Views.Settings({ el: '#main', pane: pane });
|
|
|
|
}
|
2013-06-02 03:45:02 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
editor: function (id) {
|
|
|
|
var post = new Ghost.Models.Post();
|
|
|
|
post.urlRoot = Ghost.settings.apiRoot + '/posts';
|
|
|
|
if (id) {
|
|
|
|
post.id = id;
|
2013-10-18 21:18:49 +04:00
|
|
|
post.fetch({ data: {status: 'all'}}).then(function () {
|
2013-06-02 03:45:02 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
|
|
|
}
|
2013-06-10 00:41:07 +04:00
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-24 00:55:03 +04:00
|
|
|
debug: function () {
|
|
|
|
Ghost.currentView = new Ghost.Views.Debug({ el: "#main" });
|
2013-06-02 03:45:02 +04:00
|
|
|
}
|
|
|
|
});
|
2013-08-01 05:11:45 +04:00
|
|
|
}());
|