StanfordLegion / legion

The Legion Parallel Programming System
https://legion.stanford.edu
Apache License 2.0
668 stars 146 forks source link

legion_prof_rs: load archive when navigating to directory in browser #1716

Closed syamajala closed 1 month ago

syamajala commented 1 month ago

legion_prof archive should create an index.html with this in it:

<html>
<script>
window.onload = function() {
  var prof = location
  if(location.protocol !== 'https:') {
    prof = location.replace(`https:${location.href.substring(location.protocol.length)}`);
  }
  window.location.replace("https://legion.stanford.edu/prof-viewer/?url="+prof.href);
}
</script>
</html>

Then we can just load an archive when navigating to the directory on sapling. See this as an example: http://sapling2.stanford.edu/~seshu/legion_prof/

syamajala commented 1 month ago

Not sure if we should embed the html file directly in archive_data.rs as a string, but here is a patch:

diff --git a/src/archive_data.rs b/src/archive_data.rs
index da61fd7..a97d839 100644
--- a/src/archive_data.rs
+++ b/src/archive_data.rs
@@ -254,6 +254,19 @@ impl<T: DeferredDataSource> DataSourceArchiveWriter<T> {
             }
         });

+        std::fs::write(self.path.join("index.html"),
+                       "<html>
+<script>
+window.onload = function() {
+  var prof = location
+  if(location.protocol !== 'https:') {
+    prof = location.replace(`https:${location.href.substring(location.protocol.length)}`);
+  }
+  window.location.replace(\"https://legion.stanford.edu/prof-viewer/?url=\"+prof.href);
+}
+</script>
+</html>")?;
+
         Ok(())
     }
 }
elliottslaughter commented 1 month ago

I'm happy to take this as a PR. The file seems sort enough that for now I'm ok with just embedding the string like that.