link to repo site in headline

This commit is contained in:
Sam Rijs 2018-01-27 22:49:43 +11:00
parent f5bfc8684f
commit d320259fe8
3 changed files with 25 additions and 12 deletions

View file

@ -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;
} }

View file

@ -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"
}
} }
} }

View file

@ -58,8 +58,10 @@ pub fn status_html(analysis_outcome: AnalyzeDependenciesOutcome, repo_path: Repo
header { header {
h1 { h1 {
"Dependency status for " "Dependency status for "
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())) 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));