mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 02:16:30 +00:00
add summary per dependency table
This commit is contained in:
parent
d320259fe8
commit
d274045862
2 changed files with 27 additions and 8 deletions
|
@ -43,6 +43,12 @@ h1 code {
|
|||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
h3 span.summary {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
font-size: .9em;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use hyper::Response;
|
||||
use hyper::header::ContentType;
|
||||
use maud::{Markup, html};
|
||||
|
@ -8,8 +10,22 @@ use ::models::repo::RepoPath;
|
|||
|
||||
const SELF_BASE_URL: &'static str = "https://shiny-robots.herokuapp.com";
|
||||
|
||||
fn dependency_table<I: IntoIterator<Item=(CrateName, AnalyzedDependency)>>(deps: I) -> Markup {
|
||||
fn dependency_table(title: &str, deps: BTreeMap<CrateName, AnalyzedDependency>) -> Markup {
|
||||
let count_total = deps.len();
|
||||
let count_outdated = deps.iter().filter(|&(_, dep)| dep.is_outdated()).count();
|
||||
|
||||
html! {
|
||||
h3 {
|
||||
(title)
|
||||
span class="summary" {
|
||||
@if count_outdated > 0 {
|
||||
(format!(" ({} total, {} up-to-date, {} outdated)", count_total, count_total - count_outdated, count_outdated))
|
||||
} @else {
|
||||
(format!(" ({} total, all up-to-date)", count_total))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
table {
|
||||
tr {
|
||||
th "Crate"
|
||||
|
@ -75,18 +91,15 @@ pub fn status_html(analysis_outcome: AnalyzeDependenciesOutcome, repo_path: Repo
|
|||
}
|
||||
|
||||
@if !analysis_outcome.deps.main.is_empty() {
|
||||
h3 "Dependencies"
|
||||
(dependency_table(analysis_outcome.deps.main))
|
||||
(dependency_table("Dependencies", analysis_outcome.deps.main))
|
||||
}
|
||||
|
||||
@if !analysis_outcome.deps.dev.is_empty() {
|
||||
h3 "Dev dependencies"
|
||||
(dependency_table(analysis_outcome.deps.dev))
|
||||
(dependency_table("Dev dependencies", analysis_outcome.deps.dev))
|
||||
}
|
||||
|
||||
@if !analysis_outcome.deps.build.is_empty() {
|
||||
h3 "Build dependencies"
|
||||
(dependency_table(analysis_outcome.deps.build))
|
||||
(dependency_table("Build dependencies", analysis_outcome.deps.build))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue