hoc/templates/index.rs.html
2019-06-16 15:00:46 +02:00

95 lines
3.3 KiB
HTML

@use super::base;
@use crate::statics::VersionInfo;
@(version_info: VersionInfo, repo_count: usize, domain: &str)
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
<p>
This API offers badges for the Hits-of-Code metric for your repositories. This metric was proposed by
<a href="https://www.yegor256.com/">Yegor Bugayenko</a> as an
<a href="https://www.yegor256.com/2014/11/14/hits-of-code.html">alternative to Lines-of-Code</a>.
</p>
<p>
Instead of counting the number of existing lines in a codebase, the number of modified lines is counted. That way, the
metric can only grow and never shrink. While this metric still cannot give any information about the code quality, it
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
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:
</p>
<pre>
[![Hits-of-Code](https://@domain/&lt;service&gt;/&lt;user&gt;/&lt;repo&gt;)](https://@domain/view/&lt;service&gt;/&lt;user&gt;/&lt;repo&gt;)
</pre>
<p>
where <code>&lt;service&gt;</code> is one of <code>github</code>, <code>gitlab</code> or <code>bitbucket</code>. So the
following Markdown
</p>
<pre>
[![Hits-of-Code](https://@domain/github/vbrandl/hoc)](https://@domain/view/github/vbrandl/hoc)
</pre>
<p>
would render this badge:
</p>
<pre>
<a href="https://@domain/view/github/vbrandl/hoc"><img src="https://@domain/github/vbrandl/hoc"
alt="example badge" /></a>
</pre>
<p>
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON
object with two fields: <code>count</code> and <code>head</code> with count being the HoC value and head being the
commit ref of <code>HEAD</code>. Requesting
<a href="https://@domain/github/vbrandl/hoc/json">https://@domain/github/vbrandl/hoc/json</a> might return something
along the lines of
</p>
<pre>
&#123;
"head" : "05736ee3ba256ec9a7227c436aef2bf43db109ab",
"count": 7582
&#125;
</pre>
<h2>Badge Generator</h2>
<form method="post" action="/generate">
<select name="service" id="service">
<option value="github">GitHub</option>
<option value="gitlab">Gitlab</option>
<option value="bitbucket">Bitbucket</option>
</select>
<label>/</label>
<input name="user" id="user" type="text" placeholder="user" />
<label>/</label>
<input name="repo" id="repo" type="text" placeholder="repository" />
<button type="submit">Generate</button>
</form>
<h2>Source Code</h2>
<p>
The whole service is licensed under the <a href="https://opensource.org/licenses/MIT">MIT license</a> and the source
code <a href="https://github.com/vbrandl/hoc">can be found on GitHub</a>. Feature proposals or pull requests are
welcome.
</p>
<h2>Contact</h2>
<p>
You can reach me via mail: <a href="mailto:mail+hoc@@vbrandl.net">mail+hoc@@vbrandl.net</a> preferably using
my <a href="https://mirror.oldsql.cc/key.asc">GPG key</a>
(<a href="http://pool.sks-keyservers.net/pks/lookup?op=get&amp;search=0x1FFE431282F4B8CC0A7579167FB009175885FC76">from a
keyserver</a>), or by using any other UID from my key.
</p>
}, version_info, repo_count)