As mobile devices get more popular, it is important for many sites and apps
to provide both a regular (desktop) site and a mobile site. It is currently
difficult to accomplish this with web2py. Plugin jqmobile is great for
mobile devices, but doesn't really work for regular web browsers.
I am determined to find a way to allow web2py to run a desktop and a mobile
version of an app without giving up the ability to byte compile apps. I
think I found a solution, but it will require a couple of patches to the
web2py core first. This first patch will add "is_mobile" to the request
object.
So in your views or controllers, you can just test for a mobile view:
if request.is_mobile:
response.view = 'default/index.mobile'
Of course, you would not be required to do this if my solution for native
web2py support works out, as checking for desktop/mobile views would be done
automatically.
My end goal is to provide an out-of-the-box solution for web2py that will
allow you to make your own mobile layout and mobile views without breaking
backwards compatibility, while still allowing applications to be byte
compiled. My plan is to provide a mobile layout (like plugin_jqmobile's),
along with the existing desktop layout. Then, mobile views would have the
.mobile extension. If the .mobile view isn't available it would fallback to
the standard .html view that is used for desktops.
I am posting this to get the community's opinion on including this
functionality into web2py before I devote my time to actually developing the
solution. Does anyone see any problems with my logic so far, or about the
way the mobile sites are implemented alongside the regular sites?