<?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>The One Man Mission &#187; web design</title>
	<atom:link href="http://www.theonemanmission.com/tag/web-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theonemanmission.com</link>
	<description>Web design, SEO and development by Phil Owen</description>
	<lastBuildDate>Tue, 07 Sep 2010 17:46:21 +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>Make Your Website Mobile-Friendly</title>
		<link>http://www.theonemanmission.com/featured/make-your-website-mobile-friendly/</link>
		<comments>http://www.theonemanmission.com/featured/make-your-website-mobile-friendly/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 22:57:18 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://theonemanmission.com/?p=493</guid>
		<description><![CDATA[Small business owners have been advised that more than 10m people (in the UK alone!) are using their phone to surf the internet, according to figures released by Nielsen.
The data means that around 20% of those with a mobile use it to access websites and that all small businesses must have a site that is [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Small business owners have been advised that more than 10m people (in the UK alone!) are using their phone to surf the internet, according to figures released by Nielsen.</p>
<p>The data means that around 20% of those with a mobile use it to access websites and that all small businesses must have a site that is compatible with mobile technology.</p>
<p>There are now 6.2m smartphone users in the UK after 600,000 people bought one of the latest technology phones since last summer.</p>
<p>It&#8217;s a fact:</p>
<blockquote>
<h3>10 million people (in the UK) are accessing the internet on mobiles</h3>
</blockquote>
<p>&#8220;The era of the handset as a truly multi-media device on a mass-market level lies somewhere on the horizon,&#8221; said Edward Kershaw, head of mobile media at Nielsen.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">So I set out to find just <em>how</em> this was accomplished.   I personally have a potentially large commercial website due for launch in a month or two, and have always wanted to find out just how I was going to make it friendly to mobile users &#8211; especially when you learn that there are more people in the world who own a mobile device than who own a credit card.  Big numbers.  Also, take a look at the Japanese at the moment (who are normally two steps ahead of the Western world when it comes to technology) &#8211; only a small percentage now have home PC&#8217;s, as mobile devices are the norm for all their internet / communication needs.<img class="alignright size-medium wp-image-494" style="border: 0pt none;" title="Your Site On A Mobile" src="http://theonemanmission.com/wp-content/uploads/2010/02/iphone3gs-138x300.jpg" alt="" width="138" height="300" /></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Let&#8217;s get stuck in:</p>
<p style="text-align: justify;">You may think that since you write valid code and separate structure from presentation at all times, your site already works great on mobile devices. You may also think bad things don’t happen to good people. In both cases, you’d be wrong.</p>
<p style="text-align: justify;">The fact of the matter is that the state of HTML rendering in the wireless world is all over the map right now. Some browsers, like Pocket Internet Explorer, are actually pretty good at parsing through standard web pages. Others can scarcely handle layout rules at all. And still worse are the mobile browsers that load all CSS and javascript files, attempt to use them, and screw up the experience even more in the process.</p>
<p style="text-align: justify;">What’s really needed until HTML/CSS/JS support is improved in mobile devices is a little server-side filtering. By pulling out everything a mobile device can possibly choke on before it even gets to the mobile device, we can create a mobile version of our site which is not only viewable on more devices but is much quicker to download as well.</p>
<p style="text-align: justify;">And you know what? The mobile version of your site is probably going to be much easier on screenreaders too.</p>
<p style="text-align: justify;">
<h3 style="text-align: justify;">Four easy steps</h3>
<p style="text-align: justify;">Outlined below are the four steps to get this done in a matter of minutes, provided you are in an Apache environment and can run PHP.   If you’re not, these steps can easily be adaptable to other technologies.</p>
<p style="text-align: justify;">
<h4 style="text-align: justify;">Step 1:  Set up a domain mirror</h4>
<p style="text-align: justify;">If your site lives at</p>
<p style="text-align: justify;">
<p><code>www.theonemanmission.com</code></p>
<p>you’re going to want to set up a subdomain at:</p>
<p><code>mobile.theonemanmission.com</code></p>
<p>How you accomplish this is usually pretty straightforward but differs depending on your host. You want to set up your subdomain as a “mirror” of your main site, meaning the subdomain is really just pointing to your existing site.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">
<h4 style="text-align: justify;">Step 2:  Create a global_prepend file</h4>
<p style="text-align: justify;">The next thing we’re going to do is a create a PHP file which will be automatically prepended to every page of our site. Call this file something like <code>"global_prepend.php"</code></p>
<p style="text-align: justify;">and throw it at the root of your server:</p>
<p style="text-align: justify;">
<blockquote style="text-align: justify;"><p>&lt;br /&gt;<br />
&lt;?php&lt;br /&gt;<br />
function callback($buffer) {&lt;br /&gt;<br />
if ($_SERVER['SERVER_NAME'] == &#8216;mobile.owendevelopment.com&#8217;) {&lt;br /&gt;<br />
$buffer = str_replace(&#8216;http://www.myawesomeblog.com&#8217;, &#8216;http://mobile.myawesomeblog.com&#8217;, $buffer);&lt;br /&gt;<br />
$buffer = preg_replace(&#8216;/[\n\r\t]+/&#8217;, &#8221;, $buffer);&lt;br /&gt;<br />
$buffer = preg_replace(&#8216;/\s{2,}/&#8217;, &#8216; &#8216;, $buffer);&lt;br /&gt;<br />
$buffer = preg_replace(&#8216;/(&lt;a[^&gt;]*&gt;)(&lt;img[^&gt;]+alt=&#8221;)([^"]*)(&#8220;[^&gt;]*&gt;)(&lt;\/a&gt;)/i&#8217;, &#8216;$1$3$5&lt;br /&gt;&#8217;, $buffer);&lt;br /&gt;<br />
$buffer = preg_replace(&#8216;/(&lt;link[^&gt;]+rel=&#8221;[^"]*stylesheet&#8221;[^&gt;]*&gt;|&lt;img[^&gt;]*&gt;|style=&#8221;[^"]*&#8221;)|&lt;script[^&gt;]*&gt;.*?&lt;\/script&gt;|&lt;style[^&gt;]*&gt;.*?&lt;\/style&gt;|&lt;!&#8211;.*?&#8211;&gt;/i&#8217;, &#8221;, $buffer);&lt;br /&gt;<br />
$buffer = preg_replace(&#8216;/&lt;\/head&gt;/i&#8217;, &#8216;&lt;meta name=&#8221;robots&#8221; content=&#8221;noindex, nofollow&#8221;&gt;&lt;/head&gt;&#8217;, $buffer);&lt;br /&gt;<br />
}&lt;br /&gt;<br />
return $buffer;&lt;br /&gt;<br />
}&lt;br /&gt;<br />
ob_start(&#8220;callback&#8221;);&lt;br /&gt;<br />
?&gt;</p></blockquote>
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">This code uses a PHP function called</p>
<p style="text-align: justify;"><code>ob_start()</code></p>
<p style="text-align: justify;">to read in your entire HTML source, run some rules on it, and then send the output to users’ web browsers… all in real time.   The first</p>
<p style="text-align: justify;"><code>"if"</code></p>
<p style="text-align: justify;">statement simply checks to see if the user is coming from our special “mobile” URL, and if so, runs seven replace statements on the code.   Here’s what each line does:</p>
<ol style="text-align: justify;">
<li>Changes all URLs to “mobile”-ized URLs.Strips all linefeeds, carriage returns, and tabs.Trims multiple spaces down to one (HTML doesn’t recognize more than one space in a row).Changes any anchored images with alt text to plain text anchors.Strips all stylesheets, images, inline styles, scripts, and comments (including RDF).Tells search engine robots not to index or crawl the mobile version of the site so as to not create duplicate listings.</li>
</ol>
<h4 style="text-align: justify;">Step 3: Create global_append file</h4>
<p style="text-align: justify;">Next, we need to create a tiny PHP file which will automatically get added to the <em>end</em> of every file on our site. This is the code that actually outputs the page to the browser. So the flow is like so: Suck code into buffer, siphon fat away, spit contents of buffer into browser.</p>
<p style="text-align: justify;">The code for the global_append file is below.  Call it something like</p>
<p style="text-align: justify;"><code>"global_append.php"</code></p>
<p style="text-align: justify;">and throw it at the root of your server:</p>
<p style="text-align: justify;">
<blockquote style="text-align: justify;"><p>&lt;br /&gt;<br />
&lt;?php&lt;br /&gt;<br />
ob_end_flush();&lt;br /&gt;<br />
?&gt;</p></blockquote>
<h4 style="text-align: justify;">Step 4: Enable prepends and appends using .htaccess</h4>
<p style="text-align: justify;">If you don’t already have an</p>
<p style="text-align: justify;"><code>.htaccess</code></p>
<p style="text-align: justify;">file at the root of your server, open up a new text file and add these lines to it:</p>
<p style="text-align: justify;"><code>php_value auto_prepend_file /localfilepath/global_prepend.php<br />
php_value auto_append_file /localfilepath/global_append.php</code></p>
<p style="text-align: justify;">Then save it to the root of your server with the filename <code>".htaccess"</code></p>
<p style="text-align: justify;">If you already have an .htaccess file, just add the above lines to it.</p>
<p style="text-align: justify;"><em>* Important Note: If you copy these two lines from your web browser, you might need to delete the carriage return and make your own. Sometimes a browser’s carriage return will cause your .htaccess file to fail (you’ll know immediately if it has failed because your site won’t come up).</em></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Assuming your subdomain is live, you should now be able to hit your site in a web browser using the special mobile URL and see a nice, compact, imageless, styleless, scriptless version of your site. Voila!</p>
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;"><span style="color: #808080;">Many thanks to the Genius of  <a href="http://www.mikeindustries.com">http://www.mikeindustries.com</a><span style="text-decoration: underline;"> for this useful info.</span><a href="http://www.mikeindustries.com"><br />
</a></span></p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.theonemanmission.com/featured/make-your-website-mobile-friendly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
