Compare commits
6
Commits
0.1.2
..
51173860be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51173860be | ||
|
|
b157941d5e | ||
|
|
1efb44206b | ||
|
|
e193f96709 | ||
|
|
e6cc71fa47 | ||
|
|
bbb19754bd |
No files matched your search
Generated
+643
-677
File diff suppressed because it is too large.
Load diff
+20
-15
@@ -1,20 +1,25 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "karnaugh"
|
name = "karnaugh"
|
||||||
version = "0.1.2"
|
version = "0.1.5"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.8.7"
|
axum = "0.8.9"
|
||||||
flate2 = "1.1.5"
|
flate2 = "1.1.9"
|
||||||
itertools = "0.14.0"
|
itertools = "0.15.0"
|
||||||
tar = "0.4.44"
|
tar = "0.4.46"
|
||||||
time = "0.3.47"
|
time = "0.3.53"
|
||||||
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.53.0", features = ["macros", "rt-multi-thread"] }
|
||||||
tower-http = { version = "0.6.8", features = ["compression-br", "fs", "trace"] }
|
tower-http = { version = "0.7.0", features = [
|
||||||
tracing = "0.1.43"
|
"compression-br",
|
||||||
tracing-subscriber = "0.3.22"
|
"fs",
|
||||||
typst-html = { git = "https://github.com/mkorje/typst.git", branch = "mathml" }
|
"trace",
|
||||||
typst-kit = { git = "https://github.com/mkorje/typst.git", branch = "mathml" }
|
"set-header",
|
||||||
typst = { git = "https://github.com/mkorje/typst.git", branch = "mathml" }
|
] }
|
||||||
ureq = "3.1.4"
|
tracing = "0.1.44"
|
||||||
clap = { version = "4.6.0", features = ["derive"] }
|
tracing-subscriber = "0.3.23"
|
||||||
|
typst-html = "0.15.1"
|
||||||
|
typst-kit = "0.15.1"
|
||||||
|
typst = "0.15.1"
|
||||||
|
ureq = "3.3.0"
|
||||||
|
clap = { version = "4.6.2", features = ["derive"] }
|
||||||
Generated
+3
-3
@@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773821835,
|
"lastModified": 1784120854,
|
||||||
"narHash": "sha256-TJ3lSQtW0E2JrznGVm8hOQGVpXjJyXY2guAxku2O9A4=",
|
"narHash": "sha256-KesHgItiZPgGX740axSiQLcIQ8D24MDqNpkKYWIek8k=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "b40629efe5d6ec48dd1efba650c797ddbd39ace0",
|
"rev": "753cc8a3a87467296ddd1fa93f0cc3e81120ee46",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
rec {
|
rec {
|
||||||
packages.karnaugh = pkgs.rustPlatform.buildRustPackage (final: {
|
packages.karnaugh = pkgs.rustPlatform.buildRustPackage (final: {
|
||||||
pname = "karnaugh";
|
pname = "karnaugh";
|
||||||
version = "0.1.2";
|
version = "0.1.5";
|
||||||
src = self;
|
src = self;
|
||||||
cargoHash = "sha256-YRSK2Vk6I1y/PhH1ZyFAYF0E6IB55So3MTs8B5df4LM=";
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
});
|
});
|
||||||
packages.container = pkgs.dockerTools.buildImage {
|
packages.container = pkgs.dockerTools.buildImage {
|
||||||
name = "karnaugh";
|
name = "karnaugh";
|
||||||
@@ -31,22 +31,24 @@
|
|||||||
|
|
||||||
copyToRoot = pkgs.buildEnv {
|
copyToRoot = pkgs.buildEnv {
|
||||||
name = "karnaugh-root";
|
name = "karnaugh-root";
|
||||||
paths = [packages.karnaugh];
|
paths = [ packages.karnaugh ];
|
||||||
pathsToLink = ["/bin"];
|
pathsToLink = [ "/bin" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
Entrypoint = ["/bin/karnaugh"];
|
Entrypoint = [ "/bin/karnaugh" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
packages.default = packages.karnaugh;
|
packages.default = packages.karnaugh;
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
cargo
|
cargo
|
||||||
rustc
|
rustc
|
||||||
rustfmt
|
rustfmt
|
||||||
clippy
|
clippy
|
||||||
|
cargo-edit
|
||||||
|
cargo-audit
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -8,7 +8,7 @@ use ::typst::syntax::VirtualPath;
|
|||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
Router,
|
||||||
extract::{Path, State},
|
extract::{Path, State},
|
||||||
http::StatusCode,
|
http::{HeaderValue, StatusCode, header::CACHE_CONTROL},
|
||||||
response::{Html, IntoResponse, Response},
|
response::{Html, IntoResponse, Response},
|
||||||
routing::get,
|
routing::get,
|
||||||
};
|
};
|
||||||
@@ -17,6 +17,7 @@ use itertools::Itertools;
|
|||||||
use tower_http::{
|
use tower_http::{
|
||||||
compression::CompressionLayer,
|
compression::CompressionLayer,
|
||||||
services::{ServeDir, ServeFile},
|
services::{ServeDir, ServeFile},
|
||||||
|
set_header::SetResponseHeaderLayer,
|
||||||
trace::TraceLayer,
|
trace::TraceLayer,
|
||||||
};
|
};
|
||||||
use tracing::{Level, info};
|
use tracing::{Level, info};
|
||||||
@@ -97,14 +98,20 @@ async fn main() {
|
|||||||
let mut favicon = state.config.get_full_assets_path();
|
let mut favicon = state.config.get_full_assets_path();
|
||||||
favicon.push(PathBuf::from("favicon.svg"));
|
favicon.push(PathBuf::from("favicon.svg"));
|
||||||
|
|
||||||
|
let assets_service = ServeDir::new(state.config.get_full_assets_path());
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", get(root_handler))
|
.route("/", get(root_handler))
|
||||||
.route("/{*path}", get(typst_handler))
|
.route("/{*path}", get(typst_handler))
|
||||||
.route_service("/favicon.ico", ServeFile::new(favicon))
|
.route_service("/favicon.ico", ServeFile::new(favicon))
|
||||||
.nest_service("/assets", ServeDir::new(&state.config.assets_root))
|
.nest_service("/assets", assets_service)
|
||||||
.with_state(state.clone())
|
.with_state(state.clone())
|
||||||
.layer(TraceLayer::new_for_http())
|
.layer(TraceLayer::new_for_http())
|
||||||
.layer(CompressionLayer::new());
|
.layer(CompressionLayer::new())
|
||||||
|
.layer(SetResponseHeaderLayer::overriding(
|
||||||
|
CACHE_CONTROL,
|
||||||
|
HeaderValue::from_static("public, max-age=86400, immutable"),
|
||||||
|
));
|
||||||
|
|
||||||
let socket = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), state.config.port);
|
let socket = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), state.config.port);
|
||||||
info!("Serving Karnaugh on socket {}", socket);
|
info!("Serving Karnaugh on socket {}", socket);
|
||||||
|
|||||||
+12
-5
@@ -10,6 +10,7 @@ use typst::{
|
|||||||
text::{Font, FontBook},
|
text::{Font, FontBook},
|
||||||
utils::LazyHash,
|
utils::LazyHash,
|
||||||
};
|
};
|
||||||
|
use typst_html::HtmlOptions;
|
||||||
use typst_kit::fonts::FontStore;
|
use typst_kit::fonts::FontStore;
|
||||||
|
|
||||||
use crate::AppConfig;
|
use crate::AppConfig;
|
||||||
@@ -41,12 +42,14 @@ impl TypstContext {
|
|||||||
let world = DocumentWorld::new(path, self);
|
let world = DocumentWorld::new(path, self);
|
||||||
let compiled = typst::compile(&world);
|
let compiled = typst::compile(&world);
|
||||||
|
|
||||||
|
let html_options = HtmlOptions::default();
|
||||||
|
|
||||||
// TODO: Log warnings
|
// TODO: Log warnings
|
||||||
|
|
||||||
// TODO: Log errors
|
// TODO: Log errors
|
||||||
compiled
|
compiled
|
||||||
.output
|
.output
|
||||||
.and_then(|doc| typst_html::html(&doc))
|
.and_then(|doc| typst_html::html(&doc, &html_options))
|
||||||
.map_err(|err| err.into_iter().collect())
|
.map_err(|err| err.into_iter().collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +119,8 @@ impl<'a> DocumentWorld<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_project_file(&self, path: &VirtualPath) -> FileResult<PathBuf> {
|
fn resolve_project_file(&self, path: &VirtualPath) -> FileResult<PathBuf> {
|
||||||
Ok(path.realize(&self.context.config.content_root))
|
path.realize(&self.context.config.content_root)
|
||||||
|
.map_err(FileError::Realize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_package_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
fn resolve_package_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
||||||
@@ -129,12 +133,13 @@ impl<'a> DocumentWorld<'a> {
|
|||||||
|
|
||||||
fn resolve_common_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
fn resolve_common_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
||||||
let path = get_package_path(path, spec);
|
let path = get_package_path(path, spec);
|
||||||
Ok(path.realize(&self.context.config.get_full_common_path()))
|
path.realize(&self.context.config.get_full_common_path())
|
||||||
|
.map_err(FileError::Realize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_preview_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
fn resolve_preview_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
||||||
let package_path = self.get_package(spec)?;
|
let package_path = self.get_package(spec)?;
|
||||||
Ok(path.realize(&package_path))
|
path.realize(&package_path).map_err(FileError::Realize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_package(&self, spec: &PackageSpec) -> PackageResult<PathBuf> {
|
fn get_package(&self, spec: &PackageSpec) -> PackageResult<PathBuf> {
|
||||||
@@ -142,7 +147,9 @@ impl<'a> DocumentWorld<'a> {
|
|||||||
&VirtualPath::new("").expect("Failed to create empty virtual path"),
|
&VirtualPath::new("").expect("Failed to create empty virtual path"),
|
||||||
spec,
|
spec,
|
||||||
);
|
);
|
||||||
let path = path.realize(&self.context.config.packages_root);
|
let path = path
|
||||||
|
.realize(&self.context.config.packages_root)
|
||||||
|
.map_err(|_| PackageError::NotFound(spec.clone()))?;
|
||||||
|
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
return Ok(path);
|
return Ok(path);
|
||||||
|
|||||||
Reference in new issue
Block a user