On Sat, 07 Jan 2012 03:13:21 -0800, Patrick Reilly preilly@wikimedia.org wrote:
On Jan 7, 2012, at 2:21 AM, "Daniel Friesen" lists@nadir-seen-fire.com wrote:
On Sat, 07 Jan 2012 01:18:20 -0800, Quim Gil quimgil@gmail.com wrote:
Hi, I have installed the Mobile Frontend extension in my pet project at http://espiral.org
I only get to the mobile view manually, through the link at the footer. Autodetection of mobile browsers doesn't seem to work or I have done / missed something in my installation. I have got feedback from a bunch of users with a bunch of devices, nobody got the mobile view by default and all of them get it when visiting http://en.wikipedia.org
Something that looks different in my installation compared to Wikipedia's is the lack of a redirect to a ".m." URL. I'm actually a bit confused about this. It is mentioned briefly at http://www.mediawiki.org/wiki/Extension:MobileFrontend but it is not clear to me whether this is something supposed to work automagically when installing the extension or whether there is something I need to do with the WURFL database, the LocalSettings.php, the web server...
Other than this the extension works great presenting the mobile view of pages. Thank you very much for your work!
I've been examining the MobileFrontend code myself since I too wanted to use it on a wiki. The MobileFrontend code is written 'very' WMF centric and uses a large number of hacks (which imho aren't acceptable of an extension purporting to be usable outside of WMF). It's a long way away from being usable on a normal wiki.
How so? What would you change?
Well my list of what's wrong with the extension to start with: - ExtMobileFrontend is made into an instance, yet self:: is used all over the extension, it's an instance yet not, static yet not... - The extension relies on an X-Device set from a customized frontend cache despite the fact it already has device detection code in it. Plenty of wikis are not in front of front-end caches. (detection code if you're on the mobile site etc... should be grouped together into a common area and something like ->isMobile() should be used elsewhere) - The WURFL config is messed up, defaulting to the expectation that memcached is running locally. - It loads up the entire WURFL then does absolutely nothing with it. - It doesn't detect the mobile server url on it's own (more frontend cache reliance) - It uses a ill-conceved config for the mobile url '.m.' instead of something like $wgMobileServer = "//en.m.wikipedia.org"; this makes it non-portable to other patterns like say m.example.wiki.com. - The code for converting a normal wiki url to a mobile site url is faulty. Horrid string replacements are used, code is duplicated everywhere when it should be common, and code like `$hostParts = explode( '.', $parsedUrl['host'] ); $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2];` mean that it'll completely screw up for .co.uk domains, third-level registered domains, wiki. subdomains, etc... - It does everything using dom manipulation on the output causing a reliance on vector and monobook's skin structure making it break in some other skins. (It should implement a skin of it's own) - It seams to make strange assumptions about the existence of a ./w/mobileRedirect.php - The login code seams to assume that every wiki has https:// with a proper ssl certificate instead of using $wgSecureLogin (besides the whole debate about MobileFrontend seemingly reimplementing things already in core or that should be in core) - A number of mobile actions seam to be implemented by letting MediaWiki run through entirely wasting time doing things, then detecting that a mobileaction was used, discarding everything that was done and outputted, then outputting something else (btw: it's also using Article instead of WikiPage in one of those spots). - Small note ->response()->header( 'Location: ' . $location ); should actually probably use OutputPage's redirect or something - Also ->setcookie supports $domain and $prefix arguments, you shouldn't be fiddling around with globals - Things like stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) { are hardcoded into it - I spot a few places where urls are hardcoded instead of using Title - I even see some hardcoded WMF stuff in the extension: $wgMobileFrontendLogo = '//upload.wikimedia.org/wikipedia/commons/1/16/W_logo_for_beta_test_of_Mobile_Frontend.gif';
The key things hurting portability are the reliance on front end caches with customizations, not detecting the mobile url properly, making bad replacements for the mobile url, and trying to hack things out of skin output.
-- ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]