Monday, July 12, 2021

Glimmer Desktop App Images Can Auto-Download on the Web with Glimmer DSL for Opal

Imagine this scenario. You built this baseball game ticketing management desktop app for clerks to accept ticket purchases over the phone. You already applied branding to it. Now, you want to take it online (i.e. webify).

Thankfully, Glimmer DSL for Opal lets you run all the GUI code on the web without changing a single line of code. But, here is the kicker! What about images!? After all, desktop apps simply access them locally. How do you let a web framework like Rails expose those images as downloadable links online!?!

Again! Glimmer DSL for Opal v0.15.1 comes to the rescue! It can auto-detect all images in gems (representing desktop apps) that depend on Glimmer, copy them to the Rails assets directory, and thus turn them into downloadable images (of course, security measures can be added to whitelist them if needed, but I doubt that would be important for images that were already published as part of app gems publicly anyways)










Original Desktop Version written in Glimmer DSL for SWT (ignore the stretching difference for now; platform differences are to be expected, and the web version can always be tweaked via separate CSS):









The only bits of the code setting the images are the `image` and `background_image` properties on `shell`, which set the favicon and background image respectively (on the desktop, the favicon is simply the app icon). They in turn rely on File.expand_path, which is where the automation happens that pre-downloads available image web links (auto-detected from loaded gems depending on `glimmer-dsl-swt` on the Rails server-side with a json controller action) and matches them on supplied relative paths.

Think of Glimmer DSL for Opal in its Alpha stage as this mad scientist alchemical lab of crazy ideas manifesting into success. It might slowly change the face of web development as we know it with very small & simplistic yet greatly effective ideas. If you got more ideas to pitch, please suggest in issues or pull requests.

Happy Glimmering!

No comments: