From 3990ea0a12f5e9fcb4a8110d878659b72fc69844 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 23 Apr 2019 18:19:54 +0200 Subject: [PATCH] Add templates --- build.rs | 13 +++++++++ templates/base.rs.html | 49 ++++++++++++++++++++++++++++++++ templates/index.rs.html | 63 +++++++++++++++++++++++++++++++++++++++++ templates/p404.rs.html | 13 +++++++++ templates/p500.rs.html | 13 +++++++++ 5 files changed, 151 insertions(+) create mode 100644 build.rs create mode 100644 templates/base.rs.html create mode 100644 templates/index.rs.html create mode 100644 templates/p404.rs.html create mode 100644 templates/p500.rs.html diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..fd83ed0 --- /dev/null +++ b/build.rs @@ -0,0 +1,13 @@ +extern crate ructe; +extern crate vergen; + +use ructe::Ructe; +use vergen::{generate_cargo_keys, ConstantsFlags}; + +fn main() { + let flags = ConstantsFlags::SHA_SHORT; + generate_cargo_keys(flags).expect("Unable to generate the cargo keys!"); + Ructe::from_env() + .expect("ructe") + .compile_templates("templates"); +} diff --git a/templates/base.rs.html b/templates/base.rs.html new file mode 100644 index 0000000..9bc30d5 --- /dev/null +++ b/templates/base.rs.html @@ -0,0 +1,49 @@ +@(title: &str, header: &str, content: Content, commit: &str, version: &str) + + + + + + + + + + @title + + + +
+
+

@header

+
+ +
+ @:content() +
+ + +
+ + + diff --git a/templates/index.rs.html b/templates/index.rs.html new file mode 100644 index 0000000..ae559e6 --- /dev/null +++ b/templates/index.rs.html @@ -0,0 +1,63 @@ +@use super::base; + +@(commit: &str, version: &str) + +@:base("Hits-of-Code Badges", "Hits-of-Code Badges", { + +

+This API offers badges for the Hits-of-Code metric for your repositories. This metric was proposed by +Yegor Bugayenko as an +alternative to Lines-of-Code. +

+ +

+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. +

+ +

+There is a command-line tool 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: +

+ +
+[![Hits-of-Code](https://hitsofcode.com/<service>/<user>/<repo>)](https://hitsofcode.com/view/<service>/<user>/<repo>)
+
+ +

+where <service> is one of github, gitlab or bitbucket. So the +following Markdown +

+ +
+[![Hits-of-Code](https://hitsofcode.com/github/vbrandl/hoc)](https://hitsofcode.com/view/github/vbrandl/hoc)
+
+ +

+would render this badge: +

+ +
+
+
+ +

Source Code

+ +

+The whole service is licensed under the MIT license and the source +code can be found on GitHub. Feature proposals or pull requests are +welcome. +

+ +

Contact

+ +

+ You can reach me via mail: mail+hoc@@vbrandl.net preferably using +my GPG key +(from a + keyserver), or by using any other UID from my key. +

+}, commit, version) diff --git a/templates/p404.rs.html b/templates/p404.rs.html new file mode 100644 index 0000000..1ae929a --- /dev/null +++ b/templates/p404.rs.html @@ -0,0 +1,13 @@ +@use super::base; + +@(commit: &str, version: &str) + +@:base("Page not Found - Hits-of-Code Badges", "404 - Page not Found", { +

+Sorry. I couldn't find the page you are looking for. Please go back to the homepage. +

+ +

+If you think, this is a mistake on my side, please drop me a mail. +

+}, commit, version) diff --git a/templates/p500.rs.html b/templates/p500.rs.html new file mode 100644 index 0000000..0bdebeb --- /dev/null +++ b/templates/p500.rs.html @@ -0,0 +1,13 @@ +@use super::base; + +@(commit: &str, version: &str) + +@:base("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", { +

+Oops. Looks like a made a mistake. Please go back to the homepage and try again. +

+ +

+If you think, this is a bug, please drop me a mail. +

+}, commit, version)