Add tacit css

This commit is contained in:
Valentin Brandl 2019-04-17 20:48:47 +02:00
parent 539b61e856
commit 254351e391
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D
3 changed files with 25 additions and 9 deletions

View File

@ -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))

View File

@ -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/&lt;service&gt;/&lt;user&gt;/&lt;repo&gt;)
</pre>
</code>
</p>
<p>
where <code>&lt;service&gt;</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)
</pre>
</code>
</p>
<p>
would render this badge:
<code>
<pre>
<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

File diff suppressed because one or more lines are too long