mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-21 18:06: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;
|
||||
}
|
||||
|
||||
h1 a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1 code {
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
|
|
@ -20,28 +20,35 @@ impl RepoPath {
|
|||
#[derive(Debug)]
|
||||
pub struct RepoValidationError;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RepoSite(String);
|
||||
#[derive(Clone, Copy)]
|
||||
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 {
|
||||
type Err = RepoValidationError;
|
||||
|
||||
fn from_str(input: &str) -> Result<RepoSite, RepoValidationError> {
|
||||
let is_valid = input.chars().all(|c| {
|
||||
c.is_ascii_alphanumeric() || c == '.'
|
||||
});
|
||||
|
||||
if !is_valid {
|
||||
Err(RepoValidationError)
|
||||
} else {
|
||||
Ok(RepoSite(input.to_string()))
|
||||
match input {
|
||||
"github" => Ok(RepoSite::Github),
|
||||
_ => Err(RepoValidationError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for RepoSite {
|
||||
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 {
|
||||
h1 {
|
||||
"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));
|
||||
|
|
Loading…
Reference in a new issue