Hitting the road with Webmin (and a perl function for detecting mobile user agents)
As I mentioned in a previous post, I’ve been hanging out with a lot of mobile application developers lately. Now, I’ve never made a secret of my disdain for telephones. But seeing the things they’re doing with mobile technology got me to thinking. What’s a cool use for mobile technology that applies to what I’m doing every day with Webmin and Virtualmin? Well, it turns out it’s the same thing that gets me to spend $72/month on a Sidekick. Being able to administer my server, fix customer problems, and deal with email, while traveling…even if there’s no laptop in sight or WiFi in range. So, on our way home from dinner last Tuesday night, Jamie and I chatted about what keeps Webmin and Virtualmin from being useful on our phones. Technically we can login to Webmin via our phones (Jamie has a Treo and I have a Sidekick), the problem is that it’s so slow to load all of the graphics and deal with the frames and menus (not to mention clicking “OK” when any site with more than a few lines of JavaScript eats up all of the memory on my Sidekick and it can’t keep running them), that it’s faster to drop in via SSH (both of our phones also have SSH clients) and do it all on the command line. Despite the horrid little keyboard, this is faster than using the web interface.
So, we came to the conclusion that we needed a new theme just for mobile phones. A theme targeted to the most common operations, and stripped of everything unnecessary, so it would be fast despite the client being slow and limited. But, we’d also have to address the problem of showing that theme only when a mobile client connected, since we can’t reasonably make an AJAX-filled fully graphical theme degrade all the way down to tiny. So, Jamie added some code to detect mobile browsers:
# is_mobile_useragent(agent) # Returns 1 if some user agent looks like a cellphone or other mobile device, # such as a treo. sub is_mobile_useragent { local ($agent) = @_; local @prefixes = ( "UP.Link", # Openwave "Nokia", # All Nokias start with Nokia "MOT-", # All Motorola phones start with MOT- "SAMSUNG", # Samsung browsers "Samsung", # Samsung browsers "SEC-", # Samsung browsers "AU-MIC", # Samsung browsers "AUDIOVOX", # Audiovox "BlackBerry", # BlackBerry "hiptop", # Danger hiptop Sidekick "SonyEricsson", # Sony Ericsson "Ericsson", # Old Ericsson browsers , mostly WAP "Mitsu/1.1.A", # Mitsubishi phones "Panasonic WAP", # Panasonic old WAP phones "DoCoMo", # DoCoMo phones ); local @substrings = ( "UP.Browser", # Openwave "MobilePhone", # NetFront "AU-MIC-A700", # Samsung A700 Obigo browsers "Danger hiptop", # Danger Sidekick hiptop "Windows CE", # Windows CE Pocket PC "Blazer", # Palm Treo Blazer "BlackBerry", # BlackBerries can emulate other browsers, but # they still keep this string in the UserAgent "SymbianOS", # New Series60 browser has safari in it and # SymbianOS is the only distinguishing string ); foreach my $p (@prefixes) { return 1 if ($agent =~ /^\Q$p\E/); } foreach my $s (@substrings, @mobile_agents) { return 1 if ($agent =~ /\Q$s\E/); } return 0; }
So, there’s a quick and dirty perl function (BSD-licensed, like all of Webmin core) that makes detecting a mobile client easy. Of course, there’s more granularity out there than “mobile” or “big” client. That’s where something like WURFL will come in (that’s not gonna happen in Webmin in the short term, but it’ll come later, as our themes get smarter and more dynamic). Anyway, so now that Webmin can detect what kind of client it’s talking to, it can choose a theme to suit the target. We’ve made a new dead simple, zero-graphics, menu-based theme for Virtualmin, that allows really quick administration on even the most limited web client.
Now, as of version 1.328 of Webmin and next weeks version of our themes, you’ll get a different interface based on how advanced your client is. Small clients will see something like this:

While big clients will see one of the all-singing, all-dancing, maybe AJAX-filled, themes with images and such. Everybody wins, and now I don’t really need an SSH client on my next phone–this interface is faster, and if I really, really, need a shell, I can wing it with the non-interactive CGI-based Command Shell module in Webmin. The neat thing is that this will also work in Usermin, so we’ll have a kick ass webmail client that is fast and clean in our mobile devices. I’m glad I’ve been thrown in with a bunch of mobile guys lately. It’s an eye-opening experience.


