Skip to content

Commit 9add27e

Browse files
committed
Merge pull request #207 from dirk/dirk/well-known-routes
Well-known routes
2 parents 7374243 + 7118d66 commit 9add27e

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

.env

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Credentials for uploading packages to S3, these can be blank if you're not
2+
# publishing locally.
3+
S3_BUCKET=
4+
S3_ACCESS_KEY=
5+
S3_SECRET_KEY=
6+
# Not needed if the S3 bucket is in US standard
7+
S3_REGION=
8+
9+
# Credentials for talking to github, can be blank if you're not logging in.
10+
#
11+
# When registering a new application, be sure to set the callback url to the
12+
# address `http://localhost:4200/authorize/github`.
13+
GH_CLIENT_ID=
14+
GH_CLIENT_SECRET=
15+
16+
# Key to sign and encrypt cookies with
17+
SESSION_KEY=badkey
18+
19+
# Location of the *postgres* database
20+
# (eg. postgres://postgres:@localhost/cargo_registry)
21+
DATABASE_URL=postgres://postgres:@localhost/cargo_registry
22+
23+
# Remote and local locations of the registry index
24+
GIT_REPO_URL=file://./tmp/index-bare
25+
GIT_REPO_CHECKOUT=./tmp/index-co

app/controllers/crate/docs.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.ObjectController.extend({
4+
});

app/router.js

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Router.map(function() {
1616
this.route('download');
1717
this.route('versions');
1818
this.route('reverse_dependencies');
19+
20+
// Well-known routes
21+
this.route('docs');
1922
});
2023
this.route('me', function() {
2124
this.route('crates');

app/routes/crate/docs.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Ember from 'ember';
2+
import Crate from 'cargo/models/crate';
3+
4+
export default Ember.Route.extend({
5+
setupController: function(controller, data) {
6+
var crate;
7+
8+
if (data instanceof Crate) {
9+
crate = data;
10+
} else {
11+
crate = data.crate;
12+
}
13+
14+
var documentation = crate.get('documentation');
15+
16+
if (documentation) {
17+
window.location = documentation;
18+
} else {
19+
// Redirect to the crate's main page and show a flash error if
20+
// no documentation is found
21+
var message = 'Crate does not supply a documentation URL';
22+
this.controllerFor('application').set('nextFlashError', message);
23+
this.replaceWith('crate', crate);
24+
}
25+
26+
this._super(controller, crate);
27+
},
28+
});

app/templates/crate/docs.hbs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div id="crates-heading">
2+
<img class="logo" src="/assets/circle-with-i.png"/>
3+
<h1>Documentation for <em>{{name}}</em></h1>
4+
</div>
5+
6+
<p>
7+
Redirecting you to <code>{{documentation}}</code>&#8230;
8+
</p>

0 commit comments

Comments
 (0)