Skip to content

Well-known routes #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 9, 2015
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
25 changes: 25 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Credentials for uploading packages to S3, these can be blank if you're not
# publishing locally.
S3_BUCKET=
S3_ACCESS_KEY=
S3_SECRET_KEY=
# Not needed if the S3 bucket is in US standard
S3_REGION=

# Credentials for talking to github, can be blank if you're not logging in.
#
# When registering a new application, be sure to set the callback url to the
# address `http://localhost:4200/authorize/github`.
GH_CLIENT_ID=
GH_CLIENT_SECRET=

# Key to sign and encrypt cookies with
SESSION_KEY=badkey

# Location of the *postgres* database
# (eg. postgres://postgres:@localhost/cargo_registry)
DATABASE_URL=postgres://postgres:@localhost/cargo_registry

# Remote and local locations of the registry index
GIT_REPO_URL=file://./tmp/index-bare
GIT_REPO_CHECKOUT=./tmp/index-co
4 changes: 4 additions & 0 deletions app/controllers/crate/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Ember from 'ember';

export default Ember.ObjectController.extend({
});
3 changes: 3 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Router.map(function() {
this.route('download');
this.route('versions');
this.route('reverse_dependencies');

// Well-known routes
this.route('docs');
});
this.route('me', function() {
this.route('crates');
Expand Down
28 changes: 28 additions & 0 deletions app/routes/crate/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Ember from 'ember';
import Crate from 'cargo/models/crate';

export default Ember.Route.extend({
setupController: function(controller, data) {
var crate;

if (data instanceof Crate) {
crate = data;
} else {
crate = data.crate;
}

var documentation = crate.get('documentation');

if (documentation) {
window.location = documentation;
} else {
// Redirect to the crate's main page and show a flash error if
// no documentation is found
var message = 'Crate does not supply a documentation URL';
this.controllerFor('application').set('nextFlashError', message);
this.replaceWith('crate', crate);
}

this._super(controller, crate);
},
});
8 changes: 8 additions & 0 deletions app/templates/crate/docs.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="crates-heading">
<img class="logo" src="/assets/circle-with-i.png"/>
<h1>Documentation for <em>{{name}}</em></h1>
</div>

<p>
Redirecting you to <code>{{documentation}}</code>&#8230;
</p>