Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const Router = Ember.Router.extend({
});

Router.map(function() {
this.route('404');
this.route('project', {path: '/:project'});

this.route('project-version', {path: '/:project/:project_version'}, function() {
// this.route('classes-redirect', {path: '/classes'});

Expand Down
2 changes: 2 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ const { set, inject } = Ember;

export default Ember.Route.extend({
headData: inject.service(),

title(tokens) {
const reversed = Ember.makeArray(tokens).reverse();
const title = `${reversed.join(' - ')} - Ember API Documentation`;
set(this, 'headData.title', title);
set(this, 'headData.cdnDomain', ENV.API_HOST);
return title;
}

});
25 changes: 16 additions & 9 deletions app/routes/project-version/classes/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,27 @@ export default Ember.Route.extend(ScrollTracker, {
find(typeName, param) {
return this.store.find(typeName, param).catch(() => {
return this.store.find('namespace', param).catch(() => {
return this.transitionTo('project-version'); // class doesn't exist in new version
return Ember.RSVP.resolve({ isError: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So fastboot gives back a 500 when you transition during the model hook or afterModel hook, so I need to communicate to the redirect hook that I want to send this to our 404 page.

});
});
},

redirect(model, transition) {
if (model.isError) {
this.transitionTo('404');
}
},

afterModel(klass) {
set(this, 'headData.description', klass.get('ogDescription'));
const relationships = get(klass.constructor, 'relationshipNames');
const promises = Object.keys(relationships).reduce((memo, relationshipType) => {
const relationshipPromises = relationships[relationshipType].map(name => klass.get(name));
return memo.concat(relationshipPromises);
}, []);

return Ember.RSVP.all(promises);
if (!klass.isError) {
set(this, 'headData.description', klass.get('ogDescription'));
const relationships = get(klass.constructor, 'relationshipNames');
const promises = Object.keys(relationships).reduce((memo, relationshipType) => {
const relationshipPromises = relationships[relationshipType].map(name => klass.get(name));
return memo.concat(relationshipPromises);
}, []);
return Ember.RSVP.all(promises);
}
},

serialize(model) {
Expand Down
10 changes: 10 additions & 0 deletions app/templates/404.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<article class="whoops">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same template as error.hbs (without the logic). Open to some design love.

<br><br>
<h2 class="whoops__title">Ack! 404 friend, you're in the wrong place</h2>
<div class="whoops__message">
<p>
This page wasn't found. Please try the {{#link-to 'index'}}API docs page{{/link-to}}.
If you expected something else to be here, please file a <a href="https://github.com/ember-learn/ember-api-docs/issues/new" target="_blank" rel="noopener">ticket</a>.
</p>
</div>
</article>