-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Restructure and expand
export_template
files (#144)
* feat: Restructure `export_template` to use a single `index.html` template file * Adds `{{title}}` as a template parameter. * Consolidate app-launching code in `runExportedApp()`. * Pick up app mode from the `mode` query parameter. * `edit/index.html` now redirects to `index.html?mode="editor-terminal-viewer"`. * fix: Includes can include raw HTML * chore: Include `<title>` only if in the template data * feat: use object destructuring in the function signature * chore: Use `console.warn` * chore: Don't need to load jquery terminal
- Loading branch information
Showing
3 changed files
with
63 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,34 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<!doctype html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Shiny examples browser</title> | ||
<script | ||
src="../{{REL_PATH}}shinylive/load-shinylive-sw.js" | ||
type="module" | ||
></script> | ||
<script src="../{{REL_PATH}}shinylive/jquery.min.js"></script> | ||
<script src="../{{REL_PATH}}shinylive/jquery.terminal/js/jquery.terminal.min.js"></script> | ||
<link | ||
href="../{{REL_PATH}}shinylive/jquery.terminal/css/jquery.terminal.min.css" | ||
rel="stylesheet" | ||
<title>Redirect to editable app</title> | ||
<meta | ||
http-equiv="refresh" | ||
content="0;URL='../index.html?mode=editor-terminal-viewer'" | ||
/> | ||
<script type="module"> | ||
import { runApp } from "../{{REL_PATH}}shinylive/shinylive.js"; | ||
const response = await fetch("../app.json"); | ||
if (!response.ok) { | ||
throw new Error("HTTP error loading app.json: " + response.status); | ||
} | ||
const appFiles = await response.json(); | ||
|
||
const appRoot = document.getElementById("root"); | ||
runApp(appRoot, "editor-terminal-viewer", {startFiles: appFiles}, "{{APP_ENGINE}}"); | ||
</script> | ||
<link rel="stylesheet" href="../{{REL_PATH}}shinylive/style-resets.css" /> | ||
<link rel="stylesheet" href="../{{REL_PATH}}shinylive/shinylive.css" /> | ||
</head> | ||
<body> | ||
<div style="height: 100vh; width: 100vw" id="root"></div> | ||
</body> | ||
<body></body> | ||
</html> |
This file contains 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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Shiny App</title> | ||
{{#title}} | ||
<title>{{.}}</title> | ||
{{/title}} | ||
<script | ||
src="./{{REL_PATH}}shinylive/load-shinylive-sw.js" | ||
type="module" | ||
></script> | ||
<script type="module"> | ||
import { runApp } from "./{{REL_PATH}}shinylive/shinylive.js"; | ||
const response = await fetch("./app.json"); | ||
if (!response.ok) { | ||
throw new Error("HTTP error loading app.json: " + response.status); | ||
} | ||
const appFiles = await response.json(); | ||
|
||
const appRoot = document.getElementById("root"); | ||
runApp(appRoot, "viewer", {startFiles: appFiles}, "{{APP_ENGINE}}"); | ||
import { runExportedApp } from "./{{REL_PATH}}shinylive/shinylive.js"; | ||
runExportedApp({ | ||
id: "root", | ||
appEngine: "{{APP_ENGINE}}", | ||
relPath: "{{REL_PATH}}", | ||
}); | ||
</script> | ||
<link rel="stylesheet" href="./{{REL_PATH}}shinylive/style-resets.css" /> | ||
<link rel="stylesheet" href="./{{REL_PATH}}shinylive/shinylive.css" /> | ||
{{{ include_in_head }}} | ||
</head> | ||
<body> | ||
{{{ include_before_body }}} | ||
<div style="height: 100vh; width: 100vw" id="root"></div> | ||
{{{ include_after_body }}} | ||
</body> | ||
</html> |
This file contains 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