fossunited / falcon

A service that execute code in any programming language in a sandboxed environment.
MIT License
42 stars 6 forks source link

Make it easy to integrate livecode with existing tutorials and posts #15

Open anandology opened 3 years ago

anandology commented 3 years ago

People typically write tutorials with code snippets. What if the code snippets can become live by adding a couple of javascript?

Here is the plan:

<script type="text/javascript" src=".../livecode.js"></script>
<script type="text/javascript">
    var LIVECODE_RUNTIME = "python";
    var LIVECODE_SELECTOR = "pre";
    var LIVECODE_URL = "https://livevode.example.com";

</script>

On load, it will convert all <pre> elements into livecode editors. Users will be able to click run to execute that code. This could be added to any webpage.

It may be possible to find the LIVECODE_URL automatically from the location of the script tag. Python has __file__ to find the path of current module, we need something like that for JS. John Resig has suggested a hack to get something close. It would be interesting to try.