pub struct Asset {
pub body: &'static [u8],
pub content_type: &'static str,
}
const INDEX_HTML: &str = include_str!("../web/index.html");
const COOKBOOK_HTML: &str = include_str!("../web/cookbook.html");
const ATELIER_HTML: &str = include_str!("../web/atelier.html");
const THEME_CSS: &str = include_str!("../web/styles/theme.css");
const COOKBOOK_CSS: &str = include_str!("../web/cookbook/cookbook.css");
const ATELIER_CSS: &str = include_str!("../web/atelier/atelier.css");
const BOOT_JS: &str = include_str!("../web/interpreter/boot.js");
const APP_JS: &str = include_str!("../web/interpreter/app.js");
const GLASSES_JS: &str = include_str!("../web/interpreter/glasses.js");
const SCENE_JS: &str = include_str!("../web/interpreter/scene.js");
const HEATMAP_JS: &str = include_str!("../web/interpreter/heatmap.js");
const DIFF_JS: &str = include_str!("../web/interpreter/diff.js");
const INTENT_JS: &str = include_str!("../web/interpreter/intent.js");
const KEYMAP_JS: &str = include_str!("../web/interpreter/keymap.js");
const SESSION_JS: &str = include_str!("../web/interpreter/session.js");
const PWA_JS: &str = include_str!("../web/interpreter/pwa.js");
const COOKBOOK_JS: &str = include_str!("../web/cookbook/cookbook.js");
const ATELIER_JS: &str = include_str!("../web/atelier/atelier.js");
const SERVICE_WORKER_JS: &str = include_str!("../web/sw.js");
const WEB_MANIFEST: &str = include_str!("../web/manifest.webmanifest");
const ICON_SVG: &str = include_str!("../web/assets/icon.svg");
const ICON_MASKABLE_SVG: &str = include_str!("../web/assets/icon-maskable.svg");
const JS_CONTENT_TYPE: &str = "text/javascript; charset=utf-8";
pub fn asset_for(path: &str) -> Option<Asset> {
let path = path.split(['?', '#']).next().unwrap_or(path);
match path {
"/" | "/index.html" => Some(Asset {
body: INDEX_HTML.as_bytes(),
content_type: "text/html; charset=utf-8",
}),
"/cookbook" | "/cookbook.html" => Some(Asset {
body: COOKBOOK_HTML.as_bytes(),
content_type: "text/html; charset=utf-8",
}),
"/atelier" | "/atelier.html" => Some(Asset {
body: ATELIER_HTML.as_bytes(),
content_type: "text/html; charset=utf-8",
}),
"/styles/theme.css" => Some(Asset {
body: THEME_CSS.as_bytes(),
content_type: "text/css; charset=utf-8",
}),
"/cookbook/cookbook.css" => Some(Asset {
body: COOKBOOK_CSS.as_bytes(),
content_type: "text/css; charset=utf-8",
}),
"/atelier/atelier.css" => Some(Asset {
body: ATELIER_CSS.as_bytes(),
content_type: "text/css; charset=utf-8",
}),
"/interpreter/boot.js" => Some(Asset {
body: BOOT_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/app.js" => Some(Asset {
body: APP_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/glasses.js" => Some(Asset {
body: GLASSES_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/scene.js" => Some(Asset {
body: SCENE_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/heatmap.js" => Some(Asset {
body: HEATMAP_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/diff.js" => Some(Asset {
body: DIFF_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/intent.js" => Some(Asset {
body: INTENT_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/keymap.js" => Some(Asset {
body: KEYMAP_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/session.js" => Some(Asset {
body: SESSION_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/interpreter/pwa.js" => Some(Asset {
body: PWA_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/sw.js" => Some(Asset {
body: SERVICE_WORKER_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/manifest.webmanifest" => Some(Asset {
body: WEB_MANIFEST.as_bytes(),
content_type: "application/manifest+json; charset=utf-8",
}),
"/assets/icon.svg" => Some(Asset {
body: ICON_SVG.as_bytes(),
content_type: "image/svg+xml",
}),
"/assets/icon-maskable.svg" => Some(Asset {
body: ICON_MASKABLE_SVG.as_bytes(),
content_type: "image/svg+xml",
}),
"/cookbook/cookbook.js" => Some(Asset {
body: COOKBOOK_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
"/atelier/atelier.js" => Some(Asset {
body: ATELIER_JS.as_bytes(),
content_type: JS_CONTENT_TYPE,
}),
_ => None,
}
}