<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vista &#187; Coding</title>
	<atom:link href="http://blogs.bluegumtree.co.uk/vista/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.bluegumtree.co.uk/vista</link>
	<description>The view from down here is amazing</description>
	<lastBuildDate>Sat, 24 Jul 2010 00:01:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Selective Autoredirection</title>
		<link>http://blogs.bluegumtree.co.uk/vista/2010/07/13/159</link>
		<comments>http://blogs.bluegumtree.co.uk/vista/2010/07/13/159#comments</comments>
		<pubDate>Tue, 13 Jul 2010 22:30:34 +0000</pubDate>
		<dc:creator>sheilaellen</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[redirection]]></category>

		<guid isPermaLink="false">http://blogs.bluegumtree.co.uk/vista/?p=159</guid>
		<description><![CDATA[Imagine you have two versions of the same site and one of them is optimised for mobile devices.  Aside from the root folder, the URL pattern is identical for both  versions so to map between the versions you simply add or remove  &#8220;/mobile&#8221;:

http://www.mysite.com
http://www.mysite.com/mobile

Most pages on each version have a matching partner on the [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you have two versions of the same site and one of them is optimised for mobile devices.  Aside from the root folder, the URL pattern is identical for both  versions so to map between the versions you simply add or remove  &#8220;/mobile&#8221;:</p>
<ul>
<li>http://www.mysite.com</li>
<li>http://www.mysite.com/mobile</li>
</ul>
<p>Most pages on each version have a matching partner on the other but, importantly, this isn&#8217;t the case for <em>all</em> pages.</p>
<p>Although you have a version optimised for mobile devices, you can&#8217;t be sure that they&#8217;ll always land on it when they visit your site so you want to:</p>
<ul>
<li>detect mobile devices when they land on your site</li>
<li>automatically redirect them to the mobile version if they&#8217;ve landed on the default version but <em>only </em>if a mobile version of that page actually exists.</li>
</ul>
<p>Ideally, in order to avoid swapping a perfectly good page for a 404 error you want to make the check <em>before</em> initiating the redirection.  You don&#8217;t have access to the Apache config files but you can use .htaccess files.</p>
<p>I&#8217;ve been puzzling over this conundrum for a while, trying to find a solution that has as little impact on the rest of the system, aside from doing what it&#8217;s very specifically required to do, and doesn&#8217;t open up a cross-site scripting vulnerability.  Last night, I think I cracked it and as I found very little on this myself when scouring the web, I&#8217;ll share it here.  Hopefully if you spot any problems with it or &#8211; even better &#8211; ways to improve upon it, you&#8217;ll let me know.</p>
<p>This code goes in an .htaccess file in the root of http://www.mysite.com/.  Further up the file, a check has already been made to determine whether or not the user agent is a mobile device and if it is, the value of an environment variable called $IS_MOBILE has been set to &#8220;true&#8221;.  The ErrorDocument for 404 errors has also been set.</p>
<p><code><br />
# Activate the RewriteEngine<br />
RewriteEngine on<br />
</code><code><br />
# Set the base to root<br />
RewriteBase /<br />
</code><code><br />
# Check whether it's a mobile device<br />
RewriteCond %{ENV:IS_MOBILE} ^true$ [NC]<br />
</code><code><br />
#  Check that the URL isn't already going to the mobile version<br />
RewriteCond %{REQUEST_URI} !^/mobile/ [NC]<br />
</code><code><br />
# Capture the part of the URL that follows after the base, prepend it with "/mobile/" and<br />
# assign the new string to an environment variable called $MOBILE_TARGET_URL;<br />
# Also assign the un-prepended captured value to an environment variable called<br />
# $MOBILE_ORIGINAL_URL; Chain this rule to the next one.<br />
RewriteRule ^(.*)$ - [E=MOBILE_TARGET_URL:/mobile/$1,E=MOBILE_ORIGINAL_URL:$1,C]<br />
</code><code><br />
# Concatenate the $DOCUMENT_ROOT and $MOBILE_TARGET_URL together<br />
# and check whether that maps to either a directory or a file<br />
RewriteCond %{DOCUMENT_ROOT}%{ENV:MOBILE_TARGET_URL} -d [OR]<br />
RewriteCond %{DOCUMENT_ROOT}%{ENV:MOBILE_TARGET_URL} -f<br />
</code><code><br />
# If it does, redirect to the user to the mobile version<br />
RewriteRule ^.*$ %{ENV:MOBILE_TARGET_URL} [R,L]<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.bluegumtree.co.uk/vista/2010/07/13/159/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dual Eclipse</title>
		<link>http://blogs.bluegumtree.co.uk/vista/2010/06/04/148</link>
		<comments>http://blogs.bluegumtree.co.uk/vista/2010/06/04/148#comments</comments>
		<pubDate>Fri, 04 Jun 2010 08:32:12 +0000</pubDate>
		<dc:creator>sheilaellen</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Code Editor]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Multiple Monitors]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blogs.bluegumtree.co.uk/vista/?p=148</guid>
		<description><![CDATA[Usually I code in Eclipse.  It saves me a lot of time, especially thanks to plugins such as oXygen and Mylyn.  However, it&#8217;s been frustrating me for a while that although I can pop-out individual Views and position them on my second monitor, it didn&#8217;t seem possible to open a second instance of the [...]]]></description>
			<content:encoded><![CDATA[<p>Usually I code in Eclipse.  It saves me a lot of time, especially thanks to plugins such as <a title="oXygen plugin for Eclipse" href="http://www.oxygenxml.com/eclipse_plugin.html" onclick="pageTracker._trackPageview('/outgoing/www.oxygenxml.com/eclipse_plugin.html?referer=');">oXygen</a> and <a title="Mylyn Eclipse plugin" href="http://www.eclipse.org/mylyn/" onclick="pageTracker._trackPageview('/outgoing/www.eclipse.org/mylyn/?referer=');">Mylyn</a>.  However, it&#8217;s been frustrating me for a while that although I can pop-out individual Views and position them on my second monitor, it didn&#8217;t seem possible to open a second instance of the same View. I was wrong!  Just select &#8220;New window&#8221; from the &#8220;Window&#8221; menu.  It seems to have full functionality, you can even select an entirely different Perspective, if you wish. Simples! As <a title="Aleksandr Orlov on Compare the Meerkat" href="http://www.comparethemeerkat.com/meet-team" onclick="pageTracker._trackPageview('/outgoing/www.comparethemeerkat.com/meet-team?referer=');">Aleksandr Orlov</a> would say :)</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;"><strong>Aleksandr Orlov</strong></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.bluegumtree.co.uk/vista/2010/06/04/148/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Karmic Eclipse</title>
		<link>http://blogs.bluegumtree.co.uk/vista/2010/01/16/124</link>
		<comments>http://blogs.bluegumtree.co.uk/vista/2010/01/16/124#comments</comments>
		<pubDate>Sat, 16 Jan 2010 22:21:01 +0000</pubDate>
		<dc:creator>sheilaellen</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[bug fixes]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[karmic koala]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blogs.bluegumtree.co.uk/vista/?p=124</guid>
		<description><![CDATA[After upgrading Ubuntu to Karmic Koala I experienced a few problems getting Eclipse to work properly &#8211; mostly buttons that clicked but triggered nothing.  Thankfully, Chris Chrisostomu had already published a blog post on the matter, including instructions for a potential fix that certainly seems to have sorted it out for me:
http://mou.me.uk/2009/10/31/fixing-eclipse-in-ubuntu-9-10-karmic-koala/
My thanks go [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading Ubuntu to Karmic Koala I experienced a few problems getting Eclipse to work properly &#8211; mostly buttons that clicked but triggered nothing.  Thankfully, Chris Chrisostomu had already published a blog post on the matter, including instructions for a potential fix that certainly seems to have sorted it out for me:<br />
<a href="http://mou.me.uk/2009/10/31/fixing-eclipse-in-ubuntu-9-10-karmic-koala/" onclick="pageTracker._trackPageview('/outgoing/mou.me.uk/2009/10/31/fixing-eclipse-in-ubuntu-9-10-karmic-koala/?referer=');">http://mou.me.uk/2009/10/31/fixing-eclipse-in-ubuntu-9-10-karmic-koala/</a></p>
<p>My thanks go to Chris for writing it up so clearly.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.bluegumtree.co.uk/vista/2010/01/16/124/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
