Open refi64 opened 7 years ago
When the playground was built there were some discussion about how much of an editor for the full development cycle it should be.
The big scenario would requite to handle all this:
A small scenario will be to add an option to the command
$ crystal play [options] [file]
So the initial code will be autosaved to the file again. Maybe something like: --editor
-w
-s
In autosaving sessions, maybe, the localstore should be disabled.
An intermediate scenario would be allow the user to navigate local files and load them as the current code. Without the context of many open files. Which is done in the workbooks but without the autosaving.
$ tree playground
playground
└── foo.cr
$ crystal play
# open http://localhost:8080/workbook
Which scenario where you thinking about?
Would it be possible to add an option (or default) for the workbook to load files recursively?
The code here: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/tools/playground/server.cr#L290
private def files
Dir["playground/*.{md,html,cr}"]
end
Would just need to become:
private def files
if recursive_workbook
Dir["playground/**/*.{md,html,cr}"]
else
Dir["playground/*.{md,html,cr}"]
end
end
A more advanced solution would create the file tree in the web browser also.
One big feature of this, you can create a symlink ./playground -> ./src
and easily load any of your source files in the playground - browsing through the workbook.
I think recursively loading files in subdirectories and mapping them to the appropriate paths should be the default.
This would be handy for organizing more extensive workbook collections. #4462 comes to mind...
Right now, no one's trying to host the playground online or anything. What if it came with a file browser, so you could actually use it to open up files and also save them? It would all be done server-side.
Obviously, if someone's stupid enough to leave it running on a public port, then that's a major security risk. Then again, if they're stupid enough to leave it running on a public port, they're probably screwed anyway (dirtycow, anybody?).