2014-02-27 06:44:09 +04:00
|
|
|
/*global Ghost, Backbone, NProgress */
|
2013-07-11 23:02:18 +04:00
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
Ghost.Router = Backbone.Router.extend({
|
|
|
|
|
|
|
|
routes: {
|
2013-09-11 18:38:09 +04:00
|
|
|
'' : 'blog',
|
2013-07-11 23:02:18 +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',
|
2013-11-22 07:17:38 +04:00
|
|
|
'forgotten/' : 'forgotten',
|
|
|
|
'reset/:token/' : 'reset'
|
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-07-11 23:02:18 +04:00
|
|
|
},
|
|
|
|
|
2013-11-22 07:17:38 +04:00
|
|
|
reset: function (token) {
|
|
|
|
Ghost.currentView = new Ghost.Views.ResetPassword({ el: '.js-reset-box', token: token });
|
|
|
|
},
|
|
|
|
|
2013-07-11 23:02:18 +04:00
|
|
|
blog: function () {
|
|
|
|
var posts = new Ghost.Collections.Posts();
|
2013-10-08 19:39:07 +04:00
|
|
|
NProgress.start();
|
2014-04-27 20:58:34 +04:00
|
|
|
posts.fetch({ data: { status: 'all', staticPages: 'all', include: 'author'} }).then(function () {
|
2013-07-11 23:02:18 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
|
2013-10-08 19:39:07 +04:00
|
|
|
NProgress.done();
|
2013-07-11 23:02:18 +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-07-11 23:02:18 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
editor: function (id) {
|
|
|
|
var post = new Ghost.Models.Post();
|
2013-11-27 06:00:55 +04:00
|
|
|
post.urlRoot = Ghost.paths.apiRoot + '/posts';
|
2013-07-11 23:02:18 +04:00
|
|
|
if (id) {
|
|
|
|
post.id = id;
|
2014-04-27 20:58:34 +04:00
|
|
|
post.fetch({ data: {status: 'all', include: 'tags'}}).then(function () {
|
2013-07-11 23:02:18 +04:00
|
|
|
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
debug: function () {
|
|
|
|
Ghost.currentView = new Ghost.Views.Debug({ el: "#main" });
|
|
|
|
}
|
|
|
|
});
|
2013-08-01 05:11:45 +04:00
|
|
|
}());
|