Skip to content

Commit 9b6ddf8

Browse files
authored
Merge branch 'master' into #468-encourage-stable-version
2 parents 9a4a67c + b0a7a8d commit 9b6ddf8

File tree

295 files changed

+2002
-1592
lines changed

Some content is hidden

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

295 files changed

+2002
-1592
lines changed

.buildpacks

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
https://github.com/rcaught/heroku-buildpack-cmake#e4e2c9e
2-
https://github.com/emk/heroku-buildpack-rust#035823
2+
https://github.com/mmirate/heroku-buildpack-rust#f1cf6643e
33
https://github.com/tonycoco/heroku-buildpack-ember-cli
44
https://github.com/ryandotsmith/nginx-buildpack.git#af813ba
5+
https://github.com/sgrif/heroku-buildpack-diesel#43267f2

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ install:
1717
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
1818
- yarn
1919
- yarn run bower install
20+
- cargo install diesel_cli --debug --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH
2021

2122
before_script:
22-
- psql -c 'create database cargo_registry_test;' -U postgres
23+
- diesel database setup
2324

2425
script:
2526
- cargo build
@@ -42,6 +43,7 @@ addons:
4243

4344
env:
4445
global:
46+
- DATABASE_URL=postgres://postgres:@localhost/cargo_registry_test
4547
- TEST_DATABASE_URL=postgres://postgres:@localhost/cargo_registry_test
4648
- S3_BUCKET=alexcrichton-test
4749

Cargo.lock

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ rustc-serialize = "0.3"
3636
license-exprs = "^1.3"
3737
dotenv = "0.8.0"
3838
toml = "0.2"
39+
diesel = { version = "0.11.0", features = ["postgres", "serde_json"] }
40+
diesel_codegen = { version = "0.11.0", features = ["postgres"] }
41+
r2d2-diesel = "0.11.0"
42+
diesel_full_text_search = "0.11.0"
3943

4044
conduit = "0.8"
4145
conduit-conditional-get = "0.8"

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
web: ./target/release/migrate && bin/start-nginx ./target/release/server
1+
web: ./target/release/migrate && bin/diesel migration run && bin/start-nginx ./target/release/server
22
worker: ./target/release/update-downloads daemon 300

README.md

Lines changed: 4 additions & 1 deletion

app/routes/crate/version.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default Ember.Route.extend({
1919
};
2020

2121
// Fallback to the crate's last stable version
22-
if (!requestedVersion) {
22+
// If `max_version` is `0.0.0` then all versions have been yanked
23+
if (!requestedVersion && maxVersion !== '0.0.0') {
2324
if (isUnstableVersion(maxVersion)) {
2425
crate.get('versions').then(versions => {
2526
const latestStableVersion = versions.find(version => {
@@ -54,7 +55,7 @@ export default Ember.Route.extend({
5455
return crate.get('versions')
5556
.then(versions => {
5657
const version = versions.find(version => version.get('num') === params.version_num);
57-
if (!version) {
58+
if (params.version_num && !version) {
5859
this.controllerFor('application').set('nextFlashError',
5960
`Version '${params.version_num}' of crate '${crate.get('name')}' does not exist`);
6061
}

app/styles/app.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ body {
6565
}
6666

6767
.sep { margin: 0 10px; color: darken($html-bg, 10%); }
68-
.nav, .menu { @include flex-grow(2); text-align: right; }
68+
.nav, .menu {
69+
@include flex-grow(2);
70+
text-align: right;
71+
margin-right: 5px;
72+
}
6973

7074
.menu { display: none; }
7175
.menu ul.dropdown {
@@ -90,7 +94,7 @@ body {
9094
}
9195
}
9296

93-
#current-user-links {
97+
.current-user-links {
9498
display: none;
9599
left: auto;
96100
right: 0;
@@ -129,6 +133,8 @@ body {
129133
#mobile-search {
130134
display: none;
131135
margin-bottom: 10px;
136+
margin-left: 5px;
137+
margin-right: 5px;
132138
input.search {
133139
width: 100%;
134140
margin: 0;

app/styles/crate.scss

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
.info {
1111
@include display-flex;
12+
@include flex-wrap(wrap);
1213
@include align-items(center);
1314
}
1415
h1 {
@@ -240,13 +241,35 @@
240241
color: white;
241242
padding: 20px;
242243
}
243-
244+
button, button:active {
245+
padding: 5px 0;
246+
background-color: #FFFFFF;
247+
border: none;
248+
width: 60px;
249+
cursor: pointer;
250+
}
251+
button:hover {
252+
background: #edebdd;
253+
}
244254
@media only screen and (min-width: 500px) {
245255
.action { @include flex(2); display: block; }
246256
code { @include flex(8); }
247257
}
248258
}
259+
.copy-result {
260+
text-align: right;
249261

262+
span {
263+
font-size: 80%;
264+
font-weight: bold;
265+
}
266+
.copy-success {
267+
color: $link-color;
268+
}
269+
.copy-failure {
270+
color: red;
271+
}
272+
}
250273
.last-update {
251274
color: $main-color-light;
252275
font-size: 90%;
@@ -316,6 +339,7 @@
316339
h3 { margin-bottom: 5px; }
317340
.section {
318341
@include flex(1);
342+
margin-right: 10px;
319343
li { line-height: 24px; }
320344
.date { color: $main-color-light; padding-left: 5px; }
321345
}

app/templates/application.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<span class='arrow'></span>
6262
{{/rl-dropdown-toggle}}
6363

64-
{{#rl-dropdown tagName="ul" id="current-user-links" class="dropdown" closeOnChildClick="a:link"}}
64+
{{#rl-dropdown tagName="ul" class="dropdown current-user-links" closeOnChildClick="a:link"}}
6565
<li>{{#link-to 'dashboard'}}Dashboard{{/link-to}}</li>
6666
<li>{{#link-to 'me'}}Account Settings{{/link-to}}</li>
6767
<li class='last'>{{#link-to 'logout'}}Sign Out{{/link-to}}</li>
@@ -81,7 +81,7 @@
8181
Menu
8282
<span class='arrow'></span>
8383
{{/rl-dropdown-toggle}}
84-
{{#rl-dropdown tagName='ul' id='current-user-links' class='dropdown' closeOnChildClick='a:link'}}
84+
{{#rl-dropdown tagName='ul' class='dropdown current-user-links' closeOnChildClick='a:link'}}
8585
<li>{{#link-to "crates"}}Browse All Crates{{/link-to}}</li>
8686
{{#if session.currentUser}}
8787
<li>{{#link-to 'dashboard'}}Dashboard{{/link-to}}</li>

app/templates/crate/version.hbs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@
5757
{{/if}}
5858
<div class='install'>
5959
<div class='action'>Cargo.toml</div>
60-
<code>{{ crate.name }} = "{{ currentVersion.num }}"</code>
60+
<code id="crate-toml">{{ crate.name }} = "{{ currentVersion.num }}"</code>
61+
<button id="crate-download-button" data-clipboard-action="copy" data-clipboard-target="#crate-toml">
62+
<img src="/assets/copy.svg" alt="Copy to clipboard" height="25px" />
63+
</button>
64+
</div>
65+
<div class="copy-result">
66+
<span id="copy-notification"></span>
6167
</div>
6268
</div>
6369
<div class='authorship'>
@@ -271,3 +277,40 @@
271277
</div>
272278
</div>
273279
{{/if}}
280+
281+
<script type="text/javascript">
282+
if (!Clipboard.isSupported()) {
283+
document.getElementById('crate-download-button').classList.add('hidden');
284+
}
285+
286+
var clipboard = new Clipboard('#crate-download-button');
287+
var notificationElement = document.getElementById('copy-notification');
288+
289+
clipboard.on('success', function(e) {
290+
var successText = 'Copied !';
291+
292+
e.clearSelection();
293+
notificationElement.classList.add('copy-success')
294+
notificationElement.textContent = successText;
295+
fadeOffElement(notificationElement, 2000);
296+
});
297+
298+
clipboard.on('error', function(e) {
299+
var failureText = 'An error occured. Please use CTRL+C.';
300+
301+
notificationElement.classList.add('copy-failure')
302+
notificationElement.textContent = failureText;
303+
fadeOffElement(notificationElement, 2000);
304+
});
305+
306+
function fadeOffElement(element, delay) {
307+
setTimeout(function() {
308+
resetElement(element);
309+
}, delay);
310+
}
311+
312+
function resetElement(element) {
313+
element.innerHTML = '';
314+
element.className = '';
315+
}
316+
</script>

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"moment": "2.17.1",
99
"moment-timezone": "0.5.11",
1010
"normalize-css": "5.0.0",
11-
"pretender": "1.4.2"
11+
"pretender": "1.4.2",
12+
"clipboard": "1.6.0"
1213
}
1314
}

ember-cli-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ module.exports = function(defaults) {
2222

2323
app.import('bower_components/moment/moment.js');
2424
app.import('bower_components/normalize-css/normalize.css');
25-
25+
app.import('bower_components/clipboard/dist/clipboard.js');
2626
return app.toTree();
2727
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE users;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE users (
2+
id SERIAL PRIMARY KEY,
3+
email VARCHAR NOT NULL UNIQUE,
4+
gh_access_token VARCHAR NOT NULL,
5+
api_token VARCHAR NOT NULL
6+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE packages;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE packages (
2+
id SERIAL PRIMARY KEY,
3+
name VARCHAR NOT NULL UNIQUE,
4+
user_id INTEGER NOT NULL
5+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE versions;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE versions (
2+
id SERIAL PRIMARY KEY,
3+
package_id INTEGER NOT NULL,
4+
num VARCHAR NOT NULL
5+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions DROP CONSTRAINT unique_num;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions ADD CONSTRAINT unique_num UNIQUE (package_id, num);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE version_dependencies;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TABLE version_dependencies (
2+
version_id INTEGER NOT NULL,
3+
depends_on_id INTEGER NOT NULL
4+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages DROP COLUMN updated_at;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages ADD COLUMN updated_at TIMESTAMP NOT NULL DEFAULT now();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages DROP COLUMN created_at;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages ADD COLUMN created_at TIMESTAMP NOT NULL DEFAULT now();

migrations/20140925132250_dumped_migration_8/down.sql

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
UPDATE packages SET updated_at = now() WHERE updated_at IS NULL;
2+
UPDATE packages SET created_at = now() WHERE created_at IS NULL;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions DROP COLUMN updated_at;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions ADD COLUMN updated_at TIMESTAMP NOT NULL DEFAULT now();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions DROP COLUMN created_at;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions ADD COLUMN created_at TIMESTAMP NOT NULL DEFAULT now();

migrations/20140925132253_dumped_migration_11/down.sql

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
UPDATE versions SET updated_at = now() WHERE updated_at IS NULL;
2+
UPDATE versions SET created_at = now() WHERE created_at IS NULL;

migrations/20140925132254_dumped_migration_12/down.sql

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE versions ALTER COLUMN updated_at DROP DEFAULT;
2+
ALTER TABLE versions ALTER COLUMN created_at DROP DEFAULT;
3+
ALTER TABLE packages ALTER COLUMN updated_at DROP DEFAULT;
4+
ALTER TABLE packages ALTER COLUMN created_at DROP DEFAULT;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE metadata;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CREATE TABLE metadata (
2+
total_downloads BIGINT NOT NULL
3+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELETE FROM metadata;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSERT INTO metadata (total_downloads) VALUES (0);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages DROP COLUMN downloads;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages ADD COLUMN downloads INTEGER NOT NULL DEFAULT 0;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions DROP COLUMN downloads;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions ADD COLUMN downloads INTEGER NOT NULL DEFAULT 0;

migrations/20140925161625_dumped_migration_17/down.sql

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE versions ALTER COLUMN downloads DROP DEFAULT;
2+
ALTER TABLE packages ALTER COLUMN downloads DROP DEFAULT;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages DROP COLUMN max_version;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE packages ADD COLUMN max_version VARCHAR;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions ALTER COLUMN downloads DROP NOT NULL;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE versions ALTER COLUMN downloads SET NOT NULL;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE crates RENAME TO packages;
2+
ALTER TABLE versions RENAME COLUMN crate_id TO package_id;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE packages RENAME TO crates;
2+
ALTER TABLE versions RENAME COLUMN package_id TO crate_id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP INDEX index_crate_updated_at;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE INDEX index_crate_updated_at ON crates (updated_at);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP INDEX index_crate_created_at;

0 commit comments

Comments
 (0)