blockpy-edu / BlockMirror

An interface for dual block/text representation with Blockly
Apache License 2.0
75 stars 28 forks source link

Additional API function and configuration option #16

Open grintor opened 4 years ago

grintor commented 4 years ago

First of all. I want to say that What you have done here is simply amazing. I have been digging in deeply into testing this and trying to understand how all the pieces work together and I can tell this has been a LOT of work. Bravo. I have been using you alpha release, and I have to say it feels like more than an alpha, it seems very stable.

I do have some things I wish for tough. For one, I know that Skulpt supports actually executing the python code and also returning exceptions. It would be really cool to have a check-code api call. At least checking for syntax errors would be nice.

Also, I don't see a way to dictate the toolbox. I see that one gets defined at BlockMirrorBlockEditor.prototype.makeToolbox() but that would be a nice configuration option to have. It would also be really neat to be able to manipulate the toolbox through the API too. Just being able to pass it XML at will and change the tools would be very useful to me.

I also noticed that master is a few commits ahead of release, any chance you will be releasing a beta soon?

Thank you for all your hard work. I really love what you have done here.

Chris

acbart commented 4 years ago

Wow, didn't know anyone was using this! I'd love to hear more about your use case. I may not have many spare cycles to work on this since its the semester and the COVID madness, but I'll see where things are in the next few weeks.

I could add some functionality to connect with Skulpt some more. Do you have a dream API in mind? What would you like to be able to do?

The commit I just made most recently has my latest work on the Toolbar API. I believe this allows you to specify the toolbar by writing Python code. Sorry it's not better documented, and I don't quite remember offhand whether it exposes a really easy way to add new toolboxes. But let me know if you're having trouble and I'll see what I can do with it.

New Toolbar setup: https://github.com/blockpy-edu/BlockMirror/blob/master/src/toolbars.js

How it works with main BlockMirror:

https://github.com/blockpy-edu/BlockMirror/blob/85a0d0b6c2abacc9e789ba49c1750fcf28f31387/dist/block_mirror.js#L755

We should make a new release - I'll try to put that in my todo list soon.

grintor commented 4 years ago

Hey, thanks for getting back to me. Yes I am trying to get it integrated into our platform. I work with Tier2Tickets.com. We offer a software/service for I.T. departments that automatically attaches a ton of diagnostic information, including screenshots of the problem, to each trouble ticket which is submitted to the helpdesk. We built a python sandbox that the IT Department has control of inside their account which allows them to parse the information in the ticket and manipulate it before it gets submitted to the API of their helpdesk ticket systems. So, for example, they can do something like

if "printer" in subject:
    team = "hardware"

or

if "emergency" in message:
      priority = 1

and that way they can automatically triage some of the tickets based on the end-users input.

The problem though has been that the IT departments don't always want to learn programming, or they will make a syntax error and get frustrated. So I was looking for a way to build a more simple interface for this. I found blockly and though that it would be a great option, but was disappointed to learn that the block/python translation was only one directional. Then I found your blockpy project which lead me here.

I am using the release as you have it now, with some minor edits, and it's going pretty well. The only thing I would really love to see is the ability to initialize things first and then pass a reference to them to blockmirror at its initialization. Specifically, it would be great to be able to do something like

let workspace = Blockly.inject('blocklyDiv',
       {toolbox: document.getElementById('toolbox')});
let configuration = {
      'workspace': workspace,
}
let editor = new BlockMirror(configuration);

or something. Maybe the same thing for Skulpt and CodeMirror too would be useful.

The benefit here is that I could initialize the blockly workspace the way I want and I would have a reference to it to talk to its APIs right off the bat.

Other features that I am needing, but I have workarounds for, are the ability to run the python code and get it's output or exception, and the ability to halt long running code that if freezing the browser, like an infinite loop.

Overall though, I think it's going to work really well for what we need it for so there is no need to take time away from your busy schedule to try to implement any of these features any time soon. It looks like I can work around any obstacles I have found.

I am very grateful that you spent the time to put this together and open-source it. Again, it's a very impressive work and I am surprised more people haven't found this gem. We have a 25 endpoint free tier for our software, but if your schools' IT department would like to use our software, I would be glad to give them much more than that for free as a show of gratitude for the work and time this will save us on building out this interface.