Skip to content

Commit

Permalink
Merge pull request #5340 from jaswilli/ember-routing
Browse files Browse the repository at this point in the history
Clean up Ember router map
  • Loading branch information
novaugust committed May 27, 2015
2 parents 45feb20 + 5018f2f commit 78041cd
Show file tree
Hide file tree
Showing 26 changed files with 126 additions and 303 deletions.
32 changes: 0 additions & 32 deletions core/client/app/controllers/settings.js

This file was deleted.

27 changes: 9 additions & 18 deletions core/client/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,23 @@ Router.map(function () {
this.route('reset', {path: '/reset/:token'});
this.route('about', {path: '/about'});

this.resource('posts', {path: '/'}, function () {
this.route('posts', {path: '/'}, function () {
this.route('post', {path: ':post_id'});
});

this.resource('editor', function () {
this.route('editor', function () {
this.route('new', {path: ''});
this.route('edit', {path: ':post_id'});
});

this.resource('settings', function () {
this.route('general');

this.resource('settings.users', {path: '/users'}, function () {
this.route('user', {path: '/:slug'});
});

// Redirect about page
this.route('about');
this.route('tags');
this.route('labs');
this.route('code-injection');
this.route('navigation');
this.route('settings.general', {path: '/settings/general'});
this.route('settings.users', {path: '/settings/users'}, function () {
this.route('user', {path: ':slug'});
});

// Redirect debug to settings labs
this.route('debug');
this.route('settings.tags', {path: '/settings/tags'});
this.route('settings.labs', {path: '/settings/labs'});
this.route('settings.code-injection', {path: '/settings/code-injection'});
this.route('settings.navigation', {path: '/settings/navigation'});

// Redirect legacy content to posts
this.route('content');
Expand Down
12 changes: 5 additions & 7 deletions core/client/app/routes/about.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';

var AboutRoute = AuthenticatedRoute.extend(styleBody, {
export default AuthenticatedRoute.extend(styleBody, {
titleToken: 'About',

classNames: ['view-about'],

cachedConfig: false,

model: function () {
var cachedConfig = this.get('cachedConfig'),
self = this;

if (cachedConfig) {
return cachedConfig;
}

return ic.ajax.request(this.get('ghostPaths.url').api('configuration'))
.then(function (configurationResponse) {
var configKeyValues = configurationResponse.configuration;

cachedConfig = {};
configKeyValues.forEach(function (configKeyValue) {
cachedConfig[configKeyValue.key] = configKeyValue.value;
});
self.set('cachedConfig', cachedConfig);

return cachedConfig;
});
},

renderTemplate: function () {
this.render('about', {into: 'application'});
}
});

export default AboutRoute;
10 changes: 0 additions & 10 deletions core/client/app/routes/settings.js

This file was deleted.

10 changes: 0 additions & 10 deletions core/client/app/routes/settings/about.js

This file was deleted.

4 changes: 0 additions & 4 deletions core/client/app/routes/settings/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ var AppsRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {

model: function () {
return this.store.find('app');
},

renderTemplate: function () {
this.render('settings/apps', {into: 'application'});
}
});

Expand Down
9 changes: 2 additions & 7 deletions core/client/app/routes/settings/code-injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';

var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - Code Injection',
classNames: ['settings-view-code'],

beforeModel: function () {
Expand All @@ -17,15 +18,9 @@ var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, CurrentUse
});
},

renderTemplate: function () {
this.render('settings/code-injection', {into: 'application'});
},

actions: {
save: function () {
this.get('controller').send('save');
}
}
});

export default SettingsCodeInjectionRoute;
10 changes: 2 additions & 8 deletions core/client/app/routes/settings/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';

var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'General',
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - General',

classNames: ['settings-view-general'],

Expand All @@ -19,15 +19,9 @@ var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSetti
});
},

renderTemplate: function () {
this.render('settings/general', {into: 'application'});
},

actions: {
save: function () {
this.get('controller').send('save');
}
}
});

export default SettingsGeneralRoute;
29 changes: 0 additions & 29 deletions core/client/app/routes/settings/index.js

This file was deleted.

11 changes: 3 additions & 8 deletions core/client/app/routes/settings/labs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';

var LabsRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Labs',
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - Labs',

classNames: ['settings'],

beforeModel: function () {
return this.get('session.user')
.then(this.transitionAuthor())
Expand All @@ -16,11 +17,5 @@ var LabsRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
return this.store.find('setting', {type: 'blog,theme'}).then(function (records) {
return records.get('firstObject');
});
},

renderTemplate: function () {
this.render('settings/labs', {into: 'application'});
}
});

export default LabsRoute;
7 changes: 1 addition & 6 deletions core/client/app/routes/settings/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';

var NavigationRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {

titleToken: 'Navigation',
titleToken: 'Settings - Navigation',

classNames: ['settings-view-navigation'],

Expand All @@ -19,10 +18,6 @@ var NavigationRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings,
});
},

renderTemplate: function () {
this.render('settings/navigation', {into: 'application'});
},

actions: {
save: function () {
// since shortcuts are run on the route, we have to signal to the components
Expand Down
15 changes: 7 additions & 8 deletions core/client/app/routes/settings/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ paginationSettings = {
};

TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin, {
actions: {
willTransition: function () {
this.send('closeSettingsMenu');
}
},

titleToken: 'Tags',
titleToken: 'Settings - Tags',

beforeModel: function () {
return this.get('session.user')
Expand All @@ -40,7 +34,6 @@ TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin,

renderTemplate: function (controller, model) {
this._super(controller, model);
this.render('settings/tags', {into: 'application'});
this.render('settings/tags/settings-menu', {
into: 'application',
outlet: 'settings-menu',
Expand All @@ -50,6 +43,12 @@ TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin,

deactivate: function () {
this.controller.send('resetPagination');
},

actions: {
willTransition: function () {
this.send('closeSettingsMenu');
}
}
});

Expand Down
6 changes: 1 addition & 5 deletions core/client/app/routes/settings/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ paginationSettings = {
};

UsersIndexRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, PaginationRouteMixin, {
titleToken: 'Users',
titleToken: 'Team',

classNames: ['settings-view-users'],

Expand Down Expand Up @@ -47,10 +47,6 @@ UsersIndexRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, Pagi
});
},

renderTemplate: function () {
this.render('settings/users/index', {into: 'application'});
},

actions: {
reload: function () {
this.refresh();
Expand Down
6 changes: 1 addition & 5 deletions core/client/app/routes/settings/users/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';

var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'User',
titleToken: 'Team - User',

classNames: ['settings-view-user'],

Expand Down Expand Up @@ -49,10 +49,6 @@ var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings
this._super();
},

renderTemplate: function () {
this.render('settings/users/user', {into: 'application'});
},

actions: {
save: function () {
this.get('controller').send('save');
Expand Down
Loading

0 comments on commit 78041cd

Please sign in to comment.