Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
5284249acf | |||
d28f56dac0 | |||
ab02a45bf6 | |||
837c1c160b | |||
3d26823425 | |||
d9553871fa | |||
d2bc9c2149 | |||
b0b97653a9 | |||
0b1bc60790 | |||
e93588a6d9 | |||
cd5046a276 | |||
919348d49d | |||
8378b0b51b | |||
0394ae52e9 | |||
fb34f6bf2f | |||
36622ad322 | |||
89bb27e137 | |||
7d4385764c | |||
5df97f0e64 | |||
a3d98a326e | |||
76bf5f2f98 | |||
e827d2ef39 | |||
65576140ce | |||
cea54cf2f3 | |||
8c28c68c17 | |||
b86a080ead | |||
1b0c959a8d | |||
806baf7460 | |||
080f7379ea | |||
7409de5dba | |||
07f4ef518a | |||
820ebdd899 | |||
527d793914 | |||
7df6c3fc75 | |||
17e1af1dd7 | |||
baade8fbc2 | |||
cfc07664fc | |||
52938c9106 | |||
b64f573a38 | |||
ebbd1ea8cb | |||
93a0147a78 | |||
2040e718d7 | |||
5679f67de0 | |||
8babdb978e | |||
b3388912c2 | |||
bce511ce0b | |||
50e36769d1 | |||
9477338331 | |||
c1d0930354 | |||
688067e5c5 | |||
529f36dc40 | |||
d8fdabfca6 | |||
8060b80ae6 | |||
15965c5b5f | |||
1eade03b63 | |||
f41fbc8baf | |||
14cd21dc1c | |||
1bdee4ee36 | |||
9e33742d81 | |||
8e78d13443 | |||
391fa39470 | |||
e6e90214e2 | |||
6f734b103a | |||
413bb824e1 | |||
58ad13dbad |
7
.env.example
Normal file
7
.env.example
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
HOC_REPODIR='./repos'
|
||||||
|
HOC_CACHEDIR='./cache'
|
||||||
|
HOC_PORT=8080
|
||||||
|
HOC_HOST='0.0.0.0'
|
||||||
|
HOC_WORKERS=4
|
||||||
|
|
||||||
|
HOC_BASE_URL='http://0.0.0.0:8080'
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ repos
|
|||||||
cache
|
cache
|
||||||
hoc.log
|
hoc.log
|
||||||
result
|
result
|
||||||
|
hoc.toml
|
||||||
|
.env
|
||||||
|
1423
Cargo.lock
generated
1423
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
31
Cargo.toml
31
Cargo.toml
@ -1,33 +1,34 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.14.5"
|
version = "0.17.0"
|
||||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "1.1.1"
|
actix-rt = "1.1.1"
|
||||||
actix-web = "3.2.0"
|
actix-web = "3.3.2"
|
||||||
badge = "0.3.0"
|
badge = "0.3.0"
|
||||||
bytes = "0.6.0"
|
bytes = "1.0.1"
|
||||||
futures = "0.3.8"
|
config = { version = "0.10.1", features = ["toml"] }
|
||||||
git2 = "0.13.12"
|
dotenv = "0.15.0"
|
||||||
|
futures = "0.3.13"
|
||||||
|
git2 = "0.13.17"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
number_prefix = "0.4.0"
|
number_prefix = "0.4.0"
|
||||||
openssl-probe = "0.1.2"
|
openssl-probe = "0.1.2"
|
||||||
reqwest = "0.10.9"
|
reqwest = "0.10.10"
|
||||||
serde = "1.0.117"
|
serde = "1.0.123"
|
||||||
serde_derive = "1.0.103"
|
serde_derive = "1.0.123"
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.63"
|
||||||
structopt = "0.3.20"
|
tracing = "0.1.25"
|
||||||
tracing = "0.1.21"
|
|
||||||
tracing-subscriber = "0.2.15"
|
|
||||||
tracing-actix-web = "0.2.1"
|
tracing-actix-web = "0.2.1"
|
||||||
tracing-futures = "0.2.4"
|
tracing-futures = "0.2.5"
|
||||||
|
tracing-subscriber = "0.2.16"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = "0.13.0"
|
ructe = "0.13.0"
|
||||||
vergen = "3.1.0"
|
vergen = { version = "4.1.0", default-features = false, features = ["git"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.2.0"
|
||||||
|
26
README.md
26
README.md
@ -1,6 +1,6 @@
|
|||||||
# Hits-of-Code
|
# Hits-of-Code
|
||||||
|
|
||||||
[](https://hitsofcode.com/view/github/vbrandl/hoc)
|
[](https://hitsofcode.com/github/vbrandl/hoc/view)
|
||||||
[](https://drone.vbrandl.net/vbrandl/hoc)
|
[](https://drone.vbrandl.net/vbrandl/hoc)
|
||||||
[](https://gitlab.com/vbrandl/hoc/pipelines)
|
[](https://gitlab.com/vbrandl/hoc/pipelines)
|
||||||
[](https://deps.rs/repo/github/vbrandl/hoc)
|
[](https://deps.rs/repo/github/vbrandl/hoc)
|
||||||
@ -26,7 +26,7 @@ where `<service>` is one of `gitub`, `gitlab` or `bitbucket`. The HoC data can a
|
|||||||
https://<host>/<service>/<user>/<repo>/json
|
https://<host>/<service>/<user>/<repo>/json
|
||||||
```
|
```
|
||||||
|
|
||||||
There is also an overview page available via `https://<host>/view/<service>/<user>/<repo>`
|
There is also an overview page available via `https://<host>/<service>/<user>/<repo>/view`
|
||||||
|
|
||||||
To delete a repository and the cache from the server, send a `POST` request to
|
To delete a repository and the cache from the server, send a `POST` request to
|
||||||
`https://<host>/<service>/<user>/<repo>/delete`. On the overview page, there is a button to perform this operation. It
|
`https://<host>/<service>/<user>/<repo>/delete`. On the overview page, there is a button to perform this operation. It
|
||||||
@ -48,21 +48,29 @@ $ docker build .
|
|||||||
|
|
||||||
inside the repository.
|
inside the repository.
|
||||||
|
|
||||||
I'm currently working on migrating to [nix](https://nixos.org/nix). To get a
|
I'm currently working on migrating to [nix](https://nixos.org/nix). To get a development shell, run `nix-shell`, to
|
||||||
development shell, run `nix-shell`, to build the package run `nix-build --attr
|
build the package run `nix-build --attr package` and to build the Docker image, run `nix-build --attr dockerImage`.
|
||||||
package` and to build the Docker image, run `nix-build --attr dockerImage`.
|
|
||||||
|
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
Run either the binary produced by cargo, the Docker container you just built (using docker-compose) or pull the image
|
Rename [`hoc.toml.example`](./hoc.toml.example) to `hoc.toml` or [`.env.example`](./.env.example) to `.env` and set the
|
||||||
from [Docker Hub](https://hub.docker.com/r/vbrandl/hits-of-code)
|
correct value for `base_url`/`HOC_BASE_URL`. If you don't want to use a configuration or dotenv file, you can pass all
|
||||||
|
parameters directly via environment variables. For variable names see [`.env.example`](./.env.example).
|
||||||
|
|
||||||
|
To start a local instance of the service just run:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ docker run -it --rm vbrandl/hits-of-code --help
|
$ HOC_BASE_URL='http://0.0.0.0:8080' ./hoc
|
||||||
```
|
```
|
||||||
|
|
||||||
When running the binary directly, you need a git binary in your `PATH`.
|
You can also use the Docker image:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker run -p 8080:8080 --env HOC_BASE_URL='http://0.0.0.0:8080' -it --rm vbrandl/hits-of-code
|
||||||
|
```
|
||||||
|
|
||||||
|
When running the binary directly, you need a `git` binary in your `PATH`.
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
4
build.rs
4
build.rs
@ -2,11 +2,11 @@ extern crate ructe;
|
|||||||
extern crate vergen;
|
extern crate vergen;
|
||||||
|
|
||||||
use ructe::Ructe;
|
use ructe::Ructe;
|
||||||
use vergen::{generate_cargo_keys, ConstantsFlags};
|
use vergen::{gen, ConstantsFlags};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let flags = ConstantsFlags::SHA_SHORT;
|
let flags = ConstantsFlags::SHA_SHORT;
|
||||||
generate_cargo_keys(flags).expect("Unable to generate the cargo keys!");
|
gen(flags).expect("Unable to generate the cargo keys!");
|
||||||
Ructe::from_env()
|
Ructe::from_env()
|
||||||
.expect("ructe")
|
.expect("ructe")
|
||||||
.compile_templates("templates")
|
.compile_templates("templates")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: "2"
|
version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
hoc:
|
hoc:
|
||||||
@ -9,3 +9,5 @@ services:
|
|||||||
# ports:
|
# ports:
|
||||||
# - "127.0.0.1:8080:8080"
|
# - "127.0.0.1:8080:8080"
|
||||||
restart: always
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- ./.env
|
||||||
|
15
hoc.toml.example
Normal file
15
hoc.toml.example
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# every parameter can also be set (or overwritten) by passing an environment
|
||||||
|
# variable namend `HOC_<PARAMETERNAME>`, e.g.
|
||||||
|
# `HOC_BASE_URL='https://hitsofcode.com' ./hoc`
|
||||||
|
|
||||||
|
# these config parameters have default values and must not explicitly be set
|
||||||
|
repodir = "./repos"
|
||||||
|
cachedir = "./cache"
|
||||||
|
port = 8080
|
||||||
|
host = "0.0.0.0"
|
||||||
|
workers = 4
|
||||||
|
|
||||||
|
# these parameters don't have default values and must be set
|
||||||
|
|
||||||
|
# this should be the public base URL of the service, e.g. `https://hitsofcode.com`
|
||||||
|
base_url = "http://0.0.0.0:8080"
|
@ -1,41 +1,41 @@
|
|||||||
|
use config::{Config, ConfigError, Environment, File};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub(crate) struct Opt {
|
pub struct Settings {
|
||||||
#[structopt(
|
|
||||||
short = "o",
|
|
||||||
long = "outdir",
|
|
||||||
parse(from_os_str),
|
|
||||||
default_value = "./repos"
|
|
||||||
)]
|
|
||||||
/// Path to store cloned repositories
|
/// Path to store cloned repositories
|
||||||
pub(crate) outdir: PathBuf,
|
pub repodir: PathBuf,
|
||||||
#[structopt(
|
|
||||||
short = "c",
|
|
||||||
long = "cachedir",
|
|
||||||
parse(from_os_str),
|
|
||||||
default_value = "./cache"
|
|
||||||
)]
|
|
||||||
/// Path to store cache
|
/// Path to store cache
|
||||||
pub(crate) cachedir: PathBuf,
|
pub cachedir: PathBuf,
|
||||||
#[structopt(short = "p", long = "port", default_value = "8080")]
|
|
||||||
/// Port to listen on
|
/// Port to listen on
|
||||||
pub(crate) port: u16,
|
pub port: u16,
|
||||||
#[structopt(short = "h", long = "host", default_value = "0.0.0.0")]
|
|
||||||
/// Interface to listen on
|
/// Interface to listen on
|
||||||
pub(crate) host: String,
|
pub host: String,
|
||||||
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
/// Base URL
|
||||||
/// Interface to listen on
|
pub base_url: String,
|
||||||
pub(crate) domain: String,
|
|
||||||
#[structopt(short = "w", long = "workers", default_value = "4")]
|
|
||||||
/// Number of worker threads
|
/// Number of worker threads
|
||||||
pub(crate) workers: usize,
|
pub workers: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn init() {
|
pub(crate) fn init() {
|
||||||
|
dotenv::dotenv().ok();
|
||||||
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
||||||
openssl_probe::init_ssl_cert_env_vars();
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
|
|
||||||
tracing_subscriber::fmt().init();
|
tracing_subscriber::fmt().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Settings {
|
||||||
|
pub fn new() -> Result<Self, ConfigError> {
|
||||||
|
let mut config = Config::new();
|
||||||
|
config
|
||||||
|
.merge(File::with_name("hoc.toml").required(false))?
|
||||||
|
.merge(Environment::with_prefix("hoc"))?
|
||||||
|
.set_default("repodir", "./repos")?
|
||||||
|
.set_default("cachedir", "./cache")?
|
||||||
|
.set_default("workers", 4)?
|
||||||
|
.set_default("port", 8080)?
|
||||||
|
.set_default("host", "0.0.0.0")?;
|
||||||
|
config.try_into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -215,7 +215,7 @@ where
|
|||||||
Ok(HttpResponse::TemporaryRedirect()
|
Ok(HttpResponse::TemporaryRedirect()
|
||||||
.header(
|
.header(
|
||||||
LOCATION,
|
LOCATION,
|
||||||
format!("/view/{}/{}/{}", T::url_path(), data.0, data.1),
|
format!("/{}/{}/{}/view", T::url_path(), data.0, data.1),
|
||||||
)
|
)
|
||||||
.finish())
|
.finish())
|
||||||
};
|
};
|
||||||
@ -371,7 +371,7 @@ async fn overview<T: Service>(
|
|||||||
let repo_info = RepoInfo {
|
let repo_info = RepoInfo {
|
||||||
commit_url: &T::commit_url(&repo, &head),
|
commit_url: &T::commit_url(&repo, &head),
|
||||||
commits,
|
commits,
|
||||||
domain: &OPT.domain,
|
base_url: &OPT.base_url,
|
||||||
head: &head,
|
head: &head,
|
||||||
hoc,
|
hoc,
|
||||||
hoc_pretty: &hoc_pretty,
|
hoc_pretty: &hoc_pretty,
|
||||||
@ -399,7 +399,7 @@ async fn index() -> Result<HttpResponse> {
|
|||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
REPO_COUNT.load(Ordering::Relaxed),
|
REPO_COUNT.load(Ordering::Relaxed),
|
||||||
&OPT.domain,
|
&OPT.base_url,
|
||||||
)?;
|
)?;
|
||||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ async fn generate(params: web::Form<GeneratorForm<'_>>) -> Result<HttpResponse>
|
|||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
REPO_COUNT.load(Ordering::Relaxed),
|
REPO_COUNT.load(Ordering::Relaxed),
|
||||||
&OPT.domain,
|
&OPT.base_url,
|
||||||
params.service.url(),
|
params.service.url(),
|
||||||
params.service.service(),
|
params.service.service(),
|
||||||
&repo,
|
&repo,
|
||||||
@ -442,7 +442,7 @@ fn favicon32() -> HttpResponse {
|
|||||||
async fn start_server() -> std::io::Result<()> {
|
async fn start_server() -> std::io::Result<()> {
|
||||||
let interface = format!("{}:{}", OPT.host, OPT.port);
|
let interface = format!("{}:{}", OPT.host, OPT.port);
|
||||||
let state = Arc::new(State {
|
let state = Arc::new(State {
|
||||||
repos: OPT.outdir.display().to_string(),
|
repos: OPT.repodir.display().to_string(),
|
||||||
cache: OPT.cachedir.display().to_string(),
|
cache: OPT.cachedir.display().to_string(),
|
||||||
});
|
});
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
@ -475,6 +475,9 @@ async fn start_server() -> std::io::Result<()> {
|
|||||||
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
||||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
||||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
||||||
|
.service(web::resource("/github/{user}/{repo}/view").to(overview::<GitHub>))
|
||||||
|
.service(web::resource("/gitlab/{user}/{repo}/view").to(overview::<Gitlab>))
|
||||||
|
.service(web::resource("/bitbucket/{user}/{repo}/view").to(overview::<Bitbucket>))
|
||||||
.default_service(web::resource("").route(web::get().to(async_p404)))
|
.default_service(web::resource("").route(web::get().to(async_p404)))
|
||||||
})
|
})
|
||||||
.workers(OPT.workers)
|
.workers(OPT.workers)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::{config::Opt, count::count_repositories};
|
use crate::{config::Settings, count::count_repositories};
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
pub struct VersionInfo<'a> {
|
pub struct VersionInfo<'a> {
|
||||||
pub commit: &'a str,
|
pub commit: &'a str,
|
||||||
@ -8,7 +7,7 @@ pub struct VersionInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
||||||
commit: env!("VERGEN_SHA_SHORT"),
|
commit: env!("VERGEN_GIT_SHA_SHORT"),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
};
|
};
|
||||||
pub(crate) const CSS: &str = include_str!("../static/tacit-css.min.css");
|
pub(crate) const CSS: &str = include_str!("../static/tacit-css.min.css");
|
||||||
@ -16,7 +15,7 @@ pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub(crate) static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
pub(crate) static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
||||||
pub(crate) static ref OPT: Opt = Opt::from_args();
|
pub(crate) static ref OPT: Settings = Settings::new().unwrap();
|
||||||
pub(crate) static ref REPO_COUNT: AtomicUsize =
|
pub(crate) static ref REPO_COUNT: AtomicUsize =
|
||||||
AtomicUsize::new(count_repositories(&OPT.outdir).unwrap());
|
AtomicUsize::new(count_repositories(&OPT.repodir).unwrap());
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub struct RepoInfo<'a> {
|
pub struct RepoInfo<'a> {
|
||||||
pub commit_url: &'a str,
|
pub commit_url: &'a str,
|
||||||
pub commits: u64,
|
pub commits: u64,
|
||||||
pub domain: &'a str,
|
pub base_url: &'a str,
|
||||||
pub head: &'a str,
|
pub head: &'a str,
|
||||||
pub hoc: u64,
|
pub hoc: u64,
|
||||||
pub hoc_pretty: &'a str,
|
pub hoc_pretty: &'a str,
|
||||||
|
@ -37,7 +37,9 @@ macro_rules! test_service {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_index() {
|
async fn test_index() {
|
||||||
let mut app = test::init_service(App::new().service(index)).await;
|
std::env::set_var("HOC_BASE_URL", "http://0.0.0.0:8080");
|
||||||
|
|
||||||
|
let mut app = test_app!(index);
|
||||||
|
|
||||||
let req = dbg!(test::TestRequest::with_uri("/").to_request());
|
let req = dbg!(test::TestRequest::with_uri("/").to_request());
|
||||||
let resp = dbg!(test::call_service(&mut app, req).await);
|
let resp = dbg!(test::call_service(&mut app, req).await);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize, domain: &str, url: &str, service: &str, path: &str)
|
@(version_info: VersionInfo, repo_count: usize, base_url: &str, url: &str, service: &str, path: &str)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Badge Generator", {
|
@:base("Hits-of-Code Badges", "Badge Generator", {
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ Here is the markdown for the badge for <a href="https://@url/@path">@url/@path</
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[](https://@domain/view/@service/@path)
|
[](@base_url/@service/@path/view)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -18,6 +18,6 @@ It will be rendered like this
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<a href="https://@domain/view/@service/@path"><img src="https://@domain/@service/@path" alt="example badge" /></a>
|
<a href="@base_url/@service/@path/view"><img src="@base_url/@service/@path" alt="example badge" /></a>
|
||||||
</pre>
|
</pre>
|
||||||
}, version_info, repo_count)
|
}, version_info, repo_count)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize, domain: &str)
|
@(version_info: VersionInfo, repo_count: usize, base_url: &str)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ used for GitHub, GitLab and Bitbucket repositories. Just put the following code
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[](https://@domain/view/<service>/<user>/<repo>)
|
[](@base_url/<service>/<user>/<repo>/view)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -33,7 +33,7 @@ following Markdown
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[](https://@domain/view/github/vbrandl/hoc)
|
[](@base_url/github/vbrandl/hoc/view)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -41,7 +41,7 @@ would render this badge:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<a href="https://@domain/view/github/vbrandl/hoc"><img src="https://@domain/github/vbrandl/hoc"
|
<a href="@base_url/github/vbrandl/hoc/view"><img src="@base_url/github/vbrandl/hoc"
|
||||||
alt="example badge" /></a>
|
alt="example badge" /></a>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ in your repository or you want a badge for another branch of your repository, ju
|
|||||||
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON object
|
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
|
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
|
<code>head</code> (the commit ref of HEAD). Requesting <a
|
||||||
href="https://@domain/github/vbrandl/hoc/json">https://@domain/github/vbrandl/hoc/json</a> might return something along
|
href="@base_url/github/vbrandl/hoc/json">@base_url/github/vbrandl/hoc/json</a> might return something along
|
||||||
the lines of
|
the lines of
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ To include the badge in your readme, use the following markdown:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[](https://@repo_info.domain/view/@repo_info.path?branch=@repo_info.branch)
|
[](@repo_info.base_url/@repo_info.path?branch=@repo_info.branch/view?branch=@repo_info.branch)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user