Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
569ce3a457 | |||
a77962732e | |||
6438bbba82 | |||
0fcafc7e4b | |||
5fd0eaf289 | |||
2236cf8b53 | |||
60cba9951f | |||
d6835b96de | |||
6d980d92be | |||
48e65fef36 | |||
514c30e13c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
repos
|
repos
|
||||||
cache
|
cache
|
||||||
|
hoc.log
|
||||||
|
780
Cargo.lock
generated
780
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
14
Cargo.toml
@ -1,24 +1,24 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.4.0"
|
version = "0.6.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-web = "1.0.0-beta.2"
|
actix-web = "1.0.0-rc"
|
||||||
badge = "0.2.0"
|
badge = "0.2.0"
|
||||||
bytes = "0.4.12"
|
bytes = "0.4.12"
|
||||||
futures = "0.1.26"
|
futures = "0.1.27"
|
||||||
git2 = "0.8.0"
|
git2 = "0.8.0"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
log = "0.4.6"
|
log = "0.4.6"
|
||||||
|
log4rs = "0.8.3"
|
||||||
number_prefix = "0.3.0"
|
number_prefix = "0.3.0"
|
||||||
openssl-probe = "0.1.2"
|
openssl-probe = "0.1.2"
|
||||||
pretty_env_logger = "0.3.0"
|
reqwest = "0.9.17"
|
||||||
reqwest = "0.9.16"
|
serde = "1.0.91"
|
||||||
serde = "1.0.90"
|
serde_derive = "1.0.91"
|
||||||
serde_derive = "1.0.90"
|
|
||||||
serde_json = "1.0.39"
|
serde_json = "1.0.39"
|
||||||
structopt = "0.2.15"
|
structopt = "0.2.15"
|
||||||
|
|
||||||
|
71
src/config.rs
Normal file
71
src/config.rs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
use crate::{error::Result, statics::OPT};
|
||||||
|
use log::LevelFilter;
|
||||||
|
use log4rs::{
|
||||||
|
append::{console::ConsoleAppender, file::FileAppender},
|
||||||
|
config::{Appender, Config, Root},
|
||||||
|
encode::pattern::PatternEncoder,
|
||||||
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
#[derive(StructOpt, Debug)]
|
||||||
|
pub(crate) struct Opt {
|
||||||
|
#[structopt(
|
||||||
|
short = "o",
|
||||||
|
long = "outdir",
|
||||||
|
parse(from_os_str),
|
||||||
|
default_value = "./repos"
|
||||||
|
)]
|
||||||
|
/// Path to store cloned repositories
|
||||||
|
pub(crate) outdir: PathBuf,
|
||||||
|
#[structopt(
|
||||||
|
short = "c",
|
||||||
|
long = "cachedir",
|
||||||
|
parse(from_os_str),
|
||||||
|
default_value = "./cache"
|
||||||
|
)]
|
||||||
|
/// Path to store cache
|
||||||
|
pub(crate) cachedir: PathBuf,
|
||||||
|
#[structopt(short = "p", long = "port", default_value = "8080")]
|
||||||
|
/// Port to listen on
|
||||||
|
pub(crate) port: u16,
|
||||||
|
#[structopt(short = "h", long = "host", default_value = "0.0.0.0")]
|
||||||
|
/// Interface to listen on
|
||||||
|
pub(crate) host: String,
|
||||||
|
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
||||||
|
/// Interface to listen on
|
||||||
|
pub(crate) domain: String,
|
||||||
|
#[structopt(short = "w", long = "workers", default_value = "4")]
|
||||||
|
/// Number of worker threads
|
||||||
|
pub(crate) workers: usize,
|
||||||
|
#[structopt(
|
||||||
|
short = "l",
|
||||||
|
long = "logfile",
|
||||||
|
parse(from_os_str),
|
||||||
|
default_value = "./hoc.log"
|
||||||
|
)]
|
||||||
|
/// The logfile
|
||||||
|
pub(crate) logfile: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn init() -> Result<()> {
|
||||||
|
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
||||||
|
// pretty_env_logger::init();
|
||||||
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
|
let stdout = ConsoleAppender::builder().build();
|
||||||
|
let file = FileAppender::builder()
|
||||||
|
.encoder(Box::new(PatternEncoder::new("{d} - {m}{n}")))
|
||||||
|
.build(&OPT.logfile)
|
||||||
|
.unwrap();
|
||||||
|
let config = Config::builder()
|
||||||
|
.appender(Appender::builder().build("stdout", Box::new(stdout)))
|
||||||
|
.appender(Appender::builder().build("file", Box::new(file)))
|
||||||
|
.build(
|
||||||
|
Root::builder()
|
||||||
|
.appender("stdout")
|
||||||
|
.appender("file")
|
||||||
|
.build(LevelFilter::Info),
|
||||||
|
)?;
|
||||||
|
log4rs::init_config(config)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
16
src/error.rs
16
src/error.rs
@ -11,6 +11,8 @@ pub(crate) enum Error {
|
|||||||
Git(git2::Error),
|
Git(git2::Error),
|
||||||
Internal,
|
Internal,
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
|
Log(log::SetLoggerError),
|
||||||
|
LogBuilder(log4rs::config::Errors),
|
||||||
Serial(serde_json::Error),
|
Serial(serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,6 +24,8 @@ impl fmt::Display for Error {
|
|||||||
Error::Git(e) => write!(fmt, "Git({})", e),
|
Error::Git(e) => write!(fmt, "Git({})", e),
|
||||||
Error::Internal => write!(fmt, "Internal Error"),
|
Error::Internal => write!(fmt, "Internal Error"),
|
||||||
Error::Io(e) => write!(fmt, "Io({})", e),
|
Error::Io(e) => write!(fmt, "Io({})", e),
|
||||||
|
Error::Log(e) => write!(fmt, "Log({})", e),
|
||||||
|
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
|
||||||
Error::Serial(e) => write!(fmt, "Serial({})", e),
|
Error::Serial(e) => write!(fmt, "Serial({})", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,6 +59,12 @@ impl From<git2::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<log::SetLoggerError> for Error {
|
||||||
|
fn from(err: log::SetLoggerError) -> Self {
|
||||||
|
Error::Log(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
fn from(err: std::io::Error) -> Self {
|
fn from(err: std::io::Error) -> Self {
|
||||||
Error::Io(err)
|
Error::Io(err)
|
||||||
@ -72,3 +82,9 @@ impl From<reqwest::Error> for Error {
|
|||||||
Error::Client(err)
|
Error::Client(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<log4rs::config::Errors> for Error {
|
||||||
|
fn from(err: log4rs::config::Errors) -> Self {
|
||||||
|
Error::LogBuilder(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
163
src/main.rs
163
src/main.rs
@ -8,13 +8,16 @@ extern crate log;
|
|||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
mod cache;
|
mod cache;
|
||||||
|
mod config;
|
||||||
mod error;
|
mod error;
|
||||||
mod service;
|
mod service;
|
||||||
|
mod statics;
|
||||||
|
|
||||||
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, INDEX, OPT, P404, P500, VERSION_INFO},
|
||||||
};
|
};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
error::ErrorBadRequest,
|
error::ErrorBadRequest,
|
||||||
@ -23,26 +26,20 @@ use actix_web::{
|
|||||||
};
|
};
|
||||||
use badge::{Badge, BadgeOptions};
|
use badge::{Badge, BadgeOptions};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::{unsync::mpsc, Stream};
|
use futures::{unsync::mpsc, Future, Stream};
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
fs::create_dir_all,
|
fs::create_dir_all,
|
||||||
path::{Path, PathBuf},
|
path::Path,
|
||||||
process::Command,
|
process::Command,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||||
|
|
||||||
pub struct VersionInfo<'a> {
|
|
||||||
pub commit: &'a str,
|
|
||||||
pub version: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct GeneratorForm<'a> {
|
struct GeneratorForm<'a> {
|
||||||
service: FormService,
|
service: FormService,
|
||||||
@ -50,71 +47,11 @@ struct GeneratorForm<'a> {
|
|||||||
repo: Cow<'a, str>,
|
repo: Cow<'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<u8> = {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
templates::index(&mut buf, VERSION_INFO, &OPT.domain).unwrap();
|
|
||||||
buf
|
|
||||||
};
|
|
||||||
static ref P404: Vec<u8> = {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
templates::p404(&mut buf, VERSION_INFO).unwrap();
|
|
||||||
buf
|
|
||||||
};
|
|
||||||
static ref P500: Vec<u8> = {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
templates::p500(&mut buf, VERSION_INFO).unwrap();
|
|
||||||
buf
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
repos: String,
|
repos: String,
|
||||||
cache: String,
|
cache: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSS: &str = include_str!("../static/tacit-css.min.css");
|
|
||||||
const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
|
||||||
struct Opt {
|
|
||||||
#[structopt(
|
|
||||||
short = "o",
|
|
||||||
long = "outdir",
|
|
||||||
parse(from_os_str),
|
|
||||||
default_value = "./repos"
|
|
||||||
)]
|
|
||||||
/// Path to store cloned repositories
|
|
||||||
outdir: PathBuf,
|
|
||||||
#[structopt(
|
|
||||||
short = "c",
|
|
||||||
long = "cachedir",
|
|
||||||
parse(from_os_str),
|
|
||||||
default_value = "./cache"
|
|
||||||
)]
|
|
||||||
/// Path to store cache
|
|
||||||
cachedir: PathBuf,
|
|
||||||
#[structopt(short = "p", long = "port", default_value = "8080")]
|
|
||||||
/// Port to listen on
|
|
||||||
port: u16,
|
|
||||||
#[structopt(short = "h", long = "host", default_value = "0.0.0.0")]
|
|
||||||
/// Interface to listen on
|
|
||||||
host: String,
|
|
||||||
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
|
||||||
/// Interface to listen on
|
|
||||||
domain: String,
|
|
||||||
#[structopt(short = "w", long = "workers", default_value = "4")]
|
|
||||||
/// Number of worker threads
|
|
||||||
workers: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||||
let repo = Repository::open_bare(path)?;
|
let repo = Repository::open_bare(path)?;
|
||||||
let mut origin = repo.find_remote("origin")?;
|
let mut origin = repo.find_remote("origin")?;
|
||||||
@ -204,7 +141,7 @@ fn handle_hoc_request<T, F>(
|
|||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
mapper: F,
|
mapper: F,
|
||||||
) -> Result<HttpResponse>
|
) -> impl Future<Item = HttpResponse, Error = Error>
|
||||||
where
|
where
|
||||||
T: Service,
|
T: Service,
|
||||||
F: Fn(HocResult) -> Result<HttpResponse>,
|
F: Fn(HocResult) -> Result<HttpResponse>,
|
||||||
@ -215,43 +152,45 @@ where
|
|||||||
fn hoc_request<T: Service>(
|
fn hoc_request<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
) -> Result<HocResult> {
|
) -> impl Future<Item = HocResult, Error = Error> {
|
||||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
futures::future::result(Ok(())).and_then(move |_| {
|
||||||
let service_path = format!("{}/{}", T::domain(), repo);
|
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||||
let path = format!("{}/{}", state.repos, service_path);
|
let service_path = format!("{}/{}", T::domain(), repo);
|
||||||
let file = Path::new(&path);
|
let path = format!("{}/{}", state.repos, service_path);
|
||||||
let url = format!("https://{}", service_path);
|
let file = Path::new(&path);
|
||||||
if !file.exists() {
|
let url = format!("https://{}", service_path);
|
||||||
if !remote_exists(&url)? {
|
if !file.exists() {
|
||||||
warn!("Repository does not exist: {}", url);
|
if !remote_exists(&url)? {
|
||||||
return Ok(HocResult::NotFound);
|
warn!("Repository does not exist: {}", url);
|
||||||
|
return Ok(HocResult::NotFound);
|
||||||
|
}
|
||||||
|
info!("Cloning {} for the first time", url);
|
||||||
|
create_dir_all(file)?;
|
||||||
|
let repo = Repository::init_bare(file)?;
|
||||||
|
repo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*")?;
|
||||||
|
repo.remote_set_url("origin", &url)?;
|
||||||
}
|
}
|
||||||
info!("Cloning {} for the first time", url);
|
pull(&path)?;
|
||||||
create_dir_all(file)?;
|
let (hoc, head) = hoc(&service_path, &state.repos, &state.cache)?;
|
||||||
let repo = Repository::init_bare(file)?;
|
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||||
repo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*")?;
|
Standalone(hoc) => hoc.to_string(),
|
||||||
repo.remote_set_url("origin", &url)?;
|
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
||||||
}
|
};
|
||||||
pull(&path)?;
|
Ok(HocResult::Hoc {
|
||||||
let (hoc, head) = hoc(&service_path, &state.repos, &state.cache)?;
|
hoc,
|
||||||
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
hoc_pretty,
|
||||||
Standalone(hoc) => hoc.to_string(),
|
head,
|
||||||
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
url,
|
||||||
};
|
repo,
|
||||||
Ok(HocResult::Hoc {
|
service_path,
|
||||||
hoc,
|
})
|
||||||
hoc_pretty,
|
|
||||||
head,
|
|
||||||
url,
|
|
||||||
repo,
|
|
||||||
service_path,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_hoc<T: Service>(
|
fn calculate_hoc<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
) -> Result<HttpResponse> {
|
) -> impl Future<Item = HttpResponse, Error = Error> {
|
||||||
let mapper = |r| match r {
|
let mapper = |r| match r {
|
||||||
HocResult::NotFound => Ok(p404()),
|
HocResult::NotFound => Ok(p404()),
|
||||||
HocResult::Hoc { hoc_pretty, .. } => {
|
HocResult::Hoc { hoc_pretty, .. } => {
|
||||||
@ -284,7 +223,7 @@ fn calculate_hoc<T: Service>(
|
|||||||
fn overview<T: Service>(
|
fn overview<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
) -> Result<HttpResponse> {
|
) -> impl Future<Item = HttpResponse, Error = Error> {
|
||||||
let mapper = |r| match r {
|
let mapper = |r| match r {
|
||||||
HocResult::NotFound => Ok(p404()),
|
HocResult::NotFound => Ok(p404()),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
@ -362,16 +301,14 @@ fn favicon32() -> HttpResponse {
|
|||||||
HttpResponse::Ok().content_type("image/png").body(FAVICON)
|
HttpResponse::Ok().content_type("image/png").body(FAVICON)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> Result<()> {
|
||||||
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
config::init()?;
|
||||||
pretty_env_logger::init();
|
|
||||||
openssl_probe::init_ssl_cert_env_vars();
|
|
||||||
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.outdir.display().to_string(),
|
||||||
cache: OPT.cachedir.display().to_string(),
|
cache: OPT.cachedir.display().to_string(),
|
||||||
});
|
});
|
||||||
HttpServer::new(move || {
|
Ok(HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.data(state.clone())
|
.data(state.clone())
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
@ -379,15 +316,15 @@ fn main() -> std::io::Result<()> {
|
|||||||
.service(css)
|
.service(css)
|
||||||
.service(favicon32)
|
.service(favicon32)
|
||||||
.service(generate)
|
.service(generate)
|
||||||
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
.service(web::resource("/github/{user}/{repo}").to_async(calculate_hoc::<GitHub>))
|
||||||
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
.service(web::resource("/gitlab/{user}/{repo}").to_async(calculate_hoc::<Gitlab>))
|
||||||
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
.service(web::resource("/bitbucket/{user}/{repo}").to_async(calculate_hoc::<Bitbucket>))
|
||||||
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
.service(web::resource("/view/github/{user}/{repo}").to_async(overview::<GitHub>))
|
||||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
.service(web::resource("/view/gitlab/{user}/{repo}").to_async(overview::<Gitlab>))
|
||||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
.service(web::resource("/view/bitbucket/{user}/{repo}").to_async(overview::<Bitbucket>))
|
||||||
.default_service(web::resource("").route(web::get().to(p404)))
|
.default_service(web::resource("").route(web::get().to_async(p404)))
|
||||||
})
|
})
|
||||||
.workers(OPT.workers)
|
.workers(OPT.workers)
|
||||||
.bind(interface)?
|
.bind(interface)?
|
||||||
.run()
|
.run()?)
|
||||||
}
|
}
|
||||||
|
34
src/statics.rs
Normal file
34
src/statics.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use crate::{config::Opt, templates};
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
pub struct VersionInfo<'a> {
|
||||||
|
pub commit: &'a str,
|
||||||
|
pub version: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
||||||
|
commit: env!("VERGEN_SHA_SHORT"),
|
||||||
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
|
};
|
||||||
|
pub(crate) const CSS: &str = include_str!("../static/tacit-css.min.css");
|
||||||
|
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub(crate) static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
||||||
|
pub(crate) static ref OPT: Opt = Opt::from_args();
|
||||||
|
pub(crate) static ref INDEX: Vec<u8> = {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
templates::index(&mut buf, VERSION_INFO, &OPT.domain).unwrap();
|
||||||
|
buf
|
||||||
|
};
|
||||||
|
pub(crate) static ref P404: Vec<u8> = {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
templates::p404(&mut buf, VERSION_INFO).unwrap();
|
||||||
|
buf
|
||||||
|
};
|
||||||
|
pub(crate) static ref P500: Vec<u8> = {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
templates::p500(&mut buf, VERSION_INFO).unwrap();
|
||||||
|
buf
|
||||||
|
};
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 682 B After Width: | Height: | Size: 983 B |
@ -1,4 +1,4 @@
|
|||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(title: &str, header: &str, content: Content, version_info: VersionInfo)
|
@(title: &str, header: &str, content: Content, version_info: VersionInfo)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, domain: &str, url: &str, service: &str, path: &str)
|
@(version_info: VersionInfo, domain: &str, url: &str, service: &str, path: &str)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, domain: &str)
|
@(version_info: VersionInfo, domain: &str)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str)
|
@(version_info: VersionInfo, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo)
|
@(version_info: VersionInfo)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo)
|
@(version_info: VersionInfo)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user