freeCodeCamp / COM1000

freeCodeCamp's deprecated challenge editor
19 stars 16 forks source link

Feature: Pick local file, Reload File #5

Closed SaintPeter closed 8 years ago

SaintPeter commented 8 years ago

From @SaintPeter on November 24, 2015 18:46

Since we're able to write to the local file system, it would be nice to be able to read from it as well.

If we load a local file, we should then be able to "reload" the file, so we can quickly pick up changes we've made by directly editing the JSON.

Low Priority.

Copied from original issue: FreeCodeCamp/ChallengeOMatic1003#26

SaintPeter commented 8 years ago

From @terakilobyte on November 25, 2015 1:47

The file loaded in the browser isn't the file from the file system, it's a copy.

I can think of a way but it requires adding a watcher to look for changes to any files in the directory and sending that data over sockets. Thinking about streaming the data back and forth instead of caching all changes in the client until the export button is hit..., the application will have to completely change how data is represented internally.

SaintPeter commented 8 years ago

I'm not proposing a watcher, I'm proposing a reload file button. What I was thinking is that rather than "upload" the file, we could just as easily stream it up from the server, then allowing us to reload it on demand.

It's just a thought.

SaintPeter commented 8 years ago

From @terakilobyte on November 25, 2015 12:16

Streaming up from the server or down to the server will require sockets. The HTTP request/response cycle is just not the answer as once the cycle is finished the contract has been fulfilled by both parties.

For a reload button, we can use the activeFile information and ask for that file from the server though.

SaintPeter commented 8 years ago

@terakilobyte Why not just request it via AJAX and the filename?

New API endpoint: /filelist - lists out the *.JSON files in the output folder. New Component: Filelist, takes that list and display is in some nice, select-able way. New API endpoint: /sendFile/:filename - returns a file from the output folder

Reload just makes a request against sendFile, same as load a file does.

terakilobyte commented 8 years ago

The way you mentioned it I thought you wanted the server to stream to the browser any changes outside of the browser, say to the raw json. There is no way for the server or browser to know if a file has changed without some kind of watcher. Also, unless we do a very naive timer to constantly request the file (a bad idea for many reasons), there is no way for the server to notify the browser of a change.

SaintPeter commented 8 years ago

Let's not use any technical terms at all, because that's confusing the issue. Let me say it this way:

Mostly this is about reducing friction and streamlining the interface. Say I am testing a PR, I can easily load a file into COM and/or re-load it so I can see the elements without loading it on the site. This is certainly not a critical feature. That it saves locally is already awesome.