ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 22 Apr 2018 08:57:08 +0200Sagecell with code hosted in GitHubhttps://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/I would like to embed a Sage Cell in a webpage whose content comes from a GitHub `.py` file, so that changes in this file are immediately shown in the webpage. I have tried to use `javascript` / `jquery` like this (with the standard scripts in the head) and with some variations:
<div class="sage"><script type="text/x-sage" id="sage1"></script></div>
<script>$('#sage1').load("https://rawgit.com/path_to_the_file.py");</script>
and it sometimes work, but not always. I guess it has to do with the order of all the scripts involved in the process. Which would be the most appropiate and clean way to inject such code in a Sage Cell?
**EDIT:** I would like to show the input cell together with the input code, for educational purposes. So the content of the input cell has to be replaced with the content of the `.py` file.Sat, 21 Apr 2018 17:51:40 +0200https://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/Answer by tmonteil for <p>I would like to embed a Sage Cell in a webpage whose content comes from a GitHub <code>.py</code> file, so that changes in this file are immediately shown in the webpage. I have tried to use <code>javascript</code> / <code>jquery</code> like this (with the standard scripts in the head) and with some variations:</p>
<pre><code><div class="sage"><script type="text/x-sage" id="sage1"></script></div>
<script>$('#sage1').load("https://rawgit.com/path_to_the_file.py");</script>
</code></pre>
<p>and it sometimes work, but not always. I guess it has to do with the order of all the scripts involved in the process. Which would be the most appropiate and clean way to inject such code in a Sage Cell?</p>
<p><strong>EDIT:</strong> I would like to show the input cell together with the input code, for educational purposes. So the content of the input cell has to be replaced with the content of the <code>.py</code> file.</p>
https://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/?answer=42118#post-id-42118Why not just:
<script type="text/x-sage">
load('https://rawgit.com/path_to_the_file.py')
</script>
See a (temporary) example at the page: https://sagedebianlive.metelu.net/tmp/plop.html with python file https://sagedebianlive.metelu.net/tmp/plop.py (i do not have a github account, but it shoud work exactly the same).
Sat, 21 Apr 2018 21:40:03 +0200https://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/?answer=42118#post-id-42118Comment by jepstra for <p>Why not just:</p>
<pre><code><script type="text/x-sage">
load('https://rawgit.com/path_to_the_file.py')
</script>
</code></pre>
<p>See a (temporary) example at the page: <a href="https://sagedebianlive.metelu.net/tmp/plop.html">https://sagedebianlive.metelu.net/tmp...</a> with python file <a href="https://sagedebianlive.metelu.net/tmp/plop.py">https://sagedebianlive.metelu.net/tmp...</a> (i do not have a github account, but it shoud work exactly the same).</p>
https://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/?comment=42121#post-id-42121@tmonteil Thank you very much for the answer. It works perfectly. However, I would like to show the input cell and also the input code, for educational purposes. I'll edit the question to include this nuance. Thanks again!Sun, 22 Apr 2018 08:57:08 +0200https://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/?comment=42121#post-id-42121