2013-10-08 10:39:07 -05:00
|
|
|
/*global window, document, Ghost, Backbone, $, _, NProgress */
|
2013-06-01 18:45:02 -05:00
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Ghost.Router = Backbone.Router.extend({
|
|
|
|
|
|
|
|
routes: {
|
2013-09-11 09:38:09 -05:00
|
|
|
'' : 'blog',
|
2013-06-08 00:05:40 -05:00
|
|
|
'content/' : 'blog',
|
2013-09-15 06:13:06 -05:00
|
|
|
'settings(/:pane)/' : 'settings',
|
|
|
|
'editor(/:id)/' : 'editor',
|
2013-07-31 20:11:45 -05:00
|
|
|
'debug/' : 'debug',
|
|
|
|
'register/' : 'register',
|
|
|
|
'signup/' : 'signup',
|
2013-08-31 17:20:12 -05:00
|
|
|
'signin/' : 'login',
|
2013-11-21 22:17:38 -05:00
|
|
|
'forgotten/' : 'forgotten',
|
|
|
|
'reset/:token/' : 'reset'
|
2013-07-31 20:11:45 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
signup: function () {
|
2013-09-12 03:59:58 -05:00
|
|
|
Ghost.currentView = new Ghost.Views.Signup({ el: '.js-signup-box' });
|
2013-07-31 20:11:45 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
login: function () {
|
2013-09-08 10:12:25 -05:00
|
|
|
Ghost.currentView = new Ghost.Views.Login({ el: '.js-login-box' });
|
2013-08-31 17:20:12 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
forgotten: function () {
|
2013-09-12 03:59:58 -05:00
|
|
|
Ghost.currentView = new Ghost.Views.Forgotten({ el: '.js-forgotten-box' });
|
2013-06-01 18:45:02 -05:00
|
|
|
},
|
|
|
|
|
2013-11-21 22:17:38 -05:00
|
|
|
reset: function (token) {
|
|
|
|
Ghost.currentView = new Ghost.Views.ResetPassword({ el: '.js-reset-box', token: token });
|
|
|
|
},
|
|
|
|
|
2013-06-01 18:45:02 -05:00
|
|
|
blog: function () {
|
|
|
|
var posts = new Ghost.Collections.Posts();
|
2013-10-08 10:39:07 -05:00
|
|
|
NProgress.start();
|
2013-12-19 17:51:28 -05:00
|
|
|
posts.fetch({ data: { status: 'all', staticPages: 'all'} }).then(function () {
|
2013-06-01 18:45:02 -05:00
|
|
|
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
|
2013-10-08 10:39:07 -05:00
|
|
|
NProgress.done();
|
2013-06-01 18:45:02 -05:00
|
|
|
});
|
2013-06-08 00:05:40 -05:00
|
|
|
},
|
2013-06-01 18:45:02 -05:00
|
|
|
|
2013-06-08 00:05:40 -05:00
|
|
|
settings: function (pane) {
|
2013-09-01 22:54:19 -05:00
|
|
|
if (!pane) {
|
|
|
|
// Redirect to settings/general if no pane supplied
|
2013-09-15 06:13:06 -05:00
|
|
|
this.navigate('/settings/general/', {
|
2013-09-01 22:54:19 -05:00
|
|
|
trigger: true,
|
|
|
|
replace: true
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-21 05:50:49 -05: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-01 18:45:02 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
editor: function (id) {
|
|
|
|
var post = new Ghost.Models.Post();
|
2013-11-26 21:00:55 -05:00
|
|
|
post.urlRoot = Ghost.paths.apiRoot + '/posts';
|
2013-06-01 18:45:02 -05:00
|
|
|
if (id) {
|
|
|
|
post.id = id;
|
2013-10-18 12:18:49 -05:00
|
|
|
post.fetch({ data: {status: 'all'}}).then(function () {
|
2013-06-01 18:45:02 -05:00
|
|
|
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
|
|
|
}
|
2013-06-09 15:41:07 -05:00
|
|
|
},
|
2013-06-01 18:45:02 -05:00
|
|
|
|
2013-06-23 15:55:03 -05:00
|
|
|
debug: function () {
|
|
|
|
Ghost.currentView = new Ghost.Views.Debug({ el: "#main" });
|
2013-06-01 18:45:02 -05:00
|
|
|
}
|
|
|
|
});
|
2013-07-31 20:11:45 -05:00
|
|
|
}());
|