mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 10:26:30 +00:00
links direct to other deps.rs pages (#86)
and a crates link is provided on the icon to the left
This commit is contained in:
parent
3427054f9b
commit
139741362e
2 changed files with 22 additions and 2 deletions
|
@ -105,6 +105,13 @@ impl AnalyzedDependency {
|
|||
pub fn is_outdated(&self) -> bool {
|
||||
self.latest > self.latest_that_matches
|
||||
}
|
||||
|
||||
pub fn deps_rs_path(&self, name: &str) -> String {
|
||||
match &self.latest_that_matches {
|
||||
Some(version) => ["/crate/", name, "/", version.to_string().as_str()].concat(),
|
||||
None => ["/crate/", name].concat(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use hyper::{Body, Response};
|
||||
use indexmap::IndexMap;
|
||||
use maud::{html, Markup};
|
||||
use semver::Version;
|
||||
|
||||
use crate::engine::AnalyzeDependenciesOutcome;
|
||||
use crate::models::crates::{AnalyzedDependencies, AnalyzedDependency, CrateName};
|
||||
|
@ -8,6 +9,14 @@ use crate::models::repo::RepoSite;
|
|||
use crate::models::SubjectPath;
|
||||
use crate::server::views::badge;
|
||||
|
||||
fn get_crates_url(name: impl AsRef<str>) -> String {
|
||||
format!("https://crates.io/crates/{}", name.as_ref())
|
||||
}
|
||||
|
||||
fn get_crates_version_url(name: impl AsRef<str>, version: &Version) -> String {
|
||||
format!("https://crates.io/crates/{}/{}", name.as_ref(), version)
|
||||
}
|
||||
|
||||
fn dependency_tables(crate_name: CrateName, deps: AnalyzedDependencies) -> Markup {
|
||||
html! {
|
||||
h2 class="title is-3" {
|
||||
|
@ -62,7 +71,11 @@ fn dependency_table(title: &str, deps: IndexMap<CrateName, AnalyzedDependency>)
|
|||
@for (name, dep) in deps {
|
||||
tr {
|
||||
td {
|
||||
a href=(format!("https://crates.io/crates/{}", name.as_ref())) { (name.as_ref()) }
|
||||
a class="has-text-grey" href=(get_crates_url(&name)) {
|
||||
i class=("fa fa-cube") { "" }
|
||||
}
|
||||
{ "\u{00A0}" } // non-breaking space
|
||||
a href=(dep.deps_rs_path(name.as_ref())) { (name.as_ref()) }
|
||||
}
|
||||
td class="has-text-right" { code { (dep.required.to_string()) } }
|
||||
td class="has-text-right" {
|
||||
|
@ -109,7 +122,7 @@ fn render_title(subject_path: &SubjectPath) -> Markup {
|
|||
}
|
||||
SubjectPath::Crate(ref crate_path) => {
|
||||
html! {
|
||||
a href=(format!("https://crates.io/crates/{}/{}", crate_path.name.as_ref(), crate_path.version)) {
|
||||
a href=(get_crates_version_url(&crate_path.name, &crate_path.version)) {
|
||||
i class="fa fa-cube" { "" }
|
||||
(format!(" {} {}", crate_path.name.as_ref(), crate_path.version))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue