Add tacit css
This commit is contained in:
parent
539b61e856
commit
254351e391
12
src/main.rs
12
src/main.rs
@ -16,6 +16,7 @@ use structopt::StructOpt;
|
||||
type State = Arc<String>;
|
||||
|
||||
const INDEX: &str = include_str!("../static/index.html");
|
||||
const CSS: &str = include_str!("../static/tacit-css.min.css");
|
||||
|
||||
#[derive(StructOpt, Debug)]
|
||||
struct Opt {
|
||||
@ -181,6 +182,16 @@ fn index() -> HttpResponse {
|
||||
.streaming(rx_body.map_err(|_| error::ErrorBadRequest("bad request")))
|
||||
}
|
||||
|
||||
#[get("/tacit-css.min.css")]
|
||||
fn css() -> HttpResponse {
|
||||
let (tx, rx_body) = mpsc::unbounded();
|
||||
let _ = tx.unbounded_send(Bytes::from(CSS.as_bytes()));
|
||||
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/css")
|
||||
.streaming(rx_body.map_err(|_| error::ErrorBadRequest("bad request")))
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
pretty_env_logger::init();
|
||||
@ -193,6 +204,7 @@ fn main() -> std::io::Result<()> {
|
||||
.data(state.clone())
|
||||
.wrap(middleware::Logger::default())
|
||||
.service(index)
|
||||
.service(css)
|
||||
.service(web::resource("/github/{user}/{repo}").to(github))
|
||||
.service(web::resource("/gitlab/{user}/{repo}").to(gitlab))
|
||||
.service(web::resource("/bitbucket/{user}/{repo}").to(bitbucket))
|
||||
|
@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="tacit-css.min.css"/>
|
||||
<title>Hits-of-Code Badges</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -25,32 +26,32 @@ gives an overview about the amount of work put into a codebase.
|
||||
<p />
|
||||
|
||||
<div>
|
||||
<p>
|
||||
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
|
||||
used for GitHub, GitLab and Bitbucket repositories. Just put the following code in your README:
|
||||
|
||||
<code>
|
||||
<pre>
|
||||
![Hits-of-Code](https://hoc.oldsql.cc/<service>/<user>/<repo>)
|
||||
![Hits-of-Code](https://hoc.oldsql.cc/<service>/<user>/<repo>)
|
||||
</pre>
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
where <code><service></code> is one of <code>github</code>, <code>gitlab</code> or <code>bitbucket</code>. So the
|
||||
following Markdown
|
||||
|
||||
<code>
|
||||
<pre>
|
||||
![Hits-of-Code](https://hoc.oldsql.cc/github/vbrandl/elm-chess)
|
||||
![Hits-of-Code](https://hoc.oldsql.cc/github/vbrandl/elm-chess)
|
||||
</pre>
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
would render this badge:
|
||||
|
||||
<code>
|
||||
<pre>
|
||||
<img src="https://hoc.oldsql.cc/github/vbrandl/elm-chess" />
|
||||
<img src="https://hoc.oldsql.cc/github/vbrandl/elm-chess" />
|
||||
</pre>
|
||||
</code>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h2>Source Code</h2>
|
||||
|
3
static/tacit-css.min.css
vendored
Normal file
3
static/tacit-css.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user