aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-10-28 11:12:04 +0200
committerMartin Fischer <martin@push-f.com>2022-10-28 11:33:23 +0200
commita972a4b5fa7a41d7a19d422db8af86d8817dfe81 (patch)
treedcb858cf24a5977a3a6820abfedb71978f6a6c2b /src
parent8876a8f21ff859894817b8c9418acaa243b90c36 (diff)
stop rendering .html files via <iframe>s
Now that we have Lua scripting we don't need iframes anymore.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs18
-rw-r--r--src/static/style.css4
2 files changed, 2 insertions, 20 deletions
diff --git a/src/main.rs b/src/main.rs
index ffa6486..2cd3a5d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -523,27 +523,9 @@ fn render_markdown(input: &str, page: &mut Page, _mode: RenderMode) {
page.body.push_str("</div>");
}
-fn embed_html_as_iframe(input: &str, page: &mut Page, mode: RenderMode) {
- if mode == RenderMode::View {
- page.body.push_str("<iframe src='?action=run'></iframe>");
- page.frame_src = Some("'self'");
- } else {
- page.body
- .push_str("<div class=note>Note that JavaScript does not work in the preview.</div>");
- // sandbox=allow-scripts wouldn't work because the strict parent page CSP still applies
-
- // The sandbox attribute makes browsers treat the embedded page as a unique origin.
- page.body.push_str(&format!(
- "<iframe srcdoc='{}' sandbox></iframe>",
- html_escape(input)
- ));
- }
-}
-
fn get_renderer(path: &Utf8Path) -> Option<fn(&str, &mut Page, RenderMode)> {
match path.extension() {
Some("md") => Some(render_markdown),
- Some("html") => Some(embed_html_as_iframe),
_ => None,
}
}
diff --git a/src/static/style.css b/src/static/style.css
index e3d0954..54c4f4a 100644
--- a/src/static/style.css
+++ b/src/static/style.css
@@ -23,7 +23,7 @@ h1 {
flex-grow: 1;
}
-textarea, iframe {
+textarea {
flex-grow: 1;
}
@@ -92,4 +92,4 @@ label {
.addition { background: #e6ffed; }
.deletion { background: #ffeef0; }
.addition ins {background: #acf2bd; text-decoration: none; }
-.deletion del {background: #fdb8c0; text-decoration: none; } \ No newline at end of file
+.deletion del {background: #fdb8c0; text-decoration: none; }