release: v0.3.1 — W8 favicon/head/images + entry_dir fix
Ship site icons, head asset tables, and image assembly; absolutize entry_dir for relative entry scripts so sqlite paths no longer nest. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1e5e6f4891
commit
416914a346
29 files changed
+1497
-36
No files matched your search
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: web assets live server
|
||||
description: Live favicon + head icon + images_html on home page.
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`icons_table` =
|
||||
|
||||
|path|rel|type|url|
|
||||
|---|---|---|---|
|
||||
|"web-fixtures/public/favicon.png"|icon|"image/png"|"/favicon.ico"|
|
||||
|
||||
`head_table` =
|
||||
|
||||
|rel|href|type|
|
||||
|---|---|---|
|
||||
|apple-touch-icon|"/static/favicon.png"|"image/png"|
|
||||
|
||||
`images_table` =
|
||||
|
||||
|src|alt|class|loading|
|
||||
|---|---|---|---|
|
||||
|"/static/favicon.svg"|mark|brand|eager|
|
||||
|
||||
*home = > web.page title="Live assets" intro="<p>assets live</p>"*
|
||||
*home = > `home`.head table=`head_table`*
|
||||
*home = > `home`.images table=`images_table`*
|
||||
|
||||
*app = > web.app page=`home` host=127.0.0.1 port=18092*
|
||||
*app = > `app`.static dir="web-fixtures/public" mount="/static"*
|
||||
*app = > `app`.icons table=`icons_table`*
|
||||
|
||||
> print text=marqdo web assets live starting
|
||||
> `app`.listen
|
||||
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: web assets smoke
|
||||
description: Offline icons / head / images assembly (no listen).
|
||||
import web:ext/web/web.mq.md
|
||||
import json:lib/json.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`icons_table` =
|
||||
|
||||
|path|rel|type|sizes|url|
|
||||
|---|---|---|---|---|
|
||||
|"web-fixtures/public/favicon.png"|icon|"image/png"|32x32|"/favicon.ico"|
|
||||
|"web-fixtures/public/favicon.svg"|icon|"image/svg+xml"|any|"/static/favicon.svg"|
|
||||
|
||||
`head_table` =
|
||||
|
||||
|rel|href|type|media|
|
||||
|---|---|---|---|
|
||||
|icon|"/favicon.ico"|"image/png"|
|
||||
|stylesheet|"/static/print.css"|"text/css"|print|
|
||||
|script|"/static/live.js"||
|
||||
|
||||
`images_table` =
|
||||
|
||||
|src|alt|class|href|width|loading|caption|
|
||||
|---|---|---|---|---|---|---|
|
||||
|"/static/logo.svg"|Marqdo|brand-logo|"/"|48|eager|Brand|
|
||||
|
||||
`seo` =
|
||||
|
||||
| 行 | key | value |
|
||||
|----|-----|-------|
|
||||
| 1 | description | asset smoke |
|
||||
| 2 | icon | "/favicon.ico" |
|
||||
| 3 | og:image | "/static/logo.svg" |
|
||||
|
||||
*home = > web.page title="Assets"*
|
||||
*home = > `home`.head table=`head_table`*
|
||||
*home = > `home`.images table=`images_table`*
|
||||
*home = > `home`.meta meta=`seo`*
|
||||
|
||||
*ih = > json.get value=`home` key="images_html"*
|
||||
1. `ih` != ""
|
||||
> print text=images-ok
|
||||
2. *
|
||||
> print text=images-fail
|
||||
|
||||
*hd = > json.get value=`home` key="head"*
|
||||
*n = > len `hd`*
|
||||
1. `n` >= 3
|
||||
> print text=head-ok
|
||||
2. *
|
||||
> print text=head-fail
|
||||
|
||||
*meta = > json.get value=`home` key="meta"*
|
||||
*icon = > json.get value=`meta` key="icon"*
|
||||
1. `icon` == "/favicon.ico"
|
||||
> print text=meta-icon-ok
|
||||
2. *
|
||||
> print text=meta-icon-fail
|
||||
|
||||
*app = > web.app page=`home` host=127.0.0.1 port=18091*
|
||||
*app = > `app`.static dir="web-fixtures/public" mount="/static"*
|
||||
*app = > `app`.icons table=`icons_table`*
|
||||
|
||||
*icons = > json.get value=`app` key="icons"*
|
||||
*ni = > len `icons`*
|
||||
1. `ni` == 2
|
||||
> print text=icons-ok
|
||||
2. *
|
||||
> print text=icons-fail
|
||||
|
||||
*sh = > json.get value=`app` key="site_head"*
|
||||
*ns = > len `sh`*
|
||||
1. `ns` >= 1
|
||||
> print text=site-head-ok
|
||||
2. *
|
||||
> print text=site-head-fail
|
||||
|
||||
*preview = > web.make_images table=`images_table`*
|
||||
1. `preview` != ""
|
||||
> print text=make-images-ok
|
||||
2. *
|
||||
> print text=make-images-fail
|
||||
|
||||
*hprev = > web.make_head table=`head_table`*
|
||||
1. `hprev` != ""
|
||||
> print text=make-head-ok
|
||||
2. *
|
||||
> print text=make-head-fail
|
||||
@@ -0,0 +1,2 @@
|
||||
‰PNG
|
||||
|
||||
|
After Width: | Height: | Size: 8 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#1a5f4a"/><text x="16" y="22" text-anchor="middle" font-size="16" font-family="Georgia,serif" fill="#f4f7f5">M</text></svg>
|
||||
|
After Width: | Height: | Size: 226 B |
@@ -1542,6 +1542,102 @@ custom-ok",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_assets_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_web"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build web plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_web");
|
||||
assert_out(
|
||||
"tests/ext/web-assets-smoke.mq.md",
|
||||
"images-ok
|
||||
head-ok
|
||||
meta-icon-ok
|
||||
icons-ok
|
||||
site-head-ok
|
||||
make-images-ok
|
||||
make-head-ok",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_assets_live() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_web"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build web plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_web");
|
||||
|
||||
let script = "tests/ext/web-assets-live-server.mq.md";
|
||||
let bin = env!("CARGO_BIN_EXE_marqdo");
|
||||
let mut child = Command::new(bin)
|
||||
.args(["run", script])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.expect("spawn assets live server");
|
||||
|
||||
let base = "http://127.0.0.1:18092";
|
||||
let ready = std::time::Instant::now();
|
||||
loop {
|
||||
if ready.elapsed().as_secs() > 10 {
|
||||
let _ = child.kill();
|
||||
panic!("assets live server did not start in time");
|
||||
}
|
||||
let out = Command::new("curl")
|
||||
.args([
|
||||
"-s",
|
||||
"-o",
|
||||
"/dev/null",
|
||||
"-w",
|
||||
"%{http_code}",
|
||||
&format!("{base}/"),
|
||||
])
|
||||
.output()
|
||||
.expect("curl probe");
|
||||
if String::from_utf8_lossy(&out.stdout) == "200" {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(300));
|
||||
}
|
||||
|
||||
let out = Command::new("curl")
|
||||
.args([
|
||||
"-s",
|
||||
"-D",
|
||||
"-",
|
||||
"-o",
|
||||
"/tmp/marqdo-favicon.bin",
|
||||
"-w",
|
||||
"\n%{http_code}",
|
||||
&format!("{base}/favicon.ico"),
|
||||
])
|
||||
.output()
|
||||
.expect("curl favicon");
|
||||
let body = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(
|
||||
body.contains("200") && body.to_ascii_lowercase().contains("image/"),
|
||||
"favicon headers={body}"
|
||||
);
|
||||
|
||||
let out = Command::new("curl")
|
||||
.args(["-s", &format!("{base}/")])
|
||||
.output()
|
||||
.expect("curl home");
|
||||
let html = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(
|
||||
html.contains("rel=\"icon\"") && html.contains("mq-images") && html.contains("apple-touch-icon"),
|
||||
"home html missing assets markers: {}",
|
||||
&html[..html.len().min(500)]
|
||||
);
|
||||
|
||||
let _ = child.kill();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_middleware_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
|
||||
Reference in new issue
Block a user