Glimmer DSL for Opal v0.14.0 just shipped with a base-case implementation of the Ruby Net::HTTP get method API (alpha version), missing from Opal, which was implemented using jQuery.
The point is that Ruby network code written for a desktop application using `net/http` now has support in Glimmer DSL for Opal (even if this is not GUI since `net/http` is fundamental and was missing from Opal), specifically supporting the Weather app sample written for Glimmer DSL for SWT that calls out to the openweathermap.org API.
Here are the app screenshots showing how it runs on both the Web and Desktop (with some stylistic variations to be expected due to the Web varying from the Desktop, and Glimmer DSL for Opal not supporting the Canvas Shape DSL yet [use of rectangle keyword below], which can be mitigated with CSS on the Web if needed):
This is the first Glimmer DSL for Opal sample that performs a network call over the Internet using the Ruby Net::HTTP API. This should hopefully open the floodgates in the future to real app development with calls to Net::HTTP.get and Net::HTTP.post_form to communicate with Rails applications.
3 comments:
Nice! Thx for sharing
Is it possible to use browser geo location or other services like camera?
Thank you.
Geolocation/Camera is beyond the scope of that sample, which is a GUI library sample only.
That said, Opal lets you use in Ruby any features you have in JavaScript in a web browser, including geolocation and camera. Learn more about Opal at Opalrb.com
If you wanted to build an app that does geolocation on the desktop too, you'd just use a JRuby or Java library for geolocation/camera (e.g. MaxMind GeoIP2 API).
Last but not least, if you need to do geolocation/camera on both desktop and web. You can write your own library around geolocation (and another around camera) that uses a JRuby library on the desktop and a JS library in Opal, and then hide the details with just pure Ruby API code that is the exact same code in both desktop and web. That is pretty much what Glimmer does for GUI. The sky is the limit on the number of libraries that could pop up with this approach.
Still, handling both desktop and web is a tough problem in general, but all the solutions to it that I saw elsewhere demanded learning odd XML syntaxes, languages not as nice as Ruby, or complexities in setting things up and getting started.
Glimmer DSL for Opal aims to provide a better and simpler option that relies on the familiarity of Ruby. It is still an early alpha, so prototyping apps in it and providing feedback is highly appreciated.
Post a Comment