Skip to content

Commit 3d02252

Browse files
committed
Merge remote-tracking branch 'upstream/master' into moving-avg-download-graph
2 parents 90974ba + a8be938 commit 3d02252

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1924
-1104
lines changed

.jshintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"strict": false,
2929
"white": false,
3030
"eqnull": true,
31-
"esnext": true,
31+
"esversion": 6,
3232
"unused": true
3333
}

README.md

Lines changed: 88 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# crates.io
22

3-
Source code for the default [Cargo](http://doc.crates.io) registry. Viewable
3+
Source code for the default [Cargo](http://doc.crates.io) registry. Viewable
44
online at [crates.io](https://crates.io).
55

66
This project is built on ember-cli and cargo, visit
@@ -17,15 +17,15 @@ yarn
1717
yarn run bower install
1818
```
1919

20-
The website's frontend is built with [Ember.js](http://emberjs.com/). This
20+
The website's frontend is built with [Ember.js](http://emberjs.com/). This
2121
makes it possible to work on the frontend without running a local backend.
2222
To start the frontend run:
2323

2424
```bash
2525
yarn run start:staging
2626
```
2727

28-
This will run a local frontend using the staging backend (hosted on Heroku at
28+
This will run a local frontend using the staging backend (hosted on Heroku at
2929
[staging-crates-io.herokuapp.com](https://staging-crates-io.herokuapp.com)).
3030

3131
If you want to set up a particular situation, you can edit the fixture data used
@@ -55,7 +55,7 @@ yarn run start:live
5555

5656
### Running Tests
5757

58-
Install [phantomjs](http://phantomjs.org/), typically: `npm install
58+
Install [phantomjs](http://phantomjs.org/), typically: `npm install
5959
phantomjs-prebuilt`.
6060

6161
Then run the tests with:
@@ -67,84 +67,112 @@ yarn run ember test --server
6767

6868
## Working on the Backend
6969

70-
After cloning the repo, steps for setting up the backend API server are as
71-
follows:
70+
Working on the backend requires a usable postgres server and to configure
71+
crates.io to use it. There are slight differences in configuration for
72+
hosting the backend and running tests, both of which are described in more
73+
details in the appropriate subsections.
7274

73-
1. Install [Postgres](https://www.postgresql.org/) >= 9.5 and create a
74-
database. For example, if you wanted your database to be named
75-
`cargo_registry`, you can run `psql` to connect to postgres, then run
76-
`CREATE DATABASE cargo_registry;`.
75+
After cloning the repo, do the following:
7776

78-
2. Copy the `.env.sample` file to `.env` and change any applicable values as
79-
directed by the comments in the file. Make sure the values in your new
80-
`.env` are exported in the shell you use for the following commands.
77+
1. Install [Postgres](https://www.postgresql.org/) >= 9.5. On Linux this is
78+
generally available in the distribution repositories as `postgresql` or
79+
`postgresql-server`. This will need to be up and running for running tests
80+
for hosting the site locally.
8181

82-
3. Set up the git index:
82+
2. Copy the `.env.sample` file to `.env`. Some settings will need to be
83+
modified. These instructions are in the subsequent sections.
8384

84-
```
85-
./script/init-local-index.sh
86-
```
85+
### Running Tests
8786

88-
But *do not* modify your `~/.cargo/config` yet. Do that after step 3.
87+
After following the above instructions:
8988

90-
4. Build the server:
89+
1. Configure the location of the test database. Create a database specifically
90+
for testing since running the tests will clear the database. For example,
91+
to use a database named `cargo_registry_test`, create it in postgres by
92+
running `psql` to connect to postgres, then run `CREATE DATABASE
93+
cargo_registry_test;`. The test harness will ensure that migrations are run.
9194

92-
```
93-
cargo build
94-
```
95+
In your `.env` file, specify your test database URL. Here's an example,
96+
assuming your test database is named `cargo_registry_test`:
9597

96-
On OS X 10.11, you will need to install the openssl headers first, and tell
97-
cargo where to find them. See https://github.com/sfackler/rust-openssl#osx.
98+
```
99+
export TEST_DATABASE_URL=postgres://postgres@localhost/cargo_registry_test
100+
```
98101

99-
5. Run the migrations:
102+
2. In your `.env` file, set the s3 bucket to `alexcrichton-test`. No actual
103+
requests to s3 will be made; the requests and responses are recorded in
104+
files in `tests/http-data` and the s3 bucket name needs to match the
105+
requests in the files.
100106

101-
```
102-
./target/debug/migrate
103-
```
107+
```
108+
export S3_BUCKET=alexcrichton-test
109+
```
104110

105-
6. Start the backend server:
111+
3. Run the backend API server tests:
106112

107-
```
108-
./target/debug/server
109-
```
113+
```
114+
cargo test
115+
```
110116

111-
7. **Optionally** start a local frontend:
117+
### Hosting crates.io locally
112118

113-
```
114-
yarn run start:local
115-
```
119+
After following the instructions described in "Working on the Backend":
116120

117-
### Running Tests
121+
1. Make sure your local postgres instance is running and create a database for
122+
use with the local crates.io instance. `cargo_registry` is a good name to
123+
use. You can do this by running `psql` to connect to `postgres` and run:
118124

119-
1. Configure the location of the test database. Create a database other than
120-
your development database, since running the tests will clear out the data.
121-
For example, to use a database named `cargo_registry_test`, create it in
122-
postgres by running `psql` to connect to postgres, then run
123-
`CREATE DATABASE cargo_registry_test;`. The test harness will ensure that
124-
migrations are run.
125+
```
126+
CREATE DATABASE cargo_registry;
127+
```
125128

126-
In your `.env` file, specify your test database URL. Here's an example,
127-
assuming your test database is named `cargo_registry_test`:
129+
2. Modify the `.env` configuration file's `DATABASE_URL` setting to point
130+
to the local postgres instance with the database you want to use. If you've
131+
followed these instructions it should likely look like:
128132

129-
```
130-
export TEST_DATABASE_URL=postgres://postgres@localhost/cargo_registry_test
131-
```
133+
```
134+
export DATABASE_URL=postgres://postgres@localhost/cargo_registry
135+
```
132136

133-
2. In your `.env` file, set the s3 bucket to `alexcrichton-test`. No actual
134-
requests to s3 will be made; the requests and responses are recorded in
135-
files in `tests/http-data` and the s3 bucket name needs to match the
136-
requests in the files.
137+
3. Set up the git index:
137138

138-
```
139-
export S3_BUCKET=alexcrichton-test
140-
```
139+
```
140+
./script/init-local-index.sh
141+
```
141142

142-
3. Run the backend API server tests:
143+
But *do not* modify your `~/.cargo/config` yet (but record the instructions
144+
shown at the end of this step as you'll need them later).
145+
146+
4. Build the server:
147+
148+
```
149+
cargo build
150+
```
151+
152+
On OS X 10.11, you will need to install the openssl headers first, and tell
153+
cargo where to find them. See https://github.com/sfackler/rust-openssl#osx.
154+
155+
5. Modify your `~/.cargo/config` after successfully building crates.io
156+
following the instructions shown at the end of Step 3.
157+
158+
5. Run the migrations:
159+
160+
```
161+
./target/debug/migrate
162+
```
163+
164+
6. Start the backend server:
165+
166+
```
167+
./target/debug/server
168+
```
169+
170+
7. **Optionally** start a local frontend:
171+
172+
```
173+
yarn run start:local
174+
```
143175

144-
```
145-
cargo test
146-
```
147-
148176
## Categories
149177

150178
The list of categories available on crates.io is stored in

app/adapters/dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default ApplicationAdapter.extend({
88
delete query.reverse;
99
var { crate } = query;
1010
delete query.crate;
11-
return this.ajax(`${this.urlPrefix()}/crates/${crate.get('id')}/reverse_dependencies`,
11+
return this.ajax(`/${this.urlPrefix()}/crates/${crate.get('id')}/reverse_dependencies`,
1212
'GET', { data: query });
1313
},
1414
});

app/components/badge-gitlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export default Ember.Component.extend({
88
return this.get('badge.attributes.branch') || 'master';
99
}),
1010
text: Ember.computed('badge', function() {
11-
return `Gitlab build status for the ${ this.get('branch') } branch`;
11+
return `GitLab build status for the ${ this.get('branch') } branch`;
1212
})
1313
});

app/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
ga('send', 'pageview');
1818
</script>
1919

20-
<link rel="stylesheet" href="assets/vendor.css">
21-
<link rel="stylesheet" href="assets/cargo.css">
20+
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
21+
<link rel="stylesheet" href="{{rootURL}}assets/cargo.css">
2222

2323
{{content-for 'head-footer'}}
2424
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
@@ -35,8 +35,8 @@
3535
</div>
3636
</noscript>
3737

38-
<script src="assets/vendor.js"></script>
39-
<script src="assets/cargo.js"></script>
38+
<script src="{{rootURL}}assets/vendor.js"></script>
39+
<script src="{{rootURL}}assets/cargo.js"></script>
4040

4141
{{content-for 'body-footer'}}
4242
</body>

app/mirage/config.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/models/dependency.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default DS.Model.extend({
1515
default_features: DS.attr('boolean'),
1616
features: DS.attr('string'),
1717
kind: DS.attr('string'),
18+
downloads: DS.attr('number'),
1819

1920
featureList: computed('features', function() {
2021
return this.get('features').split(',');

app/routes/crate/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ajax from 'ic-ajax';
44
export default Ember.Route.extend({
55

66
model(params) {
7-
const requestedVersion = params.version_num;
7+
const requestedVersion = params.version_num === 'all' ? '' : params.version_num;
88

99
const crate = this.modelFor('crate');
1010
const controller = this.controllerFor(this.routeName);

app/styles/app.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ body {
138138
}
139139
}
140140

141+
input.search {
142+
box-shadow: none;
143+
}
144+
141145
span.small {
142146
color: $main-color-light;
143147
font-size: 80%;
@@ -226,6 +230,7 @@ pre {
226230
}
227231

228232
button.dropdown, a.dropdown {
233+
color: inherit;
229234
cursor: pointer;
230235
.arrow { font-size: 50%; display: inline-block; vertical-align: middle; }
231236
.arrow::after { content: ""; }

app/styles/crate.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
}
128128
.downloads { @include display-flex; @include align-items(center); }
129129

130+
.rev-dep-downloads {padding-left: 7px}
131+
130132
.quick-links {
131133
ul {
132134
@include display-flex;

app/templates/application.hbs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
<div class='nav'>
2929
{{#link-to "crates" (query-params letter="null" page=1)}}
30-
<button type="button">Browse All Crates</button>
30+
Browse All Crates
3131
{{/link-to}}
3232
<span class="sep">|</span>
3333
{{#rl-dropdown-container class="dropdown-container"}}
@@ -69,10 +69,8 @@
6969
{{/rl-dropdown-container}}
7070
{{else}}
7171
{{#link-to "login"}}
72-
<button type="button">
7372
<img class="lock" src="/assets/lock.png"/>
7473
Log in with GitHub
75-
</button>
7674
{{/link-to}}
7775
{{/if}}
7876
</div>

app/templates/crate/reverse-dependencies.hbs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
</div>
1414
</div>
1515

16-
<div id='crate-all-reverse-dependencies' class='white-rows'>
16+
<div class='white-rows'>
1717
{{#each model as |dependency|}}
18-
<div class='row'>
18+
<div class='crate row'>
1919
<div>
2020
{{#link-to 'crate' dependency.crate_id}}{{dependency.crate_id}}{{/link-to}} requires {{dependency.req}}
2121
</div>
22-
{{#link-to 'crate' dependency.crate_id class='arrow'}}
23-
<img class="right-arrow-all-versions" src="/assets/right-arrow-all-versions.png"/>
24-
{{/link-to}}
22+
<div class='stats downloads'>
23+
<img class='download-clear-back' src="/assets/download-clear-back.png"/>
24+
<span class='num rev-dep-downloads'>{{ format-num dependency.downloads }}</span>
25+
</div>
2526
</div>
2627
{{/each}}
2728
</div>

app/templates/crate/version.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251

252252
{{#rl-dropdown id="all-versions" tagName="ul" class="dropdown" closeOnChildClick="a:link"}}
253253
<li class='all'>
254-
{{#link-to 'crate.version' ''}}All Versions{{/link-to}}
254+
{{#link-to 'crate.version' 'all'}}All Versions{{/link-to}}
255255
</li>
256256
{{#each smallSortedVersions as |version|}}
257257
<li>

0 commit comments

Comments
 (0)