hoc/templates/index.rs.html

109 lines
4.0 KiB
HTML
Raw Normal View History

2019-04-23 18:19:54 +02:00
@use super::base;
2019-05-14 01:11:39 +02:00
@use crate::statics::VersionInfo;
2019-04-23 18:19:54 +02:00
2020-11-24 19:06:42 +01:00
@(version_info: VersionInfo, repo_count: usize, base_url: &str)
2019-04-23 18:19:54 +02:00
@: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
2021-09-03 11:44:22 +02:00
used for GitHub, GitLab, Bitbucket and Sourcehut repositories. Just put the following code in your README:
2019-04-23 18:19:54 +02:00
</p>
<pre>
2020-11-24 19:13:08 +01:00
[![Hits-of-Code](@base_url/&lt;service&gt;/&lt;user&gt;/&lt;repo&gt;)](@base_url/&lt;service&gt;/&lt;user&gt;/&lt;repo&gt;/view)
2019-04-23 18:19:54 +02:00
</pre>
<p>
2021-09-03 11:44:22 +02:00
where <code>&lt;service&gt;</code> is one of <code>github</code>, <code>gitlab</code>, <code>bitbucket</code> or
<code>sourcehut</code>. So the following Markdown
2019-04-23 18:19:54 +02:00
</p>
<pre>
2020-11-24 19:13:08 +01:00
[![Hits-of-Code](@base_url/github/vbrandl/hoc)](@base_url/github/vbrandl/hoc/view)
2019-04-23 18:19:54 +02:00
</pre>
<p>
would render this badge:
</p>
<pre>
2020-11-24 19:13:08 +01:00
<a href="@base_url/github/vbrandl/hoc/view"><img src="@base_url/github/vbrandl/hoc"
2019-04-23 18:19:54 +02:00
alt="example badge" /></a>
</pre>
<p>
By default, this service assumes the existence of a branch named <code>master</code>. If no branch with that name exists
in your repository or you want a badge for another branch of your repository, just append
<code>?branch=&lt;branch-name&gt;</code> to the URL.
</p>
2023-01-16 09:54:04 +01:00
<p>
The badge label can be customized using the <code>label=&lt;some-label&gt;</code> query parameter. It defaults to <code>Hits-of-Code</code>.
</p>
2019-06-16 15:00:46 +02:00
<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 three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and
<code>head</code> (the commit ref of HEAD). Requesting <a
2020-11-24 19:06:42 +01:00
href="@base_url/github/vbrandl/hoc/json">@base_url/github/vbrandl/hoc/json</a> might return something along
the lines of
2019-06-16 15:00:46 +02:00
</p>
<pre>
&#123;
"head": "1f01c3b964b018fb0c0c2c5b572bf4ace2968546",
"count": 8324,
"commits": 223
2019-06-16 15:00:46 +02:00
&#125;
</pre>
2019-05-04 15:38:00 +02:00
<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>
2021-09-03 11:44:22 +02:00
<option value="sourcehut">Sourcehut</option>
2019-05-04 15:38:00 +02:00
</select>
<label>/</label>
<input name="user" id="user" type="text" placeholder="user" />
<label>/</label>
<input name="repo" id="repo" type="text" placeholder="repository" />
<label>:</label>
<input name="branch" id="branch" type="text" placeholder="branch (defaults to `master`)" />
2019-05-04 15:38:00 +02:00
<button type="submit">Generate</button>
</form>
2019-04-23 18:19:54 +02:00
<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
2021-06-10 12:09:54 +02:00
my <a href="https://www.vbrandl.net/static/keys/0x1FFE431282F4B8CC0A7579167FB009175885FC76.asc">GPG key</a>
2019-04-23 18:19:54 +02:00
(<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>
2019-06-12 21:50:45 +02:00
}, version_info, repo_count)