Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Skulpt #562

Open
hpgmiskin opened this issue Sep 12, 2016 · 1 comment
Open

Python Skulpt #562

hpgmiskin opened this issue Sep 12, 2016 · 1 comment

Comments

@hpgmiskin
Copy link

I am looking to integrate Skulpt with Brackets to allow Python code to be executed. Skulpt is a Javascript implementation of Python which means it can be executed on the web. The Skulpt library can provide a graphical output and is used by Trinket.

  1. How would you suggest that I include the Skulpt library code? It is packaged for production using a Python script therefore it does not seem sensible to include the whole repository as a submodule.
  2. Where in the codebase would be the best place to add the Python execution functionality? I will need to add a run button to the interface to initiate code execution but for the logic it would be good to put this in a sensible location.
  3. Is there any other help or advise people can provide? Maybe you think this is a bad idea or have noticed a particular issue? What would be your first thoughts is you were undertaking this development?
  4. Would anyone like to help?
@humphd
Copy link

humphd commented Sep 13, 2016

I have two thoughts on how I'd approach this.

  1. We've got a good example of what you want to do in the form of our LESS and Markdown transformations. The basic idea is that if we see a *.less or *.md file being saved to disk, we also generate an associated *.css or *.html file. You can see how I did this here: Add Markdown and LESS preprocessors #465

  2. You could inject the necessary scripts into the preview (and the published version) such that your Python scripts get automatically run when the page loads or something. Assuming that there is some mechanism in Skulpt to locate, parse, and run python code within a web page, you'd just need to have the necessary parser and runtime scripts get auto-injected and started on page load within the preview iframe. To do that you'd want to add a new remote script that would get injected here: https://github.com/mozilla/brackets/blob/master/src/extensions/default/bramble/lib/PostMessageTransport.js#L194-L198. You can look at https://github.com/mozilla/brackets/blob/master/src/extensions/default/bramble/lib/MouseManagerRemote.js as one such example.

No matter how you approach this, you are going to need to make changes within https://github.com/mozilla/brackets vs. this repo--the Bramble editor/preview iframe gets hosted by Thimble, but the code isn't here.

You might also decide that you want to hack this in at a lower level than what I've described above (e.g., you might want to change the server to assume python files are being requested, and serve .js scripts when they are asked for via URLs). If that's the case, forking Bramble and doing that might be the easiest.

Let me know if you have questions about the above. It's doable, but it will require some surgery on our code to make it happen, and not all of it is easy to find. I'm happy to guide you here if you have questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants