Compare commits
196 Commits
chore/upda
...
v0.22.1
Author | SHA1 | Date | |
---|---|---|---|
a4974b136b | |||
c3fe019cf1 | |||
c5fbe731aa | |||
6c14a60f7e | |||
90e801507c | |||
ed42395070 | |||
470bc028f1 | |||
d869657105 | |||
4148b8e460 | |||
b4c4add0fc | |||
fbaea42d11 | |||
659c531640 | |||
5222e5bf27 | |||
7758066eff | |||
ab4519afbb | |||
0714f56d57 | |||
663af56fcc | |||
d92860e825 | |||
6ac19fe898 | |||
75fd905547 | |||
3df814c64c | |||
84f4aa9be3 | |||
0a518ab331 | |||
5caed6729a | |||
7846872aaa | |||
54e05d5d78 | |||
7c84ae8c0e | |||
256823ff11 | |||
00db6b1718 | |||
f914537eb2 | |||
5f29a3edfa | |||
c4b14164c0 | |||
8f129d9175 | |||
3830d488b8 | |||
7b5ed9ebae | |||
1b504c4557 | |||
7d2a9047c3 | |||
1e5db2ca2a | |||
35e8eac61a | |||
e7553c37d4 | |||
cc6233cb63 | |||
16743bbc26 | |||
ac479aa53d | |||
2ca188a473 | |||
2cf454e559 | |||
690ab9ea07 | |||
8f656f5252 | |||
7a61acf5e2 | |||
171d6f590b | |||
d63aaee2d3 | |||
e453c7aa25 | |||
99d386900e | |||
c2fb288a07 | |||
7a9def97cb | |||
815b213a2a | |||
1e44bc1a8f | |||
2507c24de7 | |||
d78b349ca1 | |||
4b37c8073f | |||
f2436efc85 | |||
80a6cf0036 | |||
a0ec86e756 | |||
d91e6bf580 | |||
f3e1d914c5 | |||
e282316769 | |||
9742900eb6 | |||
45a582dcdd | |||
b5a8500e0c | |||
87f70285c6 | |||
b76d50554c | |||
d9bd880d51 | |||
f13b823717 | |||
2b69a6ee8c | |||
e083a091c3 | |||
ebd0c7df7d | |||
be2825ad1f | |||
78a640f972 | |||
214e9b6a50 | |||
878b5a5565 | |||
ab18c03983 | |||
7a7a93ff75 | |||
78fb8d9b83 | |||
e8c9e4ca15 | |||
e1bcde073d | |||
e57d40e766 | |||
21f3790aee | |||
95213c3ded | |||
23b14ea01d | |||
515791beba | |||
ed380fc28a | |||
6504159899 | |||
4269140af5 | |||
204ba89613 | |||
80861a3682 | |||
e23869da9a | |||
96896e00b7 | |||
d0cb529708 | |||
f828878ebf | |||
e887b7553e | |||
40bae1b5a3 | |||
aa12a8bc24 | |||
776e068ab5 | |||
73299a9e73 | |||
5ec1a68314 | |||
5da1be83ef | |||
44d28233e2 | |||
e6585c7500 | |||
be96d51d71 | |||
0273e22581 | |||
675c0f1941 | |||
bdca0feee2 | |||
0d8611779c | |||
3824cce2c7 | |||
13b90f6ab0 | |||
8e4f5fd519 | |||
a101f91004 | |||
1107c3dba7 | |||
ba65938817 | |||
acaf7b80e4 | |||
e5ce8dc125 | |||
ef4c4e6046 | |||
c78ca9e8f8 | |||
b4c02058b1 | |||
8e5a189a40 | |||
be58d750c1 | |||
9a2498e9db | |||
44bb3562d1 | |||
8164577120 | |||
ed2c0dad0b | |||
790e746759 | |||
ce12a3fa13 | |||
a3bcffc8a8 | |||
0ca471422a | |||
87d7e5ac5a | |||
85a5e11c54 | |||
4fc9aea280 | |||
98313c8ba6 | |||
ac9d09f992 | |||
9996ec989d | |||
d39c1830a6 | |||
9017ab3841 | |||
d226543cef | |||
dea5fa4a09 | |||
af00647cf6 | |||
47ae92091c | |||
39e6739e6e | |||
9921ddd18c | |||
379e481914 | |||
8f87af8164 | |||
2b01514f96 | |||
0a794eb22c | |||
a5445e90ec | |||
bdd25aefd6 | |||
2444b29734 | |||
d298e5ecdb | |||
3ecab29cdd | |||
c4638dc8aa | |||
7ffa2ba9a2 | |||
10f4390b75 | |||
a3b224a8df | |||
45e20edb2b | |||
db763ff817 | |||
449e1347f4 | |||
d57df16509 | |||
c1c499e003 | |||
225d652545 | |||
948f06ba33 | |||
dcd8c41bb3 | |||
0ab2c60f06 | |||
d20da8b1e3 | |||
ffd1378b44 | |||
ecce255ee2 | |||
69410f10b6 | |||
340220d4ce | |||
27fb116d26 | |||
228a1767f2 | |||
7a45bc2d2e | |||
f02b05f4e9 | |||
04b58e53a6 | |||
849ccb58d2 | |||
aeeb688be2 | |||
89b5d8cc60 | |||
19cae24133 | |||
656cc009e1 | |||
47c8229eb1 | |||
fba5070e8f | |||
732f7b0ed9 | |||
ecf34928f7 | |||
d0242e6e2e | |||
aacff0e63e | |||
d5f4304a60 | |||
622a5a335a | |||
8f16fdf33c | |||
792a1f5743 | |||
9900518d62 | |||
d37f5ba32b |
1
.cargo/audit.toml
Normal file
1
.cargo/audit.toml
Normal file
@ -0,0 +1 @@
|
||||
[advisories]
|
1349
Cargo.lock
generated
1349
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
42
Cargo.toml
42
Cargo.toml
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.18.0"
|
||||
version = "0.22.1"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
@ -13,34 +13,34 @@ path = "src/main.rs"
|
||||
name = "hoc"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "2.2.0"
|
||||
actix-web = "4.0.0-beta.8"
|
||||
actix-rt = "2.7.0"
|
||||
actix-web = "4.0.1"
|
||||
badge = "0.3.0"
|
||||
bytes = "1.1.0"
|
||||
config = { version = "0.11.0", features = ["toml"] }
|
||||
config = { version = "0.12.0", features = ["toml"] }
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3.17"
|
||||
git2 = "0.13.21"
|
||||
futures = "0.3.21"
|
||||
git2 = "0.14.1"
|
||||
lazy_static = "1.4.0"
|
||||
number_prefix = "0.4.0"
|
||||
openssl-probe = "0.1.4"
|
||||
reqwest = "0.11.4"
|
||||
serde = "1.0.130"
|
||||
serde_derive = "1.0.123"
|
||||
serde_json = "1.0.67"
|
||||
tracing = "0.1.26"
|
||||
tracing-actix-web = "0.4.0-beta.11"
|
||||
tracing-bunyan-formatter = "0.2.5"
|
||||
openssl-probe = "0.1.5"
|
||||
reqwest = "0.11.9"
|
||||
serde = "1.0.136"
|
||||
serde_derive = "1.0.136"
|
||||
serde_json = "1.0.79"
|
||||
tracing = "0.1.32"
|
||||
tracing-actix-web = "0.5.1"
|
||||
tracing-bunyan-formatter = "0.3.2"
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-log = "0.1.2"
|
||||
tracing-subscriber = { version = "0.2.20", features = ["registry", "env-filter"] }
|
||||
tracing-subscriber = { version = "0.3.9", features = ["registry", "env-filter"] }
|
||||
|
||||
[build-dependencies]
|
||||
ructe = "0.13.4"
|
||||
vergen = { version = "5.1.15", default-features = false, features = ["git"] }
|
||||
ructe = "0.14.0"
|
||||
vergen = { version = "7.0.0", default-features = false, features = ["git"] }
|
||||
|
||||
[dev-dependencies]
|
||||
awc = "3.0.0-beta.7"
|
||||
ructe = "0.13.4"
|
||||
tempfile = "3.2.0"
|
||||
tokio = "1.11.0"
|
||||
awc = "3.0.0"
|
||||
ructe = "0.14.0"
|
||||
tempfile = "3.3.0"
|
||||
tokio = "1.17.0"
|
||||
|
9
build.rs
9
build.rs
@ -1,15 +1,12 @@
|
||||
extern crate ructe;
|
||||
extern crate vergen;
|
||||
|
||||
use ructe::Ructe;
|
||||
use ructe::{Ructe, RucteError};
|
||||
use vergen::{vergen, Config, ShaKind};
|
||||
|
||||
fn main() {
|
||||
fn main() -> Result<(), RucteError> {
|
||||
let mut config = Config::default();
|
||||
*config.git_mut().sha_kind_mut() = ShaKind::Short;
|
||||
vergen(config).expect("Unable to generate static repo info");
|
||||
Ructe::from_env()
|
||||
.expect("ructe")
|
||||
.compile_templates("templates")
|
||||
.unwrap();
|
||||
Ructe::from_env()?.compile_templates("templates")
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
{}
|
56
default.nix
56
default.nix
@ -1,56 +0,0 @@
|
||||
{ sources ? import ./nix/sources.nix
|
||||
, system ? builtins.currentSystem
|
||||
}:
|
||||
|
||||
let
|
||||
rustOverlay = import "${sources.nixpkgs-mozilla}/rust-overlay.nix";
|
||||
cargo2nixOverlay = import "${sources.cargo2nix}/overlay";
|
||||
|
||||
pkgs = import sources.nixpkgs {
|
||||
# pkgs = import <nixpkgs> {
|
||||
inherit system;
|
||||
overlays = [ cargo2nixOverlay rustOverlay ];
|
||||
};
|
||||
|
||||
rustPkgs = pkgs.rustBuilder.makePackageSet' {
|
||||
rustChannel = "stable";
|
||||
packageFun = import ./Cargo.nix;
|
||||
localPatterns =
|
||||
[
|
||||
''^(src|tests)(/.*)?''
|
||||
''[^/]*\.(rs|toml)$''
|
||||
# include other directory from the project repository
|
||||
''^templates(/.*)?''
|
||||
''^static(/.*)?''
|
||||
''^.git.*(/.*)?''
|
||||
];
|
||||
# packageOverrides
|
||||
};
|
||||
in
|
||||
rec {
|
||||
inherit rustPkgs;
|
||||
shell = pkgs.mkShell {
|
||||
inputsFrom = pkgs.lib.mapAttrsToList (_: pkg: pkg { }) rustPkgs.noBuild.workspace;
|
||||
nativeBuildInputs = with rustPkgs; [ cargo rustc ];
|
||||
};
|
||||
package = (rustPkgs.workspace.hoc {}).overrideAttrs (drv: {
|
||||
buildInputs = drv.buildInputs or [ ] ++ [ pkgs.git ];
|
||||
});
|
||||
dockerImage =
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "vbrandl/hits-of-code";
|
||||
tag = package.version;
|
||||
|
||||
contents =
|
||||
[
|
||||
package
|
||||
pkgs.cacert
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
|
||||
config = {
|
||||
Cmd = [ "/bin/hoc" ];
|
||||
WorkingDir = "/home/hoc";
|
||||
};
|
||||
};
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
{
|
||||
"cargo2nix": {
|
||||
"branch": "master",
|
||||
"description": "Convert a Cargo.lock to mkRustCrate statements for import in Nix",
|
||||
"homepage": "",
|
||||
"owner": "tenx-tech",
|
||||
"repo": "cargo2nix",
|
||||
"rev": "7bc062ccffc41dc7d3759b8b797e8b4f8dd23a15",
|
||||
"sha256": "1z7xwk1hbp26aydsk3y07riy0ivwqss06n1470mvdl7allfcd1w5",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/tenx-tech/cargo2nix/archive/7bc062ccffc41dc7d3759b8b797e8b4f8dd23a15.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"niv": {
|
||||
"branch": "master",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "98c74a80934123cb4c3bf3314567f67311eb711a",
|
||||
"sha256": "1w8n54hapd4x9f1am33icvngkqns7m3hl9yair38yqq08ffwg0kn",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/98c74a80934123cb4c3bf3314567f67311eb711a.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "nixpkgs-unstable",
|
||||
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs-channels",
|
||||
"rev": "f6bfb371cba2b5a02f200c2747c1fe2c72bd782f",
|
||||
"sha256": "0y3hlbyvznrpr1d2vxj2511hkjg733wdnxfaib3fgy9i9jr8ivzn",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/f6bfb371cba2b5a02f200c2747c1fe2c72bd782f.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-mozilla": {
|
||||
"branch": "master",
|
||||
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",
|
||||
"homepage": null,
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
|
||||
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed483e980dfb4666ae0ed17845c4220e5e7c.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
134
nix/sources.nix
134
nix/sources.nix
@ -1,134 +0,0 @@
|
||||
# This file has been generated by Niv.
|
||||
|
||||
let
|
||||
|
||||
#
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
|
||||
fetch_tarball = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
||||
|
||||
fetch_builtin-tarball = spec:
|
||||
builtins.trace
|
||||
''
|
||||
WARNING:
|
||||
The niv type "builtin-tarball" will soon be deprecated. You should
|
||||
instead use `builtin = true`.
|
||||
|
||||
$ niv modify <package> -a type=tarball -a builtin=true
|
||||
''
|
||||
builtins_fetchTarball { inherit (spec) url sha256; };
|
||||
|
||||
fetch_builtin-url = spec:
|
||||
builtins.trace
|
||||
''
|
||||
WARNING:
|
||||
The niv type "builtin-url" will soon be deprecated. You should
|
||||
instead use `builtin = true`.
|
||||
|
||||
$ niv modify <package> -a type=file -a builtin=true
|
||||
''
|
||||
(builtins_fetchurl { inherit (spec) url sha256; });
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs spec
|
||||
else if spec.type == "git" then fetch_git spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url spec
|
||||
else
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = fetch config.pkgs name spec; }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig =
|
||||
{ sourcesFile ? ./sources.json
|
||||
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
@ -1 +1,8 @@
|
||||
with import ./. { }; shell
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
pkg-config
|
||||
];
|
||||
}
|
||||
|
@ -18,21 +18,16 @@ pub struct Settings {
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
#[deprecated]
|
||||
pub fn new() -> Result<Self, ConfigError> {
|
||||
Self::load()
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Self, ConfigError> {
|
||||
let mut config = Config::new();
|
||||
config
|
||||
.merge(File::with_name("hoc.toml").required(false))?
|
||||
.merge(Environment::with_prefix("hoc"))?
|
||||
Config::builder()
|
||||
.add_source(File::with_name("hoc.toml").required(false))
|
||||
.add_source(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()
|
||||
.set_default("host", "0.0.0.0")?
|
||||
.build()?
|
||||
.try_deserialize()
|
||||
}
|
||||
}
|
||||
|
49
src/lib.rs
49
src/lib.rs
@ -462,11 +462,13 @@ async fn async_p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse>
|
||||
p404(repo_count)
|
||||
}
|
||||
|
||||
fn css() -> HttpResponse {
|
||||
#[get("/tacit-css.min.css")]
|
||||
async fn css() -> HttpResponse {
|
||||
HttpResponse::Ok().content_type("text/css").body(CSS)
|
||||
}
|
||||
|
||||
fn favicon32() -> HttpResponse {
|
||||
#[get("/favicon.ico")]
|
||||
async fn favicon32() -> HttpResponse {
|
||||
HttpResponse::Ok().content_type("image/png").body(FAVICON)
|
||||
}
|
||||
|
||||
@ -477,48 +479,21 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
||||
web::Data::new(AtomicUsize::new(count::count_repositories(&settings.repodir).unwrap()));
|
||||
let state = web::Data::new(State { settings });
|
||||
Ok(HttpServer::new(move || {
|
||||
App::new()
|
||||
let app = App::new()
|
||||
.app_data(state.clone())
|
||||
.app_data(repo_count.clone())
|
||||
.wrap(tracing_actix_web::TracingLogger::default())
|
||||
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
|
||||
.service(index)
|
||||
.service(health_check)
|
||||
.service(web::resource("/tacit-css.min.css").route(web::get().to(css)))
|
||||
.service(web::resource("/favicon.ico").route(web::get().to(favicon32)))
|
||||
.service(css)
|
||||
.service(favicon32)
|
||||
.service(generate)
|
||||
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
||||
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
||||
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
||||
.service(web::resource("/sourcehut/{user}/{repo}").to(calculate_hoc::<Sourcehut>))
|
||||
.service(
|
||||
web::resource("/github/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<GitHub>)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/gitlab/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<Gitlab>)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/bitbucket/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<Bitbucket>)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/sourcehut/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<Sourcehut>)),
|
||||
)
|
||||
.service(web::resource("/github/{user}/{repo}/json").to(json_hoc::<GitHub>))
|
||||
.service(web::resource("/gitlab/{user}/{repo}/json").to(json_hoc::<Gitlab>))
|
||||
.service(web::resource("/bitbucket/{user}/{repo}/json").to(json_hoc::<Bitbucket>))
|
||||
.service(web::resource("/sourcehut/{user}/{repo}/json").to(json_hoc::<Sourcehut>))
|
||||
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
||||
.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>))
|
||||
.service(web::resource("/sourcehut/{user}/{repo}/view").to(overview::<Sourcehut>))
|
||||
.default_service(web::to(async_p404))
|
||||
.default_service(web::to(async_p404));
|
||||
let app = GitHub::register_service(app);
|
||||
let app = Gitlab::register_service(app);
|
||||
let app = Bitbucket::register_service(app);
|
||||
Sourcehut::register_service(app)
|
||||
})
|
||||
.workers(workers)
|
||||
.listen(listener)?
|
||||
|
@ -1,7 +1,31 @@
|
||||
pub(crate) trait Service {
|
||||
use crate::{calculate_hoc, delete_repo_and_cache, json_hoc, overview};
|
||||
|
||||
use actix_web::{
|
||||
dev::{ServiceFactory, ServiceRequest},
|
||||
web, App,
|
||||
};
|
||||
|
||||
pub(crate) trait Service: Sized + 'static {
|
||||
fn domain() -> &'static str;
|
||||
fn url_path() -> &'static str;
|
||||
fn commit_url(repo: &str, commit_ref: &str) -> String;
|
||||
|
||||
fn register_service<T>(app: App<T>) -> App<T>
|
||||
where
|
||||
T: ServiceFactory<ServiceRequest, Config = (), Error = actix_web::Error, InitError = ()>,
|
||||
{
|
||||
let url_path = Self::url_path();
|
||||
app.service(
|
||||
web::resource(format!("/{url_path}/{{user}}/{{repo}}")).to(calculate_hoc::<Self>),
|
||||
)
|
||||
.service(
|
||||
web::resource(format!("/{url_path}/{{user}}/{{repo}}/delete"))
|
||||
.route(web::post().to(delete_repo_and_cache::<Self>)),
|
||||
)
|
||||
.service(web::resource(format!("/{url_path}/{{user}}/{{repo}}/json")).to(json_hoc::<Self>))
|
||||
.service(web::resource(format!("/view/{url_path}/{{user}}/{{repo}}")).to(overview::<Self>))
|
||||
.service(web::resource(format!("/{url_path}/{{user}}/{{repo}}/view")).to(overview::<Self>))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
4
static/tacit-css.min.css
vendored
4
static/tacit-css.min.css
vendored
File diff suppressed because one or more lines are too long
31
tests/resources.rs
Normal file
31
tests/resources.rs
Normal file
@ -0,0 +1,31 @@
|
||||
mod util;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn favicon() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/favicon.ico", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn tacit_css() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/tacit-css.min.css", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
80
vm.nix
80
vm.nix
@ -1,80 +0,0 @@
|
||||
# Nix configuration for a VM to run a custom configured Vim
|
||||
#
|
||||
# It is intended as an example of building a VM that builds Vim for testing
|
||||
# and evaluation purposes. It does not represent a production or secure
|
||||
# deployment.
|
||||
|
||||
{ sources ? import ./nix/sources.nix
|
||||
, pkgs ? import sources.nixpkgs { }
|
||||
, callPackage ? pkgs.callPackage
|
||||
, config
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
# config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
hoc = pkgs.callPackage ./default.nix { };
|
||||
|
||||
# hoc = cargoNix.rootCrate.build;
|
||||
in
|
||||
{
|
||||
environment = {
|
||||
systemPackages = with pkgs; [
|
||||
(
|
||||
hoc
|
||||
# import ./default.nix
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
networking.hostName = "hoc"; # Define your hostname.
|
||||
|
||||
system.stateVersion = "19.09"; # The version of NixOS originally installed
|
||||
|
||||
# Set security options:
|
||||
security = {
|
||||
sudo = {
|
||||
enable = true; # Enable sudo
|
||||
wheelNeedsPassword = false; # Allow wheel members to run sudo without a passowrd
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
|
||||
# List services that you want to enable:
|
||||
services.openssh = {
|
||||
enable = true; # Enable the OpenSSH daemon.
|
||||
#permitRootLogin = "yes"; # Probably want to change this in production
|
||||
#challengeResponseAuthentication = true; # Probably want to change this in production
|
||||
#passwordAuthentication = true; # Probably want to change this in production
|
||||
openFirewall = true;
|
||||
hostKeys = [
|
||||
{
|
||||
path = "/etc/ssh/ssh_host_ed25519_key"; # Generate a key for the vm
|
||||
type = "ed25519"; # Use the current best key type
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Users of the Vim VM:
|
||||
users.mutableUsers = false; # Remove any users not defined in here
|
||||
|
||||
users.users.root = {
|
||||
password = "123456"; # Probably want to change this in production
|
||||
};
|
||||
|
||||
# Misc groups:
|
||||
users.groups.nixos.gid = 1000;
|
||||
|
||||
# NixOS users
|
||||
users.users.nixos = {
|
||||
isNormalUser = true;
|
||||
uid = 1000;
|
||||
group = "nixos";
|
||||
extraGroups = [ "wheel" ];
|
||||
password = "123456"; # Probably want to change this in production
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user