mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 10:26:30 +00:00
link to repo site in headline
This commit is contained in:
parent
f5bfc8684f
commit
d320259fe8
3 changed files with 25 additions and 12 deletions
|
@ -35,6 +35,10 @@ code {
|
||||||
color: #555;
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1 a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
h1 code {
|
h1 code {
|
||||||
letter-spacing: -0.02em;
|
letter-spacing: -0.02em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,28 +20,35 @@ impl RepoPath {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RepoValidationError;
|
pub struct RepoValidationError;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct RepoSite(String);
|
pub enum RepoSite {
|
||||||
|
Github
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RepoSite {
|
||||||
|
pub fn to_base_uri(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
&RepoSite::Github => "https://github.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for RepoSite {
|
impl FromStr for RepoSite {
|
||||||
type Err = RepoValidationError;
|
type Err = RepoValidationError;
|
||||||
|
|
||||||
fn from_str(input: &str) -> Result<RepoSite, RepoValidationError> {
|
fn from_str(input: &str) -> Result<RepoSite, RepoValidationError> {
|
||||||
let is_valid = input.chars().all(|c| {
|
match input {
|
||||||
c.is_ascii_alphanumeric() || c == '.'
|
"github" => Ok(RepoSite::Github),
|
||||||
});
|
_ => Err(RepoValidationError)
|
||||||
|
|
||||||
if !is_valid {
|
|
||||||
Err(RepoValidationError)
|
|
||||||
} else {
|
|
||||||
Ok(RepoSite(input.to_string()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<str> for RepoSite {
|
impl AsRef<str> for RepoSite {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
self.0.as_ref()
|
match self {
|
||||||
|
&RepoSite::Github => "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,9 @@ pub fn status_html(analysis_outcome: AnalyzeDependenciesOutcome, repo_path: Repo
|
||||||
header {
|
header {
|
||||||
h1 {
|
h1 {
|
||||||
"Dependency status for "
|
"Dependency status for "
|
||||||
code (format!("{}/{}", repo_path.qual.as_ref(), repo_path.name.as_ref()))
|
a href=(format!("{}/{}/{}", repo_path.site.to_base_uri(), repo_path.qual.as_ref(), repo_path.name.as_ref())) {
|
||||||
|
code (format!("{}/{}", repo_path.qual.as_ref(), repo_path.name.as_ref()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img src=(format!("/{}/status.svg", self_path));
|
img src=(format!("/{}/status.svg", self_path));
|
||||||
|
|
Loading…
Reference in a new issue