Skip to content

Commit

Permalink
Added 'yanked' notice in more pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirevo committed Dec 16, 2019
1 parent 929e2a5 commit d27954b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/frontend/last_updated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub(crate) async fn get(ctx: Context<State>) -> Result<Response, Error> {
"prev": prev_page,
},
"results": results.into_iter().map(|(krate, keywords)| {
let version = state.index.latest_record(&krate.name)?.vers;
let record = state.index.latest_record(&krate.name)?;
let created_at =
chrono::NaiveDateTime::parse_from_str(krate.created_at.as_str(), DATETIME_FORMAT)
.unwrap();
Expand All @@ -96,14 +96,15 @@ pub(crate) async fn get(ctx: Context<State>) -> Result<Response, Error> {
Ok(json!({
"id": krate.id,
"name": krate.name,
"version": version,
"version": record.vers,
"description": krate.description,
"created_at": helpers::humanize_datetime(created_at),
"updated_at": helpers::humanize_datetime(updated_at),
"downloads": helpers::humanize_number(krate.downloads),
"documentation": krate.documentation,
"repository": krate.repository,
"keywords": keywords,
"yanked": record.yanked,
}))
}).collect::<Result<Vec<_>, Error>>()?,
});
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/most_downloaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub(crate) async fn get(ctx: Context<State>) -> Result<Response, Error> {
"prev": prev_page,
},
"results": results.into_iter().map(|(krate, keywords)| {
let version = state.index.latest_record(&krate.name)?.vers;
let record = state.index.latest_record(&krate.name)?;
let created_at =
chrono::NaiveDateTime::parse_from_str(krate.created_at.as_str(), DATETIME_FORMAT)
.unwrap();
Expand All @@ -96,14 +96,15 @@ pub(crate) async fn get(ctx: Context<State>) -> Result<Response, Error> {
Ok(json!({
"id": krate.id,
"name": krate.name,
"version": version,
"version": record.vers,
"description": krate.description,
"created_at": helpers::humanize_datetime(created_at),
"updated_at": helpers::humanize_datetime(updated_at),
"downloads": helpers::humanize_number(krate.downloads),
"documentation": krate.documentation,
"repository": krate.repository,
"keywords": keywords,
"yanked": record.yanked,
}))
}).collect::<Result<Vec<_>, Error>>()?,
});
Expand Down
17 changes: 16 additions & 1 deletion templates/last-updated.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@
font-weight: bold;
}
.search-result-yank {
display: inline;
font-size: 11px;
vertical-align: 30%;
border: 3px solid #F52;
padding: 1px 6px;
border-radius: 7px;
color: #F52;
}
.search-result-desc {
font-size: 18px;
}
Expand Down Expand Up @@ -262,7 +272,12 @@
{{#each results}}
<a class="search-result" href="/crates/{{ this.name }}">
<div class="search-result-infos">
<div class="search-result-title">{{ this.name }} #{{ this.version }}</div>
<div class="search-result-title">
{{ this.name }} #{{ this.version }}
{{#if this.yanked}}
<div class="search-result-yank">YANKED</div>
{{/if}}
</div>
<div class="search-result-desc">{{ this.description }}</div>
{{#if this.keywords}}
<div class="search-result-keywords">
Expand Down
17 changes: 16 additions & 1 deletion templates/most-downloaded.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@
font-weight: bold;
}
.search-result-yank {
display: inline;
font-size: 11px;
vertical-align: 30%;
border: 3px solid #F52;
padding: 1px 6px;
border-radius: 7px;
color: #F52;
}
.search-result-desc {
font-size: 18px;
}
Expand Down Expand Up @@ -262,7 +272,12 @@
{{#each results}}
<a class="search-result" href="/crates/{{ this.name }}">
<div class="search-result-infos">
<div class="search-result-title">{{ this.name }} #{{ this.version }}</div>
<div class="search-result-title">
{{ this.name }} #{{ this.version }}
{{#if this.yanked}}
<div class="search-result-yank">YANKED</div>
{{/if}}
</div>
<div class="search-result-desc">{{ this.description }}</div>
{{#if this.keywords}}
<div class="search-result-keywords">
Expand Down

0 comments on commit d27954b

Please sign in to comment.