[jbosstools-dev] PoC : Browser Refresh in conjunction with the Chrome LiveReload Extension

Xavier Coulon xcoulon at redhat.com
Thu Jan 3 04:26:18 EST 2013


[Adding cc:]
/Xavier



On Jan 3, 2013, at 9:28 AM, Xavier Coulon wrote:

> Hello and Happy New Year to everyone!
> 
> Between F2F meeting and Christmas vacations, I spend some time working on a PoC of LiveReload from Eclipse. 
> [My first iteration was using the Chrome Remote Debugging Protocol, but since it required starting Chrome with an extra "--remote-debugging-protocol" arg and it was specific to Chrome, I reworked on it to turn what's described below]
> 
> The PoC implements the server-side of the LiveReload protocol (based on websockets).
> 2 things to get it working (once you've checkout the plugin repo on github and started an Eclipse Runtime): 
> 
> * on the Browser side, the user needs to install the LiveReload extension
> * on the Eclipse side, the user starts his AS server and then clicks on "Enable LiveReload" on the server menu. 
> 
> Then, when the use edits html/js/css content, the files are published by the server adapter on the AS server and then, the browser is notified of the (web) resource changes (with URL and not file location). Then, the extension decides which part of the page needs to be refreshed.  
> Of course, the notification occurs *after* the html/js/css files have been published on the server ;-)
> 
> # A few notes: #
> 
> * this PoC only works from Server Adapter level, as it made more sense and helped me resolve the file URL from the server host/port and the application deployment context.
> See the "refresh" command description (https://github.com/mockko/livereload/blob/master/docs/WebSocketProtocol.md#file-modified): the command must include the URL of the changed file.
> To get notified that the server deployed the resource, I use a PublishAdapter, so this is pure generic WTP API.
> The only JBossAS-specific thing I use here is when I need to retrieve the server port:
> 	server.getAttribute("org.jboss.ide.eclipse.as.core.server.webPort", "8080")
> but there may be a more portable manner to do it.
> 
> - one thing I did not get to work (yet) was the Firefox "LiveReload" extension. It looked as if the browser extension was disconnecting immediately after connexion, so there was no channel I could use to send the "refresh" command. That should be solved, though.
> 
> * the http://livereload.com/ doc mentions this hack:
> 	"How do you stop that snippet from making it into production, then? Well, simple: add an IF and check location.host, and then feel free to commit and deploy."
> which means that it should be possible to also support Mobile devices and BrowserSim if no extension can be installed on them.
> 
> The code is at the same location as before:  https://github.com/xcoulon/jbosstools-pagereload (the old plugin has been moved to another branch)
> There's another screencast for that: https://www.youtube.com/watch?v=MWoZIQwitSs 
> As usual, sound is low and accent is strong, but I'll try to fix that in the future ;-)
> 
> # Further developments #
> 
> Now, this also opens question of support to even wider file types, such as SASS/LESS instead of plain CSS:
> 
> * should we provide editors for those types (usual stuff: syntax coloring, validation, content assist, navigation) ?
> * as far as SASS is concerned, there's no Java implementation of the processor. Would writing one in Java help us when it comes to processing SASS files to convert them into CSS and publish them ? The only way to do it is to invoke the ruby gem with JRuby - I haven't tried it yet, though.
> 
> 
> 
> All feedback is welcome.
> 
> Best regards,
> /Xavier
> 
> 
> 
> 
> _______________________________________________
> jbosstools-dev mailing list
> jbosstools-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jbosstools-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jbosstools-dev/attachments/20130103/106d1117/attachment.html 


More information about the jbosstools-dev mailing list