Skip to content

Commit 79f3a41

Browse files
committed
Merge branch 'wycats-cleanup'
2 parents d96f488 + cd45701 commit 79f3a41

File tree

7 files changed

+144
-76
lines changed

7 files changed

+144
-76
lines changed

app/controllers/crate/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export default Ember.ObjectController.extend({
2828
return this.get("sortedVersions.length") > NUM_VERSIONS;
2929
}.property('sortedVersions'),
3030

31+
anyLinks: function() {
32+
return this.get('homepage') ||
33+
this.get('wiki') ||
34+
this.get('mailing_list') ||
35+
this.get('documentation') ||
36+
this.get('repository');
37+
}.property('homepage', 'wiki', 'mailing_list', 'documentation', 'repository'),
38+
3139
displayedAuthors: function() {
3240
var self = this;
3341
if (!this.get('currentVersion')) {

app/helpers/format-email.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Ember from "ember";
2+
3+
var escape = Ember.Handlebars.Utils.escapeExpression;
4+
5+
function formatEmail(email) {
6+
var formatted = email.match(/^(.*?)\s*(?:<(.*)>)?$/);
7+
var ret = "";
8+
9+
ret += escape(formatted[1]);
10+
11+
if (formatted[2]) {
12+
ret = "<a href='mailto:" + escape(formatted[2]) + "'>" + ret + "</a>";
13+
}
14+
15+
return ret.htmlSafe();
16+
}
17+
18+
19+
export {
20+
formatEmail
21+
};
22+
23+
export default Ember.Handlebars.makeBoundHelper(formatEmail);

app/helpers/format-req.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Ember from "ember";
2+
3+
function formatReq(req) {
4+
return req === "*" ? "" : req;
5+
}
6+
7+
export default Ember.Handlebars.makeBoundHelper(formatReq);

app/styles/crate.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
.top, .bottom {
153153
@include flex-direction(column);
154154
}
155+
156+
ul {
157+
padding-left: 20px;
158+
}
155159
}
156160
}
157161

@@ -260,9 +264,8 @@
260264
.graph {
261265
@include flex-grow(10);
262266
width: 100%;
263-
padding-bottom: 30px;
264267
margin: 30px 0;
265-
border-bottom: 5px solid $gray-border;
268+
padding-bottom: 20px;
266269

267270
h4 { color: $main-color-light; }
268271
}
@@ -274,6 +277,9 @@
274277

275278
#crate-links {
276279
@include display-flex;
280+
padding-bottom: 20px;
281+
border-bottom: 5px solid $gray-border;
282+
margin-bottom: 30px;
277283

278284
h3 { margin-bottom: 5px; }
279285
.section {

app/templates/crate/index.hbs

Lines changed: 80 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</div>
4949
{{/if}}
5050
<div class='install'>
51-
<div class='action'>Depend</div>
51+
<div class='action'>Cargo.toml</div>
5252
<code>{{ name }} = "~{{ currentVersion.num }}"</code>
5353
</div>
5454
</div>
@@ -59,11 +59,11 @@
5959
<div class='date'>{{ from-now updated_at }}</div>
6060
</div>
6161

62-
<div>
62+
<div class="authors">
6363
<h3>Authors</h3>
6464
<ul>
6565
{{#each displayedAuthors}}
66-
<li>{{ name }}</li>
66+
<li>{{ format-email name }}</li>
6767
{{/each}}
6868
</ul>
6969
</div>
@@ -106,6 +106,83 @@
106106
</div>
107107
</div>
108108

109+
<div id='crate-links'>
110+
{{#if anyLinks}}
111+
<div class='section'>
112+
<h3>Links</h3>
113+
<ul>
114+
{{#if homepage}}
115+
<li><a {{bind-attr href=homepage}}>Homepage</a></li>
116+
{{/if}}
117+
{{#if wiki}}
118+
<li><a {{bind-attr href=wiki}}>Wiki</a></li>
119+
{{/if}}
120+
{{#if mailing_list}}
121+
<li><a {{bind-attr href=mailing_list}}>Mailing List</a></li>
122+
{{/if}}
123+
{{#if documentation}}
124+
<li><a {{bind-attr href=documentation}}>Documentation</a></li>
125+
{{/if}}
126+
{{#if repository}}
127+
<li><a {{bind-attr href=repository}}>Repository</a></li>
128+
{{/if}}
129+
</ul>
130+
</div>
131+
{{/if}}
132+
133+
<div class='section' id='crate-dependencies'>
134+
<h3>Dependencies</h3>
135+
<ul>
136+
{{#each currentDependencies}}
137+
<li>
138+
{{#link-to 'crate' crate_id}}
139+
{{ crate_id }} {{ format-req req }}
140+
{{/link-to}}
141+
</li>
142+
{{else}}
143+
<li>None</li>
144+
{{/each}}
145+
</ul>
146+
</div>
147+
148+
{{#if currentDevDependencies}}
149+
<div class='section' id='crate-dev-dependencies'>
150+
<h3>Dev-Dependencies</h3>
151+
<ul>
152+
{{#each currentDevDependencies}}
153+
<li>
154+
{{#link-to 'crate' crate_id}}
155+
{{ crate_id}} {{ req }}
156+
{{/link-to}}
157+
</li>
158+
{{/each}}
159+
</ul>
160+
</div>
161+
{{/if}}
162+
163+
<div class='section' id='crate-versions'>
164+
<h3>Versions</h3>
165+
<ul>
166+
{{#each smallSortedVersions}}
167+
<li>
168+
{{#link-to 'crate' this}}{{ num }}{{/link-to}}
169+
<span class='date'>{{ date-small created_at }}</span>
170+
{{#if yanked}}
171+
<span class='yanked'>yanked</span>
172+
{{/if}}
173+
</li>
174+
{{/each}}
175+
</ul>
176+
<span class='small'>
177+
{{#if hasMoreVersions}}
178+
{{#link-to 'crate.versions' this}}
179+
show all {{ versions.length }} versions
180+
{{/link-to}}
181+
{{/if}}
182+
</span>
183+
</div>
184+
</div>
185+
109186
<div id='crate-downloads'>
110187
<div class='stats'>
111188
<h3>Stats Overview</h3>
@@ -160,74 +237,3 @@
160237
</div>
161238
</div>
162239
{{/if}}
163-
164-
<div id='crate-links'>
165-
<div class='section'>
166-
<h3>Links</h3>
167-
<ul>
168-
{{#if homepage}}
169-
<li><a {{bind-attr href=homepage}}>Homepage</a></li>
170-
{{/if}}
171-
{{#if wiki}}
172-
<li><a {{bind-attr href=wiki}}>Wiki</a></li>
173-
{{/if}}
174-
{{#if mailing_list}}
175-
<li><a {{bind-attr href=mailing_list}}>Mailing List</a></li>
176-
{{/if}}
177-
{{#if documentation}}
178-
<li><a {{bind-attr href=documentation}}>Documentation</a></li>
179-
{{/if}}
180-
{{#if repository}}
181-
<li><a {{bind-attr href=repository}}>Repository</a></li>
182-
{{/if}}
183-
</ul>
184-
</div>
185-
186-
<div class='section' id='crate-dependencies'>
187-
<h3>Dependencies</h3>
188-
<ul>
189-
{{#each currentDependencies}}
190-
<li>
191-
{{#link-to 'crate' crate_id}}
192-
{{ crate_id}} {{ req }}
193-
{{/link-to}}
194-
</li>
195-
{{/each}}
196-
</ul>
197-
</div>
198-
199-
<div class='section' id='crate-dev-dependencies'>
200-
<h3>Dev-Dependencies</h3>
201-
<ul>
202-
{{#each currentDevDependencies}}
203-
<li>
204-
{{#link-to 'crate' crate_id}}
205-
{{ crate_id}} {{ req }}
206-
{{/link-to}}
207-
</li>
208-
{{/each}}
209-
</ul>
210-
</div>
211-
212-
<div class='section' id='crate-versions'>
213-
<h3>Versions</h3>
214-
<ul>
215-
{{#each smallSortedVersions}}
216-
<li>
217-
{{#link-to 'crate' this}}{{ num }}{{/link-to}}
218-
<span class='date'>{{ date-small created_at }}</span>
219-
{{#if yanked}}
220-
<span class='yanked'>yanked</span>
221-
{{/if}}
222-
</li>
223-
{{/each}}
224-
</ul>
225-
<span class='small'>
226-
{{#if hasMoreVersions}}
227-
{{#link-to 'crate.versions' this}}
228-
show all {{ versions.length }} versions
229-
{{/link-to}}
230-
{{/if}}
231-
</span>
232-
</div>
233-
</div>

app/templates/loading.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Loading...
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {
2+
formatEmail
3+
} from 'cargo/helpers/format-email';
4+
5+
module('FormatEmailHelper');
6+
7+
// Replace this with your real tests.
8+
test('it works', function(assert) {
9+
assert.equal(formatEmail('foo'), 'foo');
10+
assert.equal(formatEmail('foo <foo@bar.com>').toString(),
11+
"<a href='mailto:foo@bar.com'>foo</a>");
12+
assert.equal(formatEmail('<script></script> <foo@bar.com>').toString(),
13+
"<a href='mailto:script&gt;&lt;/script&gt; &lt;foo@bar.com'></a>");
14+
assert.equal(formatEmail('').toString(), '');
15+
assert.equal(formatEmail('test <foo').toString(), 'test &lt;foo');
16+
});
17+

0 commit comments

Comments
 (0)