FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Add option to disable embedded JS in generated HTML by fxwiegand · Pull Request #382 · alignoth/alignoth · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) .rs  (3) .tera  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ The following options are available when using alignoth:
| highlight-data-output | | If present highlight data will be written to the given file path | |
| coverage-data-output | | If present coverage data will be written to the given file path | |
| html | | If present the generated plot will inserted into a plain html file containing the plot centered which is then written to stdout | |
| no-embed-js | | If present, the generated html will not embed javscript dependencies and therefore be considerably smaller but require internet access to load the dependencies. | false |


## Installation

Expand Down
8 changes: 4 additions & 4 deletions resources/plot.html.tera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html>
<head>
<meta charset="utf-8">
<script>{{ vega | safe }}</script>
<script>{{ vegalite | safe }}</script>
<script>{{ vegaembed | safe }}</script>
<script>{{ lzstring | safe }}</script>
{{ vega | safe }}
{{ vegalite | safe }}
{{ vegaembed | safe }}
{{ lzstring | safe }}
<style>
#controls {
display: flex;
Expand Down
4 changes: 4 additions & 0 deletions src/cli.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub struct Alignoth {
/// Displays the given content of the aux tags in the tooltip of the plot. Multiple usage for more than one tag is possible.
#[structopt(long, short = "x")]
pub(crate) aux_tag: Option<Vec<String>>,

/// If present, the generated html will not embed javscript dependencies and therefore be considerably smaller but require internet access to load the dependencies.
#[structopt(long, conflicts_with("output"))]
pub(crate) no_embed_js: bool,
}

pub(crate) trait Preprocess {
Expand Down
55 changes: 51 additions & 4 deletions src/main.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,57 @@ async fn main() -> Result<()> {
"spec",
&json!(compress_to_utf16(&plot_specs.to_string())).to_string(),
);
context.insert("vega", include_str!("../resources/vega.min.js"));
context.insert("vegalite", include_str!("../resources/vega-lite.min.js"));
context.insert("vegaembed", include_str!("../resources/vega-embed.min.js"));
context.insert("lzstring", include_str!("../resources/lz-string.min.js"));
if opt.no_embed_js {
context.insert(
"vega",
r#"<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>"#,
);
context.insert(
"vegalite",
r#"<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>"#,
);
context.insert(
"vegaembed",
r#"<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>"#,
);
context.insert(
"lzstring",
r#"<script src="https://cdn.jsdelivr.net/npm/lz-string@1"></script>"#,
);
} else {
context.insert(
"vega",
concat!(
"<script>",
include_str!("../resources/vega.min.js"),
"</script>"
),
);
context.insert(
"vegalite",
concat!(
"<script>",
include_str!("../resources/vega-lite.min.js"),
"</script>"
),
);
context.insert(
"vegaembed",
concat!(
"<script>",
include_str!("../resources/vega-embed.min.js"),
"</script>"
),
);
context.insert(
"lzstring",
concat!(
"<script>",
include_str!("../resources/lz-string.min.js"),
"</script>"
),
);
}
let html = templates.render("plot", &context)?;
if wizard {
std::fs::write(format!("{bam_name}.html"), html.as_bytes())?;
Expand Down
1 change: 1 addition & 0 deletions src/wizard.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@ pub(crate) async fn wizard_mode() -> Result<Alignoth> {
ref_data_output: None,
read_data_output: None,
coverage_output: None,
no_embed_js: false,
})
}
Loading

Back | FazBrowse Home | New Git URL