From ffa7409b16bf309d84d3cb306cf5540833363791 Mon Sep 17 00:00:00 2001 From: Brad Choate Date: Mon, 26 Apr 2010 13:03:43 -0700 Subject: [PATCH] Updates to disable iMT UI by default for iPad. Also added useragent detection for Palm Pre. --- CHANGES.txt | 10 +++++++++- README.txt | 18 ++++++++++++++++-- plugins/iMT/iMT.pl | 19 +++++++++++++------ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8d6fb42..11eaedb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +# Version 1.11 - April 26, 2010 + +* Recognize user agent for Palm Pre +* Disable iMT behavior for iPad (can be reversed using a config setting "iMTForiPad 1") + + # Version 1.1 - March 3, 2010 * Updated for MT 5. @@ -5,15 +11,17 @@ * A fix for running in persistent environments. * Styling fix for menus affecting iPhone OS 3.0 and later. + # Version 1.02 - June 4, 2008 * Fix for MT 4.2 + # Version 1.01 - September 10, 2008 * Support for Opera Mini. + # Version 1.0 - September 10, 2008 * Initial release. - diff --git a/README.txt b/README.txt index c4f3de9..14b4b2c 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ iMT, a Plugin for Movable Type -Version 1.1 +Version 1.11 This plugin will provide a more natural user interface for Apple's iPhone and iPod touch products. @@ -11,7 +11,21 @@ Once installed, you can access your Movable Type installation from your iPhone or iPod touch and it should display the new user interface automatically. No other configuration is required. +This plugin recognizes several mobile devices/browsers, including: + +* iPhone (all models) +* iPod touch (all models) +* Opera Mini +* Palm Pre +* Android phones +* Google Nexus One + +The plugin does not enable a mobile interface for Apple iPad. If however, +you want to use the iMT interface for iPad, you will need to add this +configuration setting to mt-config.cgi: + + iMTForiPad 1 + This plugin has been released under the terms of the GNU Public License, version 2.0. - diff --git a/plugins/iMT/iMT.pl b/plugins/iMT/iMT.pl index 9d9fa93..573a7ff 100755 --- a/plugins/iMT/iMT.pl +++ b/plugins/iMT/iMT.pl @@ -12,7 +12,7 @@ package MT::Plugin::iMT; my $enabled = 0; my $orig_alt_tmpl_path; -our $VERSION = '1.1'; +our $VERSION = '1.11'; my $plugin = __PACKAGE__->new({ name => "iPhone / iPod touch UI Support", author_name => "Walt Dickinson, Brad Choate", @@ -80,13 +80,20 @@ sub init_request { if ($app->isa('MT::App::CMS')) { # A bit of User Agent sniffing to determine if MT should # be using our AppleWebKit mobile interface. - # Using keyword detection provided by Apple: + # Using keyword detection guidance provided by Apple: # http://trac.webkit.org/projects/webkit/wiki/DetectingWebKit # Adjusted 'Mobile/' to 'Mobile[ /]' to match for Nexus One which - # supplies no device identifier following the 'Mobile' keyword - if (my $ua = $ENV{HTTP_USER_AGENT}) { - if ((($ua =~ m!AppleWebKit/!) && ($ua =~ m!Mobile[ /]!)) || - ($ua =~ m!Opera Mini/!)) { + # supplies no device identifier following the 'Mobile' keyword + # Disabled iMT by default for iPad; can be overridden using + # 'iMTForiPad' config setting. + if (my $agent = $ENV{HTTP_USER_AGENT}) { + my $is_iphone = ($agent =~ /AppleWebKit/ && ( $agent =~ m!Mobile[ /]! || $agent =~ /Pre/ )) || ($agent =~ m!Opera Mini/!); + if ($is_iphone && (! $app->config('iMTForiPad'))) { + if ($agent =~ /iPad/) { + $is_iphone = 0; + } + } + if ($is_iphone) { $enabled = 1; # Redirect 'dashboard' or 'default' modes to iphone_main