Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51173860be | ||
|
|
b157941d5e | ||
|
|
1efb44206b | ||
|
|
e193f96709 | ||
|
|
e6cc71fa47 | ||
|
|
bbb19754bd | ||
|
|
c2e208a20b |
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]
|
||||
name = "karnaugh"
|
||||
version = "0.1.1"
|
||||
version = "0.1.5"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
axum = "0.8.7"
|
||||
flate2 = "1.1.5"
|
||||
itertools = "0.14.0"
|
||||
tar = "0.4.44"
|
||||
time = "0.3.47"
|
||||
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread"] }
|
||||
tower-http = { version = "0.6.8", features = ["compression-br", "fs", "trace"] }
|
||||
tracing = "0.1.43"
|
||||
tracing-subscriber = "0.3.22"
|
||||
typst-html = { git = "https://github.com/mkorje/typst.git", branch = "mathml" }
|
||||
typst-kit = { git = "https://github.com/mkorje/typst.git", branch = "mathml" }
|
||||
typst = { git = "https://github.com/mkorje/typst.git", branch = "mathml" }
|
||||
ureq = "3.1.4"
|
||||
clap = { version = "4.6.0", features = ["derive"] }
|
||||
axum = "0.8.9"
|
||||
flate2 = "1.1.9"
|
||||
itertools = "0.15.0"
|
||||
tar = "0.4.46"
|
||||
time = "0.3.53"
|
||||
tokio = { version = "1.53.0", features = ["macros", "rt-multi-thread"] }
|
||||
tower-http = { version = "0.7.0", features = [
|
||||
"compression-br",
|
||||
"fs",
|
||||
"trace",
|
||||
"set-header",
|
||||
] }
|
||||
tracing = "0.1.44"
|
||||
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": {
|
||||
"locked": {
|
||||
"lastModified": 1773821835,
|
||||
"narHash": "sha256-TJ3lSQtW0E2JrznGVm8hOQGVpXjJyXY2guAxku2O9A4=",
|
||||
"lastModified": 1784120854,
|
||||
"narHash": "sha256-KesHgItiZPgGX740axSiQLcIQ8D24MDqNpkKYWIek8k=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b40629efe5d6ec48dd1efba650c797ddbd39ace0",
|
||||
"rev": "753cc8a3a87467296ddd1fa93f0cc3e81120ee46",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
rec {
|
||||
packages.karnaugh = pkgs.rustPlatform.buildRustPackage (final: {
|
||||
pname = "karnaugh";
|
||||
version = "0.1.1";
|
||||
version = "0.1.5";
|
||||
src = self;
|
||||
cargoHash = "sha256-LqPV818AKVQR5ihE3xkEduLhsxvN5m21M8H/AVWBXTU=";
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
});
|
||||
packages.container = pkgs.dockerTools.buildImage {
|
||||
name = "karnaugh";
|
||||
@@ -31,22 +31,24 @@
|
||||
|
||||
copyToRoot = pkgs.buildEnv {
|
||||
name = "karnaugh-root";
|
||||
paths = [packages.karnaugh];
|
||||
pathsToLink = ["/bin"];
|
||||
paths = [ packages.karnaugh ];
|
||||
pathsToLink = [ "/bin" ];
|
||||
};
|
||||
|
||||
config = {
|
||||
Cmd = ["/bin/karnaugh"];
|
||||
Entrypoint = [ "/bin/karnaugh" ];
|
||||
};
|
||||
};
|
||||
packages.default = packages.karnaugh;
|
||||
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
cargo
|
||||
rustc
|
||||
rustfmt
|
||||
clippy
|
||||
cargo-edit
|
||||
cargo-audit
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
+10
-3
@@ -8,7 +8,7 @@ use ::typst::syntax::VirtualPath;
|
||||
use axum::{
|
||||
Router,
|
||||
extract::{Path, State},
|
||||
http::StatusCode,
|
||||
http::{HeaderValue, StatusCode, header::CACHE_CONTROL},
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::get,
|
||||
};
|
||||
@@ -17,6 +17,7 @@ use itertools::Itertools;
|
||||
use tower_http::{
|
||||
compression::CompressionLayer,
|
||||
services::{ServeDir, ServeFile},
|
||||
set_header::SetResponseHeaderLayer,
|
||||
trace::TraceLayer,
|
||||
};
|
||||
use tracing::{Level, info};
|
||||
@@ -97,14 +98,20 @@ async fn main() {
|
||||
let mut favicon = state.config.get_full_assets_path();
|
||||
favicon.push(PathBuf::from("favicon.svg"));
|
||||
|
||||
let assets_service = ServeDir::new(state.config.get_full_assets_path());
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(root_handler))
|
||||
.route("/{*path}", get(typst_handler))
|
||||
.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())
|
||||
.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);
|
||||
info!("Serving Karnaugh on socket {}", socket);
|
||||
|
||||
+12
-5
@@ -10,6 +10,7 @@ use typst::{
|
||||
text::{Font, FontBook},
|
||||
utils::LazyHash,
|
||||
};
|
||||
use typst_html::HtmlOptions;
|
||||
use typst_kit::fonts::FontStore;
|
||||
|
||||
use crate::AppConfig;
|
||||
@@ -41,12 +42,14 @@ impl TypstContext {
|
||||
let world = DocumentWorld::new(path, self);
|
||||
let compiled = typst::compile(&world);
|
||||
|
||||
let html_options = HtmlOptions::default();
|
||||
|
||||
// TODO: Log warnings
|
||||
|
||||
// TODO: Log errors
|
||||
compiled
|
||||
.output
|
||||
.and_then(|doc| typst_html::html(&doc))
|
||||
.and_then(|doc| typst_html::html(&doc, &html_options))
|
||||
.map_err(|err| err.into_iter().collect())
|
||||
}
|
||||
}
|
||||
@@ -116,7 +119,8 @@ impl<'a> DocumentWorld<'a> {
|
||||
}
|
||||
|
||||
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> {
|
||||
@@ -129,12 +133,13 @@ impl<'a> DocumentWorld<'a> {
|
||||
|
||||
fn resolve_common_file(&self, path: &VirtualPath, spec: &PackageSpec) -> FileResult<PathBuf> {
|
||||
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> {
|
||||
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> {
|
||||
@@ -142,7 +147,9 @@ impl<'a> DocumentWorld<'a> {
|
||||
&VirtualPath::new("").expect("Failed to create empty virtual path"),
|
||||
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() {
|
||||
return Ok(path);
|
||||
|
||||
Reference in new issue
Block a user