Skip to content

Commit d8da326

Browse files
Merge with changes from rust-lang#2111
2 parents 17e33af + 9cc23fa commit d8da326

File tree

94 files changed

+3040
-1778
lines changed

Some content is hidden

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

94 files changed

+3040
-1778
lines changed

app/components/flash-message.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<p id="flash" class={{if this.message "shown"}} data-test-flash-message ...attributes>
1+
<p local-class="flash {{if this.message "shown"}}" data-test-flash-message ...attributes>
22
{{this.message}}
33
</p>

app/styles/components/flash-message.scss renamed to app/components/flash-message.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#flash {
1+
.flash {
22
display: none;
33
font-weight: bold;
44
font-size: 110%;

app/components/pagination.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<nav class='pagination' aria-label="Pagination navigation">
2-
<LinkTo @query={{hash page=@prevPage}} class="prev" @rel="prev" @title="previous page" data-test-pagination-prev>
1+
<nav local-class='pagination' aria-label="Pagination navigation">
2+
<LinkTo @query={{hash page=@prevPage}} local-class="prev" @rel="prev" @title="previous page" data-test-pagination-prev>
33
{{svg-jar "left-pag"}}
44
</LinkTo>
55
<ol>
@@ -11,7 +11,7 @@
1111
</li>
1212
{{/each}}
1313
</ol>
14-
<LinkTo @query={{hash page=@nextPage}} class="next" @rel="next" @title="next page" data-test-pagination-next>
14+
<LinkTo @query={{hash page=@nextPage}} local-class="next" @rel="next" @title="next page" data-test-pagination-next>
1515
{{svg-jar "right-pag"}}
1616
</LinkTo>
1717
</nav>

app/styles/components/pagination.scss renamed to app/components/pagination.module.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
text-decoration: none;
1818
padding: 5px 6px;
1919
}
20+
2021
a:hover {
2122
background-color: $main-bg-dark;
2223
@media only screen and (prefers-color-scheme: dark) {
2324
background-color: #111;
2425
font-weight: bolder;
2526
}
2627
}
27-
a.active {
28+
a:global(.active) {
2829
background-color: $main-bg-dark;
2930
@media only screen and (prefers-color-scheme: dark) {
3031
background-color: #111;
@@ -33,8 +34,8 @@
3334

3435
img, svg { vertical-align: middle; }
3536

36-
.next.active,
37-
.prev.active,
37+
.next:global(.active),
38+
.prev:global(.active),
3839
.next:hover,
3940
.prev:hover {
4041
background: none;

app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Router.map(function() {
4848
this.route('policies');
4949
this.route('data-access');
5050
this.route('confirm', { path: '/confirm/:email_token' });
51+
this.route('accept-invite', { path: '/accept-invite/:token' });
5152

5253
this.route('catch-all', { path: '*path' });
5354
});

app/routes/accept-invite.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Route from '@ember/routing/route';
2+
import ajax from 'ember-fetch/ajax';
3+
4+
export default Route.extend({
5+
async model(params) {
6+
try {
7+
await ajax(`/api/v1/me/crate_owner_invitations/accept/${params.token}`, { method: 'PUT', body: '{}' });
8+
this.set('response', { accepted: true });
9+
return { response: this.get('response') };
10+
} catch (error) {
11+
this.set('response', { accepted: false });
12+
return { response: this.get('response') };
13+
}
14+
},
15+
});

app/styles/app.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@ $link-color: rgb(0, 172, 91);
1212

1313
@import "application";
1414
@import "home";
15-
@import "catch-all";
1615
@import "category-slugs";
1716
@import "crate";
1817
@import "crate/version";
1918
@import "components/crate-toml-copy";
20-
@import "components/flash-message";
21-
@import "components/pagination";
2219
@import "dashboard";
23-
@import "index";
24-
@import "loading";
2520
@import "me";
26-
@import "search";
21+
22+
@import "modules";
2723

2824
* {
2925
box-sizing: border-box;

app/styles/catch-all.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.p404 {
2+
font-size: 120%;
3+
line-height: 3em;
4+
}
5+
6+
.search-field {
7+
width: 100%;
8+
padding: 5px;
9+
@media only screen and (prefers-color-scheme: dark) {
10+
background-color: #222;
11+
color: #eee;
12+
border-color: #666;
13+
}
14+
}

app/styles/catch-all.scss

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

app/styles/crate.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@
5555
}
5656
}
5757

58+
@media only screen and (prefers-color-scheme: dark) {
59+
.crate-search {
60+
background-color: #111;
61+
color: #eee;
62+
}
63+
64+
.crate-search svg {
65+
filter: invert(100%);
66+
}
67+
}
68+
5869
#selection {
5970
width: 100%;
6071
display: flex;

app/styles/crate/versions.scss renamed to app/styles/crate/versions.module.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
#crate-all-versions {
1+
.list {
22
margin-top: 10px;
33

4-
.small { margin-left: 20px; display: inline-block; }
4+
:global(.small) {
5+
margin-left: 20px;
6+
display: inline-block;
7+
}
8+
59
a.arrow {
610
display: inline-block;
711
float: right;

app/styles/index.scss renamed to app/styles/index.module.scss

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#title-header {
1+
.title-header {
22
text-align: center;
33
border-bottom: 5px solid $gray-border;
44
@media only screen and (prefers-color-scheme: dark) {
@@ -22,13 +22,13 @@
2222
}
2323
}
2424

25-
#blurb {
25+
.blurb {
2626
margin: 30px 0 40px 0;
2727
display: flex;
2828

29-
#intro { flex: 6; line-height: 25px; padding: 10px;}
29+
.intro { flex: 6; line-height: 25px; padding: 10px;}
3030

31-
#stats {
31+
.stats {
3232
flex: 4;
3333
display: flex;
3434
flex-direction: column;
@@ -53,7 +53,7 @@
5353

5454
@media only screen and (max-width: 530px) {
5555
flex-direction: column;
56-
#stats {
56+
.stats {
5757
border: none;
5858
margin: auto;
5959
}
@@ -63,19 +63,19 @@
6363
}
6464
}
6565

66-
#home-crates {
66+
.lists {
6767
flex-wrap: wrap;
6868
justify-content: left;
6969

7070
> section {
71-
margin: 0;
72-
padding: 0 15px;
73-
width: 33.33%;
74-
@media only screen and (max-width: 750px) {
75-
width: 50%;
76-
}
77-
@media only screen and (max-width: 550px) {
78-
width: 100%;
79-
}
71+
margin: 0;
72+
padding: 0 15px;
73+
width: 33.33%;
74+
@media only screen and (max-width: 750px) {
75+
width: 50%;
76+
}
77+
@media only screen and (max-width: 550px) {
78+
width: 100%;
79+
}
8080
}
8181
}

app/styles/loading.scss renamed to app/styles/loading.module.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
div.loading-state {
1+
.loading-state {
22
text-align: center;
33
height: 65vh;
44
padding-top: 30vh;
55
}
6-
span.loading {
6+
7+
.loading {
78
display: inline-block;
89
width: 16px;
910
height: 16px;

app/styles/search.module.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.loading-spinner {
2+
margin: 0 15px;
3+
}

app/styles/search.scss

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

app/templates/accept-invite.hbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{#if this.model.response.accepted}}
2+
<h1>You've been added as a crate owner!</h1>
3+
<p>Visit your <a href="/dashboard">dashboard</a> to view all of your crates, or <a href="/me">account settings</a> to manage email notification preferences for all of your crates.</p>
4+
{{else}}
5+
<h1>Error in accepting crate ownership.</h1>
6+
<p>You may want to visit <a href="/me/pending-invites">crates.io/me/pending-invites</a> to try again.</p>
7+
{{/if}}

app/templates/catch-all.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<FlashMessage @message="Oops, that route doesn't exist!" />
22

3-
<p id='p404'>
3+
<p local-class='p404'>
44
Perhaps a search of the site may help?
55

66
<Input
77
@type="text"
8+
local-class="search-field"
89
class="search"
910
placeholder="Search"
1011
@value={{this.search}}

app/templates/crate/versions.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</span>
1111
</div>
1212

13-
<div id='crate-all-versions' class='white-rows'>
13+
<div local-class='list' class='white-rows'>
1414
{{#each this.model.versions as |version|}}
1515
<div class='row'>
1616
<div>

app/templates/index.hbs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<div id='title-header'>
1+
<div local-class='title-header'>
22
<h1>The Rust community&rsquo;s crate registry</h1>
33

4-
<div class='links'>
4+
<div local-class='links'>
55
<a href="https://doc.rust-lang.org/cargo/getting-started/installation.html" class='yellow-button' data-test-install-cargo-link>
66
{{svg-jar "button-download"}}
77
Install Cargo
@@ -14,28 +14,28 @@
1414
</div>
1515
</div>
1616

17-
<div id='blurb'>
18-
<div id='intro'>
17+
<div local-class='blurb'>
18+
<div local-class='intro'>
1919
Instantly publish your crates and install them. Use the API to
2020
interact and find out more information about available crates. Become
2121
a contributor and enhance the site with your work.
2222
</div>
2323

24-
<div id='stats'>
25-
<div class='downloads'>
24+
<div local-class='stats'>
25+
<div local-class='downloads'>
2626
{{svg-jar "download"}}
27-
<span class='num' data-test-total-downloads>{{if this.hasData (format-num this.model.num_downloads) "---,---,---"}}</span>
27+
<span local-class='num' data-test-total-downloads>{{if this.hasData (format-num this.model.num_downloads) "---,---,---"}}</span>
2828
<span class='desc small'>Downloads</span>
2929
</div>
30-
<div class='crates'>
30+
<div local-class='crates'>
3131
{{svg-jar "crate"}}
32-
<span class='num' data-test-total-crates>{{if this.hasData (format-num this.model.num_crates) "---,---"}}</span>
32+
<span local-class='num' data-test-total-crates>{{if this.hasData (format-num this.model.num_crates) "---,---"}}</span>
3333
<span class='desc small'>Crates in stock</span>
3434
</div>
3535
</div>
3636
</div>
3737

38-
<div id='home-crates' class='crate-lists'>
38+
<div local-class='lists' class='crate-lists'>
3939
<section id='new-crates' data-test-new-crates aria-busy="{{this.dataTask.isRunning}}">
4040
<h2>New Crates</h2>
4141
<CrateListNewest @crates={{this.model.new_crates}} />

app/templates/loading.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div class="loading-state">
2-
<span class="loading"></span> Loading...
1+
<div local-class="loading-state">
2+
<span local-class="loading"></span> Loading...
33
</div>

app/templates/search.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<h2>for '{{ this.q }}'</h2>
1010
{{/if}}
1111

12-
{{#if this.dataTask.isRunning}}<img src="/assets/ajax-loader.gif" class="loading-spinner">{{/if}}
12+
{{#if this.dataTask.isRunning}}<img src="/assets/ajax-loader.gif" local-class="loading-spinner">{{/if}}
1313
</div>
1414

1515
{{#if this.firstResultPending}}

config/environment.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ module.exports = function(environment) {
2626
fastboot: {
2727
hostWhitelist: ['crates.io', /^localhost:\d+$/, /\.herokuapp\.com$/],
2828
},
29+
30+
'ember-cli-mirage': {
31+
discoverEmberDataModels: false,
32+
},
2933
};
3034

3135
if (environment === 'development') {
@@ -55,6 +59,7 @@ module.exports = function(environment) {
5559

5660
if (environment === 'production') {
5761
// here you can enable a production-specific feature
62+
delete ENV['ember-cli-mirage'];
5863

5964
// Heroku Git Hash support
6065
if (process.env.SOURCE_VERSION) {

ember-cli-build.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ module.exports = function(defaults) {
3131
sassOptions: {
3232
includePaths: ['node_modules/normalize.css'],
3333
},
34+
cssModules: {
35+
extension: 'module.scss',
36+
intermediateOutputPath: 'app/styles/_modules.scss',
37+
},
3438
fingerprint: {
3539
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg', 'ttf', 'woff', 'woff2'],
3640
},
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DROP TRIGGER trigger_crate_owner_invitations_set_token_generated_at ON crate_owner_invitations;
2+
DROP FUNCTION crate_owner_invitations_set_token_generated_at();
3+
ALTER TABLE crate_owner_invitations DROP COLUMN token_generated_at;
4+
ALTER TABLE crate_owner_invitations DROP COLUMN token;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ALTER TABLE crate_owner_invitations ADD COLUMN token TEXT NOT NULL DEFAULT random_string(26);
2+
ALTER TABLE crate_owner_invitations ADD COLUMN token_generated_at TIMESTAMP;
3+
4+
CREATE FUNCTION crate_owner_invitations_set_token_generated_at() RETURNS trigger AS $$
5+
BEGIN
6+
NEW.token_generated_at := CURRENT_TIMESTAMP;
7+
RETURN NEW;
8+
END
9+
$$ LANGUAGE plpgsql;
10+
11+
CREATE TRIGGER trigger_crate_owner_invitations_set_token_generated_at BEFORE
12+
INSERT OR UPDATE OF token ON crate_owner_invitations
13+
FOR EACH ROW EXECUTE PROCEDURE crate_owner_invitations_set_token_generated_at();

0 commit comments

Comments
 (0)