Closed 8176135 closed 5 years ago
Think of a document viewer. If you load an HTML file, it would display it on window (and its associated resources, like images, fonts, or styles). If you loaded a CSS file, what would you expect to see? Its text?
I think, you want the following instead:
<html>
<head>
<style type="text/css">
/* include styles */
@import url(styles.css);
/* include fonts */
@font-face {
font-family: 'FontAwesome';
src: url(fontawesome-webfont.ttf);
font-weight: normal;
font-style: normal;
}
</style>
<script type="text/tiscript">
/* include additional scripts */
include "script.tis";
debug "hello, world";
</script>
So, if you have the following structure:
| `-- main.html
| `-- script.tis
| `-- styles.css
Then you could load everything with a single call:
// Sciter requires absolute paths when loading HTML.
let mut cwd = std::env::current_dir()?;
cwd.push("main.html");
frame.load_file(cwd.to_str()?);
Well, what I'm trying to do is include the source files (html css fonts tis...etc) within the binary rather than in a separate folder alongside it.
With the load_html
function, I can use include_str! macro to include the html file and when distributing I can just send the standalone executable, my question is is there a way to do the same for the other files without in-lining everything.
Thanks.
I see. Use packaged resources: ZIP archives or Sciter archive with packfolder
packer. Or you can implement your own data loading handler in extreme cases.
Basically, you will pack everything in a single archive file which can be included via include_bytes!
.
P.S. Though I am not sure that ZIP archives can be kept in memory, perhaps, they can be loaded from file system only.
packfolder
seems to be what I'm looking for, thanks!
Is there a way to load files like how the html file is loaded in the examples.
But for other files like fonts or css files?