Ask Your Question
1

Sagecell with code hosted in GitHub

asked 2018-04-21 17:51:40 +0200

jepstra gravatar image

updated 2018-04-22 08:59:48 +0200

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-04-21 21:40:03 +0200

tmonteil gravatar image

Why 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... with python file https://sagedebianlive.metelu.net/tmp... (i do not have a github account, but it shoud work exactly the same).

edit flag offensive delete link more

Comments

@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!

jepstra gravatar imagejepstra ( 2018-04-22 08:57:08 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-04-21 17:51:40 +0200

Seen: 349 times

Last updated: Apr 22 '18