Implement badges for sourcehut
This commit is contained in:
parent
3a57fcca9d
commit
44d47b1d5f
@ -22,7 +22,7 @@ use crate::{
|
|||||||
cache::CacheState,
|
cache::CacheState,
|
||||||
config::Settings,
|
config::Settings,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
service::{Bitbucket, FormService, GitHub, Gitlab, Service, Sourcehut},
|
||||||
statics::{CLIENT, CSS, FAVICON, VERSION_INFO},
|
statics::{CLIENT, CSS, FAVICON, VERSION_INFO},
|
||||||
template::RepoInfo,
|
template::RepoInfo,
|
||||||
};
|
};
|
||||||
@ -490,6 +490,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
|||||||
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
||||||
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
||||||
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
||||||
|
.service(web::resource("/sourcehut/{user}/{repo}").to(calculate_hoc::<Sourcehut>))
|
||||||
.service(
|
.service(
|
||||||
web::resource("/github/{user}/{repo}/delete")
|
web::resource("/github/{user}/{repo}/delete")
|
||||||
.route(web::post().to(delete_repo_and_cache::<GitHub>)),
|
.route(web::post().to(delete_repo_and_cache::<GitHub>)),
|
||||||
@ -502,15 +503,21 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
|||||||
web::resource("/bitbucket/{user}/{repo}/delete")
|
web::resource("/bitbucket/{user}/{repo}/delete")
|
||||||
.route(web::post().to(delete_repo_and_cache::<Bitbucket>)),
|
.route(web::post().to(delete_repo_and_cache::<Bitbucket>)),
|
||||||
)
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/sourcehut/{user}/{repo}/delete")
|
||||||
|
.route(web::post().to(delete_repo_and_cache::<Sourcehut>)),
|
||||||
|
)
|
||||||
.service(web::resource("/github/{user}/{repo}/json").to(json_hoc::<GitHub>))
|
.service(web::resource("/github/{user}/{repo}/json").to(json_hoc::<GitHub>))
|
||||||
.service(web::resource("/gitlab/{user}/{repo}/json").to(json_hoc::<Gitlab>))
|
.service(web::resource("/gitlab/{user}/{repo}/json").to(json_hoc::<Gitlab>))
|
||||||
.service(web::resource("/bitbucket/{user}/{repo}/json").to(json_hoc::<Bitbucket>))
|
.service(web::resource("/bitbucket/{user}/{repo}/json").to(json_hoc::<Bitbucket>))
|
||||||
|
.service(web::resource("/sourcehut/{user}/{repo}/json").to(json_hoc::<Sourcehut>))
|
||||||
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
||||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
||||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
||||||
.service(web::resource("/github/{user}/{repo}/view").to(overview::<GitHub>))
|
.service(web::resource("/github/{user}/{repo}/view").to(overview::<GitHub>))
|
||||||
.service(web::resource("/gitlab/{user}/{repo}/view").to(overview::<Gitlab>))
|
.service(web::resource("/gitlab/{user}/{repo}/view").to(overview::<Gitlab>))
|
||||||
.service(web::resource("/bitbucket/{user}/{repo}/view").to(overview::<Bitbucket>))
|
.service(web::resource("/bitbucket/{user}/{repo}/view").to(overview::<Bitbucket>))
|
||||||
|
.service(web::resource("/sourcehut/{user}/{repo}/view").to(overview::<Sourcehut>))
|
||||||
.default_service(web::resource("").route(web::get().to(async_p404)))
|
.default_service(web::resource("").route(web::get().to(async_p404)))
|
||||||
})
|
})
|
||||||
.workers(workers)
|
.workers(workers)
|
||||||
|
@ -12,6 +12,8 @@ pub(crate) enum FormService {
|
|||||||
Gitlab,
|
Gitlab,
|
||||||
#[serde(rename = "bitbucket")]
|
#[serde(rename = "bitbucket")]
|
||||||
Bitbucket,
|
Bitbucket,
|
||||||
|
#[serde(rename = "sourcehut")]
|
||||||
|
Sourcehut,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FormService {
|
impl FormService {
|
||||||
@ -20,6 +22,7 @@ impl FormService {
|
|||||||
FormService::GitHub => "github.com",
|
FormService::GitHub => "github.com",
|
||||||
FormService::Gitlab => "gitlab.com",
|
FormService::Gitlab => "gitlab.com",
|
||||||
FormService::Bitbucket => "bitbucket.org",
|
FormService::Bitbucket => "bitbucket.org",
|
||||||
|
FormService::Sourcehut => "git.sr.ht",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +31,7 @@ impl FormService {
|
|||||||
FormService::GitHub => "github",
|
FormService::GitHub => "github",
|
||||||
FormService::Gitlab => "gitlab",
|
FormService::Gitlab => "gitlab",
|
||||||
FormService::Bitbucket => "bitbucket",
|
FormService::Bitbucket => "bitbucket",
|
||||||
|
FormService::Sourcehut => "sourcehut",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,3 +77,17 @@ impl Service for Bitbucket {
|
|||||||
format!("https://{}/{}/commits/{}", Self::domain(), repo, commit_ref)
|
format!("https://{}/{}/commits/{}", Self::domain(), repo, commit_ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Sourcehut;
|
||||||
|
|
||||||
|
impl Service for Sourcehut {
|
||||||
|
fn domain() -> &'static str {
|
||||||
|
"git.sr.ht"
|
||||||
|
}
|
||||||
|
fn url_path() -> &'static str {
|
||||||
|
"sourcehut"
|
||||||
|
}
|
||||||
|
fn commit_url(repo: &str, commit_ref: &str) -> String {
|
||||||
|
format!("https://{}/{}/commit/{}", Self::domain(), repo, commit_ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@ gives an overview about the amount of work put into a codebase.
|
|||||||
<p>
|
<p>
|
||||||
There is a <a href="https://github.com/yegor256/hoc/">command-line tool</a> to calculate the HoC of a repository, but
|
There is a <a href="https://github.com/yegor256/hoc/">command-line tool</a> to calculate the HoC of a repository, but
|
||||||
some people might want a nice badge to put in their README, that's why I implemented this API. Currently the API can be
|
some people might want a nice badge to put in their README, that's why I implemented this API. Currently the API can be
|
||||||
used for GitHub, GitLab and Bitbucket repositories. Just put the following code in your README:
|
used for GitHub, GitLab, Bitbucket and Sourcehut repositories. Just put the following code in your README:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -28,8 +28,8 @@ used for GitHub, GitLab and Bitbucket repositories. Just put the following code
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
where <code><service></code> is one of <code>github</code>, <code>gitlab</code> or <code>bitbucket</code>. So the
|
where <code><service></code> is one of <code>github</code>, <code>gitlab</code>, <code>bitbucket</code> or
|
||||||
following Markdown
|
<code>sourcehut</code>. So the following Markdown
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -74,6 +74,7 @@ the lines of
|
|||||||
<option value="github">GitHub</option>
|
<option value="github">GitHub</option>
|
||||||
<option value="gitlab">Gitlab</option>
|
<option value="gitlab">Gitlab</option>
|
||||||
<option value="bitbucket">Bitbucket</option>
|
<option value="bitbucket">Bitbucket</option>
|
||||||
|
<option value="sourcehut">Sourcehut</option>
|
||||||
</select>
|
</select>
|
||||||
<label>/</label>
|
<label>/</label>
|
||||||
<input name="user" id="user" type="text" placeholder="user" />
|
<input name="user" id="user" type="text" placeholder="user" />
|
||||||
|
Loading…
Reference in New Issue
Block a user