html terminal
-rw-r--r--Cargo.toml4
-rw-r--r--build.rs34
-rw-r--r--media/logo32.pngbin2445 -> 2033 bytes
-rw-r--r--media/plaguess.pngbin1236706 -> 1186926 bytes
-rw-r--r--src/bot/js.rs25
5 files changed, 22 insertions, 41 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1565c31..506b52d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,7 +32,6 @@ serenity = { version = "0.12", features = [
poise = { git = "https://github.com/serenity-rs/poise" }
anyhow = "1.0.75"
regex = { version = "1.8.4", features = ["std"], default-features = false }
-minify-js = "0.5.6"
convert_case = "0.6.0"
parse_duration = "2.1.1"
serde = "1.0"
@@ -54,9 +53,6 @@ strconv = "0.1.0"
strip = true
lto = "thin"
-[build-dependencies]
-minify-html = "0.11.1"
-
[profile.dev.package.mindus]
opt-level = 3
diff --git a/build.rs b/build.rs
index 0de5af6..2a1d0be 100644
--- a/build.rs
+++ b/build.rs
@@ -1,22 +1,30 @@
+#![feature(let_chains)]
use std::fs;
use std::io::prelude::*;
use std::path::Path;
-use minify_html::{minify, Cfg};
-
pub fn process(input: impl AsRef<Path>) -> std::io::Result<()> {
let mut f = fs::File::create(dbg!(Path::new("html").join(input.as_ref()))).unwrap();
- let mut buf = vec![];
- fs::File::open(Path::new("html-src").join(input.as_ref()))?.read_to_end(&mut buf)?;
- let minified = minify(
- &buf,
- &Cfg {
- minify_js: true,
- minify_css: true,
- ..Default::default()
- },
- );
- f.write_all(&minified)
+ if !matches!(
+ input.as_ref().extension().unwrap().to_str().unwrap(),
+ "html" | "js" | "css"
+ ) {
+ return f.write_all(&std::fs::read(Path::new("html-src").join(input.as_ref()))?);
+ }
+ let mut c = std::process::Command::new("minify")
+ .arg(Path::new("html-src").join(input.as_ref()))
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let mut o = c.stdout.take().unwrap();
+ let mut buf = [0; 1024];
+ while let Ok(x) = o.read(&mut buf)
+ && x != 0
+ {
+ f.write_all(&buf[..x])?;
+ }
+ c.wait()?;
+ Ok(())
}
fn main() -> std::io::Result<()> {
diff --git a/media/logo32.png b/media/logo32.png
index 09e904e..155b44e 100644
--- a/media/logo32.png
+++ b/media/logo32.png
Binary files differ
diff --git a/media/plaguess.png b/media/plaguess.png
index c515b9d..84755d9 100644
--- a/media/plaguess.png
+++ b/media/plaguess.png
Binary files differ
diff --git a/src/bot/js.rs b/src/bot/js.rs
index c882c77..fa7cbbe 100644
--- a/src/bot/js.rs
+++ b/src/bot/js.rs
@@ -1,5 +1,4 @@
use super::{return_next, send_ctx, Context, Result};
-use minify_js::{Session, TopLevelMode};
use regex::Regex;
use std::sync::LazyLock;
@@ -9,22 +8,7 @@ fn parse_js(from: &str) -> Result<String> {
let mat = RE
.captures(from)
.ok_or(anyhow::anyhow!(r#"no code found (use \`\`\`js...\`\`\`."#))?;
- let script = mat.get(2).unwrap().as_str();
- let mut out = vec![];
- Ok(
- if minify_js::minify(
- &Session::new(),
- TopLevelMode::Global,
- script.as_bytes(),
- &mut out,
- )
- .is_ok()
- {
- String::from_utf8_lossy(&out).to_string()
- } else {
- script.replace('\n', ";")
- },
- )
+ Ok(mat.get(2).unwrap().as_str().replace('\n', ";"))
}
#[poise::command(
@@ -47,10 +31,3 @@ pub async fn run(
send_ctx!(ctx, "js {script}")?;
return_next!(ctx)
}
-
-#[test]
-fn test_parse_js() {
- assert!(
- parse_js("```js\nLog.info(4)\nLog.info(4+2)\n```").unwrap() == "Log.info(4);Log.info(4+ 2)" // hmm
- )
-}