-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clients reconnect better, basic save/load events.
- Loading branch information
1 parent
34ce544
commit 6f2b7f2
Showing
4 changed files
with
71 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,57 @@ | ||
# never-f5 | ||
|
||
I need to make a quick mockup of a site, or page/SPA/app concept. Or I want to play with a new javascript library. | ||
I need to make a quick mockup of a site, or page/SPA/app concept. | ||
|
||
I don't want a node.js based server to get auto-refresh on save, or nice stuff like that. | ||
Or work with a designer quickly iterating HTML changes to a design, and the | ||
"save", "switch to a browser window", "press f5" loop is getting pretty old. | ||
|
||
I want auto refreshing, fast, without needing to install a massive node.js | ||
multi-layer complex beast. | ||
|
||
I want it to be fast. I want a stand-alone binary I can install anywhere. | ||
|
||
(I want an excuse to learn rust...) | ||
(I want an excuse to code in rust...) | ||
|
||
## Voila! | ||
## ta DAA! Here is "never-f5" to save the day. | ||
|
||
1) Serve a directory locally. (Port 8088) | ||
2) Notify file changes by websocket | ||
3) embed a websocket script into pages to auto refresh. | ||
|
||
Makes quick page design / scripting a million times nicer. WIP. | ||
Makes quick page design / scripting a million times nicer. | ||
|
||
You can access normal static files as normal: | ||
|
||
/index.html | ||
|
||
for instance. But if you add a `'!'`, then you get the auto-refresh websocket magic attached. | ||
for instance. But if you add a `'!'`, then you get the auto-refresh websocket | ||
magic attached. | ||
|
||
/index.html! | ||
|
||
Now, whenever any files in that directory are changed, it'll refresh the page. | ||
|
||
## NEXT STEPS: | ||
|
||
0) Tidying up - general fixing / cleaning / organising / documenting / refactoring. | ||
0) *Commandline arguments.* | ||
Need to have port & ip options, directory, websocket address, and injection | ||
file, to allow easy inserting extra callbacks, doing clever CSS stuff, | ||
event debounce time, etc. | ||
|
||
1) I don't want it to refresh UNLESS YOU WANT IT TO. So there should be a hook to allow it to call a user-defined 'file-changed' callback in the page. This should allow you to save state (if you want to). | ||
1) *Tidying up* - general fixing / cleaning / organising / documenting / refactoring. | ||
|
||
2) Make sure all the actix-web settings are tuned for this kind of work. We aren't expecting a million requests and hundreds of simultanious connections. - THAT SAID - It should allow you to have a bunch of different browsers, devices, etc. all viewing the same document. | ||
|
||
3) Have a 'save-state/load-state' kind of route, so that you could make changes on one device, and see them reflected on multiple devices instantly - is this a good idea? | ||
2) Have a `save-state/load-state` kind of route, so that you could make changes | ||
on one device, and see them reflected on multiple devices instantly - /is this a | ||
good idea?/ | ||
|
||
## Current State: | ||
|
||
Very 'Work in Progress'. I hacked this together very quickly, learning Rust and Actix-Web in the process. | ||
It currently only works when serving directly in the current directory - so what I need, but I could see need for more configurability. | ||
|
||
So it's technically usable for me now, already, which is pretty awesome. | ||
I put this together pretty quickly, learning Rust and Actix-Web in the | ||
process. It seems to work very well. | ||
|
||
I put this on github now simply as an off-site backup from my laptop - and in case anyone else wants a similar tool. | ||
## Saving state. | ||
|
||
It could really do with tidying up a lot. | ||
Since it's sometimes nice to have state in web apps or pages (who knew, right) | ||
there's a couple of callbacks you can add to your page: `window._autoreload_save` | ||
and `window._autoreload_load`, which you can use to save and reload your state | ||
to local storage or whatever before and after reloads. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters