From 1d389046368cc1eb94c0e8230afdc27cac0e150b Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Mon, 25 May 2015 13:17:10 -0500 Subject: [PATCH] Clean up Ember router map No Issue - Switch resources to routes. - No longer nest "settings" routes so the router reflects the way the templates are rendered. - Remove renderTemplate override from settings routes. - Remove unneeded routes, controllers, and views. - Adjust users page so that infinite scroll loading of users works and markup remains the same for Zelda styling. --- app/controllers/settings.js | 32 ------- app/router.js | 27 ++---- app/routes/about.js | 12 ++- app/routes/settings.js | 10 --- app/routes/settings/about.js | 10 --- app/routes/settings/apps.js | 4 - app/routes/settings/code-injection.js | 9 +- app/routes/settings/general.js | 10 +-- app/routes/settings/index.js | 29 ------- app/routes/settings/labs.js | 11 +-- app/routes/settings/navigation.js | 7 +- app/routes/settings/tags.js | 15 ++-- app/routes/settings/users/index.js | 6 +- app/routes/settings/users/user.js | 6 +- app/templates/about.hbs | 68 +++++++-------- app/templates/components/gh-nav-menu.hbs | 2 +- app/templates/settings/users/index.hbs | 94 ++++++++++----------- app/views/about.js | 5 -- app/views/settings.js | 20 ----- app/views/settings/index.js | 5 -- app/views/settings/users/users-list-view.js | 8 -- app/views/users-list.js | 7 ++ bower.json | 1 - 23 files changed, 118 insertions(+), 280 deletions(-) delete mode 100644 app/controllers/settings.js delete mode 100644 app/routes/settings.js delete mode 100644 app/routes/settings/about.js delete mode 100644 app/routes/settings/index.js delete mode 100644 app/views/about.js delete mode 100644 app/views/settings.js delete mode 100644 app/views/settings/index.js delete mode 100644 app/views/settings/users/users-list-view.js create mode 100644 app/views/users-list.js diff --git a/app/controllers/settings.js b/app/controllers/settings.js deleted file mode 100644 index 27346eef9..000000000 --- a/app/controllers/settings.js +++ /dev/null @@ -1,32 +0,0 @@ -import Ember from 'ember'; -var SettingsController = Ember.Controller.extend({ - - needs: ['feature'], - - showGeneral: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true; - }), - showUsers: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') ? false : true; - }), - showTags: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') ? false : true; - }), - showNavigation: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true; - }), - showCodeInjection: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true; - }), - showLabs: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true; - }), - showAbout: Ember.computed('session.user.name', function () { - return this.get('session.user.isAuthor') ? false : true; - }), - showPassProtection: Ember.computed('session.user.name', 'controllers.feature.passProtectUI', function () { - return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('controllers.feature.passProtectUI') ? false : true; - }) -}); - -export default SettingsController; diff --git a/app/router.js b/app/router.js index 615df78d4..bc4421740 100644 --- a/app/router.js +++ b/app/router.js @@ -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'); diff --git a/app/routes/about.js b/app/routes/about.js index 8263b55cb..6d5832795 100644 --- a/app/routes/about.js +++ b/app/routes/about.js @@ -1,15 +1,17 @@ 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; } @@ -17,18 +19,14 @@ var AboutRoute = AuthenticatedRoute.extend(styleBody, { 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; diff --git a/app/routes/settings.js b/app/routes/settings.js deleted file mode 100644 index fb8722875..000000000 --- a/app/routes/settings.js +++ /dev/null @@ -1,10 +0,0 @@ -import AuthenticatedRoute from 'ghost/routes/authenticated'; -import styleBody from 'ghost/mixins/style-body'; - -var SettingsRoute = AuthenticatedRoute.extend(styleBody, { - titleToken: 'Settings', - - classNames: ['settings'] -}); - -export default SettingsRoute; diff --git a/app/routes/settings/about.js b/app/routes/settings/about.js deleted file mode 100644 index 26ffe22e5..000000000 --- a/app/routes/settings/about.js +++ /dev/null @@ -1,10 +0,0 @@ -import AuthenticatedRoute from 'ghost/routes/authenticated'; -import styleBody from 'ghost/mixins/style-body'; - -var SettingsAboutRoute = AuthenticatedRoute.extend(styleBody, { - beforeModel: function () { - this.transitionTo('about'); - } -}); - -export default SettingsAboutRoute; diff --git a/app/routes/settings/apps.js b/app/routes/settings/apps.js index 842bee04f..143a64b1e 100644 --- a/app/routes/settings/apps.js +++ b/app/routes/settings/apps.js @@ -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'}); } }); diff --git a/app/routes/settings/code-injection.js b/app/routes/settings/code-injection.js index 4a2b69e55..49b1360c4 100644 --- a/app/routes/settings/code-injection.js +++ b/app/routes/settings/code-injection.js @@ -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 () { @@ -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; diff --git a/app/routes/settings/general.js b/app/routes/settings/general.js index 47b7a4392..8d78d9615 100644 --- a/app/routes/settings/general.js +++ b/app/routes/settings/general.js @@ -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'], @@ -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; diff --git a/app/routes/settings/index.js b/app/routes/settings/index.js deleted file mode 100644 index 73fc43083..000000000 --- a/app/routes/settings/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'; -import MobileIndexRoute from 'ghost/routes/mobile-index-route'; -import CurrentUserSettings from 'ghost/mixins/current-user-settings'; -import mobileQuery from 'ghost/utils/mobile'; - -var SettingsIndexRoute = MobileIndexRoute.extend(AuthenticatedRouteMixin, CurrentUserSettings, { - titleToken: 'Settings', - - // Redirect users without permission to view settings, - // and show the settings.general route unless the user - // is mobile - beforeModel: function () { - var self = this; - return this.get('session.user') - .then(this.transitionAuthor()) - .then(this.transitionEditor()) - .then(function () { - if (!mobileQuery.matches) { - self.transitionTo('settings.general'); - } - }); - }, - - desktopTransition: function () { - this.transitionTo('settings.general'); - } -}); - -export default SettingsIndexRoute; diff --git a/app/routes/settings/labs.js b/app/routes/settings/labs.js index dbf8a77f8..8e98b670e 100644 --- a/app/routes/settings/labs.js +++ b/app/routes/settings/labs.js @@ -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()) @@ -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; diff --git a/app/routes/settings/navigation.js b/app/routes/settings/navigation.js index f4fe79e30..4ec275648 100644 --- a/app/routes/settings/navigation.js +++ b/app/routes/settings/navigation.js @@ -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'], @@ -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 diff --git a/app/routes/settings/tags.js b/app/routes/settings/tags.js index e19be9aa2..698e8d6d1 100644 --- a/app/routes/settings/tags.js +++ b/app/routes/settings/tags.js @@ -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') @@ -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', @@ -50,6 +43,12 @@ TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin, deactivate: function () { this.controller.send('resetPagination'); + }, + + actions: { + willTransition: function () { + this.send('closeSettingsMenu'); + } } }); diff --git a/app/routes/settings/users/index.js b/app/routes/settings/users/index.js index 738d9056e..12321b36b 100644 --- a/app/routes/settings/users/index.js +++ b/app/routes/settings/users/index.js @@ -13,7 +13,7 @@ paginationSettings = { }; UsersIndexRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, PaginationRouteMixin, { - titleToken: 'Users', + titleToken: 'Team', classNames: ['settings-view-users'], @@ -47,10 +47,6 @@ UsersIndexRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, Pagi }); }, - renderTemplate: function () { - this.render('settings/users/index', {into: 'application'}); - }, - actions: { reload: function () { this.refresh(); diff --git a/app/routes/settings/users/user.js b/app/routes/settings/users/user.js index 4dbca6b70..72c2cd2ec 100644 --- a/app/routes/settings/users/user.js +++ b/app/routes/settings/users/user.js @@ -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'], @@ -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'); diff --git a/app/templates/about.hbs b/app/templates/about.hbs index cc3e9814c..8d20c9385 100644 --- a/app/templates/about.hbs +++ b/app/templates/about.hbs @@ -1,41 +1,41 @@ -
+
+
+
+ + + {{gh-notifications location="about-upgrade" notify="updateNotificationChange"}} +
-
- - - {{gh-notifications location="about-upgrade" notify="updateNotificationChange"}} -
- -
-
    -
  • Version {{model.version}}
  • -
  • Environment {{model.environment}}
  • -
  • Database {{model.database}}
  • -
  • Mail {{#if model.mail}}{{model.mail}}{{else}}Native{{/if}}
  • -
- -
- -
-

The People Who Made it Possible

- -
- {{partial "contributors"}} +
+
    +
  • Version {{model.version}}
  • +
  • Environment {{model.environment}}
  • +
  • Database {{model.database}}
  • +
  • Mail {{#if model.mail}}{{model.mail}}{{else}}Native{{/if}}
  • +
+
-

Ghost is built by an incredible group of contributors from all over the world. Here are just a few of the people who helped create the version you’re using right now.

+
+

The People Who Made it Possible

- Find out how you can get involved +
+ {{partial "contributors"}} +
+

Ghost is built by an incredible group of contributors from all over the world. Here are just a few of the people who helped create the version you’re using right now.

+ + Find out how you can get involved + +
+ +
- - -
diff --git a/app/templates/components/gh-nav-menu.hbs b/app/templates/components/gh-nav-menu.hbs index 25e47d8c1..e84b393cc 100644 --- a/app/templates/components/gh-nav-menu.hbs +++ b/app/templates/components/gh-nav-menu.hbs @@ -8,7 +8,7 @@ {{/gh-dropdown-button}} {{#gh-dropdown tagName="div" classNames="dropdown" name="user-menu" closeOnClick="true"}}
-
+ {{#view "users-list"}} + {{#if invitedUsers}} +
- {{#if invitedUsers}} +

Invited users

-
+ {{#each user in invitedUsers itemController="settings/users/user"}} +
+ ic -

Invited users

+
+ {{user.email}}
+ {{#if user.model.pending}} + Invitation not sent - please try again + {{else}} + Invitation sent: {{user.model.created_at}} + {{/if}} +
+ +
+ {{/each}} - {{#each user in invitedUsers itemController="settings/users/user"}} -
- ic +
+ {{/if}} + +
+ +

Active users

+ + {{#each user in activeUsers itemController="settings/users/user"}} + {{#link-to 'settings.users.user' user.model class="user-list-item" }} + + +
- {{user.email}}
- {{#if user.model.pending}} - Invitation not sent - please try again - {{else}} - Invitation sent: {{user.model.created_at}} - {{/if}} + + {{user.model.name}} + +
+ Last seen: {{user.last_login}}
- + {{/link-to}} {{/each}}
- - {{/if}} - -
- -

Active users

- - {{#each user in activeUsers itemController="settings/users/user"}} - {{#link-to 'settings.users.user' user.model class="user-list-item" }} - - - - -
- - {{user.model.name}} - -
- Last seen: {{user.last_login}} -
- - {{/link-to}} - {{/each}} - -
- -
{{! .content settings-users }} + {{/view}} diff --git a/app/views/about.js b/app/views/about.js deleted file mode 100644 index ca97178f9..000000000 --- a/app/views/about.js +++ /dev/null @@ -1,5 +0,0 @@ -import BaseView from 'ghost/views/settings/content-base'; - -var AboutView = BaseView.extend(); - -export default AboutView; diff --git a/app/views/settings.js b/app/views/settings.js deleted file mode 100644 index 516ca3adc..000000000 --- a/app/views/settings.js +++ /dev/null @@ -1,20 +0,0 @@ -import MobileParentView from 'ghost/views/mobile/parent-view'; - -var SettingsView = MobileParentView.extend({ - // MobileParentView callbacks - showMenu: function () { - $('.js-settings-header-inner').css('display', 'none'); - $('.js-settings-menu').css({right: '0', left: '0', 'margin-right': '0'}); - $('.js-settings-content').css({right: '-100%', left: '100%', 'margin-left': '15'}); - }, - showContent: function () { - $('.js-settings-menu').css({right: '100%', left: '-110%', 'margin-right': '15px'}); - $('.js-settings-content').css({right: '0', left: '0', 'margin-left': '0'}); - $('.js-settings-header-inner').css('display', 'block'); - }, - showAll: function () { - $('.js-settings-menu, .js-settings-content').removeAttr('style'); - } -}); - -export default SettingsView; diff --git a/app/views/settings/index.js b/app/views/settings/index.js deleted file mode 100644 index 2ffb98081..000000000 --- a/app/views/settings/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import MobileIndexView from 'ghost/views/mobile/index-view'; - -var SettingsIndexView = MobileIndexView.extend(); - -export default SettingsIndexView; diff --git a/app/views/settings/users/users-list-view.js b/app/views/settings/users/users-list-view.js deleted file mode 100644 index 23425e0ea..000000000 --- a/app/views/settings/users/users-list-view.js +++ /dev/null @@ -1,8 +0,0 @@ -import Ember from 'ember'; -import PaginationViewMixin from 'ghost/mixins/pagination-view-infinite-scroll'; - -var UsersListView = Ember.View.extend(PaginationViewMixin, { - classNames: ['js-users-list-view'] -}); - -export default UsersListView; diff --git a/app/views/users-list.js b/app/views/users-list.js new file mode 100644 index 000000000..31596c70c --- /dev/null +++ b/app/views/users-list.js @@ -0,0 +1,7 @@ +import Ember from 'ember'; +import PaginationViewMixin from 'ghost/mixins/pagination-view-infinite-scroll'; + +export default Ember.View.extend(PaginationViewMixin, { + tagName: 'section', + classNames: ['js-users-list-view', 'view-content', 'settings-users'] +}); diff --git a/bower.json b/bower.json index 1ab7884fb..f6ead3719 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,6 @@ "loader.js": "3.2.1", "moment": "2.10.2", "normalize.css": "3.0.3", - "nprogress": "0.1.6", "password-generator": "git://github.com/bermi/password-generator#49accd7", "rangyinputs": "1.2.0", "showdown-ghost": "0.3.6",