mirror of
https://github.com/tcsenpai/Zundler.git
synced 2025-06-06 03:25:28 +00:00
Rename some files; also finish some work from prev commit
This commit is contained in:
parent
54fda10acc
commit
8aa570030b
@ -116,9 +116,7 @@ monkeyPatch();
|
||||
// Set up message listener
|
||||
window.addEventListener("message", (evnt) => {
|
||||
console.log("Received message in iframe", evnt);
|
||||
if (evnt.data.action == 'set_data') {
|
||||
onSetData(evnt.data.argument);
|
||||
} else if (evnt.data.action == 'scroll_to_anchor') {
|
||||
if (evnt.data.action == 'scroll_to_anchor') {
|
||||
onScrollToAnchor(evnt.data.argument);
|
||||
}
|
||||
}, false);
|
||||
|
@ -17,4 +17,5 @@ GC = pako.inflate(GC);
|
||||
GC = new TextDecoder("utf-8").decode(GC);
|
||||
GC = JSON.parse(GC);
|
||||
window.globalContext = GC;
|
||||
eval(window.globalContext.main);
|
||||
eval(window.globalContext.utils.zundler_common);
|
||||
eval(window.globalContext.utils.zundler_main);
|
@ -58,11 +58,11 @@ var prepare = function(html) {
|
||||
`;
|
||||
|
||||
const commonTag = doc.createElement("script");
|
||||
commonTag.textContent = retrieveFile("common.js").data
|
||||
commonTag.textContent = window.globalContext.utils.zundler_common;
|
||||
const injectPreTag = doc.createElement("script");
|
||||
injectPreTag.textContent = retrieveFile("inject_pre.js").data
|
||||
injectPreTag.textContent = window.globalContext.utils.inject_pre;
|
||||
const injectPostTag = doc.createElement("script");
|
||||
injectPostTag.textContent = retrieveFile("inject_post.js").data
|
||||
injectPostTag.textContent = window.globalContext.utils.inject_post;
|
||||
|
||||
doc.head.prepend(commonTag);
|
||||
doc.head.prepend(gcTag);
|
@ -45,8 +45,9 @@ def embed_assets(index_file, output_path=None, append_pre="", append_post=""):
|
||||
for filename in [
|
||||
"init.css",
|
||||
"init.html",
|
||||
"bootstrap.js",
|
||||
"main.js",
|
||||
"zundler_bootstrap.js",
|
||||
"zundler_common.js",
|
||||
"zundler_main.js",
|
||||
"inject_pre.js",
|
||||
"inject_post.js",
|
||||
"pako.min.js",
|
||||
@ -58,6 +59,8 @@ def embed_assets(index_file, output_path=None, append_pre="", append_post=""):
|
||||
init_files[filename] = append_pre + init_files[filename]
|
||||
if filename == "inject_post.js":
|
||||
init_files[filename] += append_post
|
||||
if filename.lower().endswith(".js"):
|
||||
init_files[filename] += "\n\n//# sourceURL=%s" % filename
|
||||
|
||||
if not os.path.exists(index_file):
|
||||
raise FileNotFoundError("no such file: %s" % index_file)
|
||||
@ -74,13 +77,15 @@ def embed_assets(index_file, output_path=None, append_pre="", append_post=""):
|
||||
exclude_pattern=new_base_name,
|
||||
)
|
||||
|
||||
remote_resources = []
|
||||
|
||||
global_context = {
|
||||
"current_path": base_name,
|
||||
"file_tree": file_tree,
|
||||
"remote_resources": remote_resources,
|
||||
"main": init_files["main.js"] + "\n//# sourceURL=main.js",
|
||||
"fileTree": file_tree,
|
||||
"utils": {
|
||||
"zundler_main": init_files["zundler_main.js"],
|
||||
"zundler_common": init_files["zundler_common.js"],
|
||||
"inject_pre": init_files["inject_pre.js"],
|
||||
"inject_post": init_files["inject_post.js"],
|
||||
},
|
||||
}
|
||||
|
||||
global_context = json.dumps(global_context)
|
||||
@ -100,13 +105,13 @@ https://github.com/AdrianVollmer/Zundler
|
||||
<body>{body}
|
||||
<script>window.globalContext = "{global_context}"</script>
|
||||
<script>{pako} \n//# sourceURL=pako.js</script>
|
||||
<script>{bootstrap} \n//# sourceURL=boostrap.js</script>
|
||||
<script>{bootstrap} \n//# sourceURL=zundler_boostrap.js</script>
|
||||
</body><!-- {license} --></html>
|
||||
""".format(
|
||||
style=init_files["init.css"],
|
||||
body=init_files["init.html"],
|
||||
pako=init_files["pako.min.js"],
|
||||
bootstrap=init_files["bootstrap.js"],
|
||||
bootstrap=init_files["zundler_bootstrap.js"],
|
||||
global_context=global_context,
|
||||
license=init_files["LICENSE"],
|
||||
version=__version__,
|
||||
|
Loading…
x
Reference in New Issue
Block a user