Reduce number of parameters
Some checks are pending
continuous-integration/drone/push Build is pending
Some checks are pending
continuous-integration/drone/push Build is pending
This commit is contained in:
parent
9991f6c545
commit
bbf5bba490
30
src/main.rs
30
src/main.rs
@ -15,12 +15,14 @@ mod count;
|
|||||||
mod error;
|
mod error;
|
||||||
mod service;
|
mod service;
|
||||||
mod statics;
|
mod statics;
|
||||||
|
mod template;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cache::CacheState,
|
cache::CacheState,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
||||||
statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO},
|
statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO},
|
||||||
|
template::RepoInfo,
|
||||||
};
|
};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
error::ErrorBadRequest,
|
error::ErrorBadRequest,
|
||||||
@ -271,18 +273,30 @@ fn overview<T: Service>(
|
|||||||
service_path,
|
service_path,
|
||||||
} => {
|
} => {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
let repo_info = RepoInfo {
|
||||||
|
commit_url:
|
||||||
|
&T::commit_url(&repo, &head),
|
||||||
|
commits,
|
||||||
|
domain: &OPT.domain,
|
||||||
|
head: &head,
|
||||||
|
hoc,
|
||||||
|
hoc_pretty: &hoc_pretty,
|
||||||
|
path: &service_path,
|
||||||
|
url: &url,
|
||||||
|
};
|
||||||
templates::overview(
|
templates::overview(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
REPO_COUNT.load(Ordering::Relaxed),
|
REPO_COUNT.load(Ordering::Relaxed),
|
||||||
&OPT.domain,
|
repo_info
|
||||||
&service_path,
|
// &OPT.domain,
|
||||||
&url,
|
// &service_path,
|
||||||
hoc,
|
// &url,
|
||||||
&hoc_pretty,
|
// hoc,
|
||||||
&head,
|
// &hoc_pretty,
|
||||||
&T::commit_url(&repo, &head),
|
// &head,
|
||||||
commits,
|
// &T::commit_url(&repo, &head),
|
||||||
|
// commits,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (tx, rx_body) = mpsc::unbounded();
|
let (tx, rx_body) = mpsc::unbounded();
|
||||||
|
10
src/template.rs
Normal file
10
src/template.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
pub struct RepoInfo<'a> {
|
||||||
|
pub commit_url: &'a str,
|
||||||
|
pub commits: u64,
|
||||||
|
pub domain: &'a str,
|
||||||
|
pub head: &'a str,
|
||||||
|
pub hoc: u64,
|
||||||
|
pub hoc_pretty: &'a str,
|
||||||
|
pub path: &'a str,
|
||||||
|
pub url: &'a str,
|
||||||
|
}
|
@ -1,13 +1,16 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
@use crate::template::RepoInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str, commits: u64)
|
@(version_info: VersionInfo, repo_count: usize, repo_info: RepoInfo)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Overview", {
|
@:base("Hits-of-Code Badges", "Overview", {
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The project <a href="@url">@url</a> has <strong>@hoc_pretty</strong> (exactly @hoc) hits of code at
|
The project <a href="@repo_info.url">@repo_info.url</a> has
|
||||||
<a href="@commit_url">@head</a>. The repository contains <strong>@commits</strong> commits.
|
<strong>@repo_info.hoc_pretty</strong> (exactly @repo_info.hoc) hits of code at
|
||||||
|
<a href="@repo_info.commit_url">@repo_info.head</a>. The repository contains
|
||||||
|
<strong>@repo_info.commits</strong> commits.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -15,6 +18,6 @@ To include the badge in your readme, use the following markdown:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[![Hits-of-Code](https://@domain/@path)](https://@domain/view/@path)
|
[![Hits-of-Code](https://@repo_info.domain/@repo_info.path)](https://@repo_info.domain/view/@repo_info.path)
|
||||||
</pre>
|
</pre>
|
||||||
}, version_info, repo_count)
|
}, version_info, repo_count)
|
||||||
|
Loading…
Reference in New Issue
Block a user