diff --git a/Cargo.lock b/Cargo.lock
index 595c12b..e69d97a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -807,6 +807,7 @@ dependencies = [
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "number_prefix 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1211,6 +1212,11 @@ dependencies = [
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "number_prefix"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "openssl"
version = "0.10.20"
@@ -2428,6 +2434,7 @@ dependencies = [
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
+"checksum number_prefix 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a"
"checksum openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)" = "5a0d6b781aac4ac1bd6cafe2a2f0ad8c16ae8e1dd5184822a16c50139f8838d9"
"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
"checksum openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)" = "33c86834957dd5b915623e94f2f4ab2c70dd8f6b70679824155d5ae21dbd495d"
diff --git a/Cargo.toml b/Cargo.toml
index a8c47ce..04169e7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,7 @@ bytes = "0.4.12"
futures = "0.1.25"
git2 = "0.8.0"
lazy_static = "1.3.0"
+number_prefix = "0.3.0"
openssl-probe = "0.1.2"
pretty_env_logger = "0.3.0"
reqwest = "0.9.15"
diff --git a/src/main.rs b/src/main.rs
index cd138ed..c5aea70 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,8 +2,6 @@
extern crate actix_web;
#[macro_use]
extern crate lazy_static;
-extern crate reqwest;
-extern crate serde_json;
#[macro_use]
extern crate serde_derive;
@@ -25,6 +23,7 @@ use badge::{Badge, BadgeOptions};
use bytes::Bytes;
use futures::{unsync::mpsc, Stream};
use git2::Repository;
+use number_prefix::{NumberPrefix, Prefixed, Standalone};
use std::{
fs::create_dir_all,
path::{Path, PathBuf},
@@ -36,25 +35,32 @@ use structopt::StructOpt;
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
-const COMMIT: &str = env!("VERGEN_SHA_SHORT");
-const VERSION: &str = env!("CARGO_PKG_VERSION");
+pub struct VersionInfo<'a> {
+ pub commit: &'a str,
+ pub version: &'a str,
+}
+
+const VERSION_INFO: VersionInfo = VersionInfo {
+ commit: env!("VERGEN_SHA_SHORT"),
+ version: env!("CARGO_PKG_VERSION"),
+};
lazy_static! {
static ref CLIENT: reqwest::Client = reqwest::Client::new();
static ref OPT: Opt = Opt::from_args();
static ref INDEX: Vec
-The project at @url has @hoc hits of code at @head. +The project @url has @hoc_pretty (exactly @hoc) hits of code at @head.
@@ -15,4 +16,4 @@ To include the badge in your readme, use the following markdown:
[![Hits-of-Code](https://@domain/@path)](https://@domain/view/@path)-}, commit, version) +}, version_info) diff --git a/templates/p404.rs.html b/templates/p404.rs.html index 1ae929a..8189f6f 100644 --- a/templates/p404.rs.html +++ b/templates/p404.rs.html @@ -1,6 +1,7 @@ @use super::base; +@use crate::VersionInfo; -@(commit: &str, version: &str) +@(version_info: VersionInfo) @:base("Page not Found - Hits-of-Code Badges", "404 - Page not Found", {
@@ -10,4 +11,4 @@
If you think, this is a mistake on my side, please drop me a mail.
-}, commit, version) +}, version_info) diff --git a/templates/p500.rs.html b/templates/p500.rs.html index 0bdebeb..4798fca 100644 --- a/templates/p500.rs.html +++ b/templates/p500.rs.html @@ -1,6 +1,7 @@ @use super::base; +@use crate::VersionInfo; -@(commit: &str, version: &str) +@(version_info: VersionInfo) @:base("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", {@@ -10,4 +11,4 @@
If you think, this is a bug, please drop me a mail.
-}, commit, version) +}, version_info)