<?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>Slash Dot Dash &#187; iPhone</title>
	<atom:link href="http://www.slashdotdash.net/category/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.slashdotdash.net</link>
	<description>Rolling on Rails</description>
	<lastBuildDate>Wed, 18 Mar 2009 22:03:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>BBC iPlayer on the iPhone</title>
		<link>http://www.slashdotdash.net/2008/03/08/bbc-iplayer-on-the-iphone/</link>
		<comments>http://www.slashdotdash.net/2008/03/08/bbc-iplayer-on-the-iphone/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 18:23:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Yesterday the BBC announced that their iPlayer video on demand service was available for the iPhone (and iPod Touch). There&#8217;s a more in depth post on the BBC Internet Blog where they give details on the technical implementation. Back to BBC iPlayer on iPhone implementation: we&#8217;re not using the new Apple SDK, nor are we [...]]]></description>
			<content:encoded><![CDATA[<p style="float:right"><a href="http://www.slashdotdash.net/images/iplayer1.jpg"><img src="http://www.slashdotdash.net/images/iplayer1p.jpg" alt="" /></a></p>
<p>Yesterday the <a href="http://news.bbc.co.uk/1/hi/technology/7283702.stm"><span class="caps">BBC</span> announced</a> that their <a href="http://www.bbc.co.uk/iplayer/">iPlayer</a> video on demand service was available for the iPhone (and iPod Touch). There&#8217;s a more in depth post on the <a href="http://www.bbc.co.uk/blogs/bbcinternet/2008/03/bbc_iplayer_on_iphone_behind_t.html"><span class="caps">BBC</span> Internet Blog</a> where they give details on the technical implementation.</p>
<blockquote>
<p>Back to <span class="caps">BBC</span> iPlayer on iPhone implementation: we&#8217;re not using the new Apple <span class="caps">SDK</span>, nor are we using the much-rumoured Flash for iPhone (no &#8211; we haven&#8217;t seen it, either). Instead, we&#8217;re creating 516Kbps streams (400Kbps H.264 video, 116Kbps <span class="caps">AAC</span> audio) that show off <span class="caps">BBC</span> programmes brilliantly on an iPhone.</p>
</blockquote>
<p>It&#8217;s interesting to read about the raw processing power required to transcode their 24 simultaneous incoming programmes, for a peak data rate of over a gigabit per second of incoming video.</p>
<p>I tried out an episode of Top Gear and was impressed with both the streaming speed and the quality of the video (check out the images below). The only downside is that it only supports streaming and requires a WiFi connection; unsurprisingly, <span class="caps">EDGE</span> isn&#8217;t fast enough. Ideally it would be fantastic to be able to download a programme to watch &#8216;offline&#8217;, such as on a train (I&#8217;ll keep my finger&#8217;s crossed).</p>
<p style="float:left"><a href="http://www.slashdotdash.net/images/iplayer2.jpg"><img src="http://www.slashdotdash.net/images/iplayer2p.jpg" style="margin:0;" alt="" /></a></p>
<p style="float:left"><a href="http://www.slashdotdash.net/images/iplayer3.jpg"><img src="http://www.slashdotdash.net/images/iplayer3p.jpg" style="margin:0;" alt="" /></a></p>
<p style="float:left"><a href="http://www.slashdotdash.net/images/iplayer4.jpg"><img src="http://www.slashdotdash.net/images/iplayer4p.jpg" style="margin:0;" alt="" /></a></p>
<h3 style="clear:both;">Update</h3>
<p><del>-<strong>Update I</strong>: I knocked up a <a href="http://pastie.org/164454">quick Ruby script to download the mp4 files</a> that the iPhone version uses (it uses wget).</del>- (The script no-longer works due to <span class="caps">BBC</span> attempts to prevent downloads).</p>
<p><strong>Update II</strong>: Paul Battley has <a href="http://po-ru.com/projects/iplayer-downloader/">written a Ruby library, <code>iplayer-dl</code>, for downloading the <span class="caps">BBC</span> iPlayer videos</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdotdash.net/2008/03/08/bbc-iplayer-on-the-iphone/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Contributing to &#8220;Advanced Rails Recipes&#8221;</title>
		<link>http://www.slashdotdash.net/2008/02/28/contributing-to-advanced-rails-recipes/</link>
		<comments>http://www.slashdotdash.net/2008/02/28/contributing-to-advanced-rails-recipes/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 23:10:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[The latest Beta update to the new Pragmatic Programmers book Advanced Rails Recipes: 72 New Ways to Build Stunning Rails Apps includes two chapters authored by myself. They are both complete rewrites and updates of two of my popular blog posts Rails searching with Sphinx and iPhone on Rails &#8211; Creating an iPhone optimised version [...]]]></description>
			<content:encoded><![CDATA[<p style="float:right"><img src="http://www.slashdotdash.net/images/fr-arr-100.jpg" alt="" /></p>
<p>The latest Beta update to the new Pragmatic Programmers book <a href="http://www.pragprog.com/titles/fr_arr">Advanced Rails Recipes: 72 New Ways to Build Stunning Rails Apps</a> includes two chapters authored by myself.</p>
<p>They are both complete rewrites and updates of two of my popular blog posts <a href="http://www.slashdotdash.net/articles/2007/08/06/rails-searching-with-sphinx">Rails searching with Sphinx</a> and <a href="http://www.slashdotdash.net/articles/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2">iPhone on Rails &#8211; Creating an iPhone optimised version of your Rails site using iUI and Rails 2</a>.</p>
<p>The new recipes are:</p>
<p style="float:right"><img src="http://www.slashdotdash.net/images/api_search.gif" alt="" /></p>
<ul>
<li><strong>Full-Text Search with Sphinx</strong> &#8211; includes a Rails site that uses Sphinx to index the Rails <span class="caps">API</span>.</li>
</ul>
<p style="float:right"><img src="http://www.slashdotdash.net/images/iphone_todo.gif" alt="" /></p>
<ul>
<li><strong>Support An iPhone Interface</strong> &#8211; with a <span class="caps">TODO</span> list app.</li>
</ul>
<p>Along with these two (worth the purchase price on their own!), there are another 79 great recipes with some of the latest Rails best practices in small, easy to implement chunks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdotdash.net/2008/02/28/contributing-to-advanced-rails-recipes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Watch movies on your iPhone &#8211; conversion from AVI files on Mac OS X</title>
		<link>http://www.slashdotdash.net/2008/01/16/quick-tip-watch-movies-on-your-iphone-conversion-from-avi-files-on-mac-os-x/</link>
		<comments>http://www.slashdotdash.net/2008/01/16/quick-tip-watch-movies-on-your-iphone-conversion-from-avi-files-on-mac-os-x/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 20:37:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Want to watch a movie on your iPhone (or iPod)? The simplest method of converting to the correct format and size is to use iSquint an &#8220;iPod video conversion app for Mac OS X&#8221;. Install, then fire up the iSquint application. Drag &#38; drop your .avi file onto the window. Select Optimize for iPod, Add [...]]]></description>
			<content:encoded><![CDATA[<p style="float:right"><img src="http://www.slashdotdash.net/images/iSquint.gif" alt="" /></p>
<p>Want to watch a movie on your iPhone (or iPod)? The simplest method of converting to the correct format and size is to use <a href="http://www.isquint.org/">iSquint</a> an &#8220;iPod video conversion app for Mac <span class="caps">OS X</span>&#8221;.</p>
<ul>
<li>Install, then fire up the iSquint application.</li>
<li>Drag &#38; drop your .avi file onto the window.</li>
<li>Select <strong>Optimize for iPod</strong>, <strong>Add to iTunes</strong> and <strong>H.264 Encoding</strong>.</li>
<li>Set the <strong>Quality</strong> slider (I&#8217;d recommend High) and click <strong>Start</strong>.</li>
</ul>
<p><img src="http://www.slashdotdash.net/images/iSquint2.gif" alt="" /></p>
<p>Leave iSquint to do its stuff and you&#8217;ll have the converted film available in iTunes. For a single CD avi file, expect a final file size of around 300-350MB for High Quality or 150-200MB for Standard Quality settings (at 127kbps bit rate).</p>
<p><strong>Note:</strong> You&#8217;ll need to manually select the movie for synching when your iPhone or iPod is connected to iTunes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdotdash.net/2008/01/16/quick-tip-watch-movies-on-your-iphone-conversion-from-avi-files-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone on Rails &#8211; Creating an iPhone optimised version of your Rails site using iUI and Rails 2</title>
		<link>http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2/</link>
		<comments>http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 00:33:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[After upgrading trawlr.com to Rails 2 I thought I&#8217;d make use of some of the new features and attempt to create an iPhone version of the site. With Rails 2 you can create a mime type specifically for the iPhone and then use that format in a respond_to block (along with views such as index.iphone.erb). [...]]]></description>
			<content:encoded><![CDATA[<p style="float:right"><a href="http://www.slashdotdash.net/images/iPhone3.gif"><img src="http://www.slashdotdash.net/images/iPhone3p.gif" alt="" /></a></p>
<p style="float:right"><a href="http://www.slashdotdash.net/images/iPhone2.gif"><img src="http://www.slashdotdash.net/images/iPhone2p.gif" alt="" /></a></p>
<p><a href="http://www.slashdotdash.net/articles/2007/12/03/rails-2-upgrade-notes">After upgrading trawlr.com to Rails 2</a> I thought I&#8217;d make use of some of the new features and attempt to create an iPhone version of the site.<br />
With Rails 2 you can create a mime type specifically for the iPhone and then use that format in a <code>respond_to</code> block (along with views such as <code>index.iphone.erb</code>).</p>
<h2>Before you start &#8211; iPhoney</h2>
<p><a href="http://www.marketcircle.com/iphoney/">iPhoney</a> is an indispensable Mac-only tool for aiding the development of an iPhone specific site.</p>
<blockquote>
<p>Looking for a way to see how your web creations will look on iPhone? Look no further. iPhoney gives you a pixel-accurate web browsing environment—powered by Safari—that you can use when developing web sites for iPhone. It&#8217;s the perfect 320 by 480-pixel canvas for your iPhone development. And it&#8217;s free. iPhoney is not an iPhone simulator but instead is designed for web developers who want to create 320 by 480 (or 480 by 320) websites for use with iPhone. It gives you a canvas on which to test the visual quality of your designs.</p>
</blockquote>
<p>Ensure iPhoney&#8217;s user agent is set to <code>iPhone User Agent</code> in the menu.</p>
<h2>iPhone mime type</h2>
<p>Create an iPhone mime type alias using Rails 2 <code>initializers</code>.</p>
<p><code>config/initializers/mime_types</code></p>
<pre>
Mime::Type.register_alias "text/html", :iphone
</pre>
<h2>Detecting iPhone user agents</h2>
<p style="float:right"><a href="http://www.slashdotdash.net/images/iPhone1.gif"><img src="http://www.slashdotdash.net/images/iPhone1p.gif" alt="" /></a></p>
<p>Apple recommends that rather than redirecting iPhone users to an iPhone-optimised version of your site you should instead show the original site with a link to the alternative.</p>
<p>This can be achieved via user agent sniffing; looking for <code>Mobile Safari</code> (as Apple suggests), rather that iPhone or iPod touch, to allow for future device support.</p>
<p>Adding a helper method to <code>application_helper.rb</code> allows a notification message to be shown for <em>only</em> iPhone users (try accessing <a href="http://www.trawlr.com">www.trawlr.com</a> from an iPhone).</p>
<p><code>app/helpers/application_helper.rb</code></p>
<pre>
# Request from an iPhone or iPod touch? (Mobile Safari user agent)
def iphone_user_agent?
  request.env["HTTP_USER_AGENT"] &#38;&#38; request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/]
end
</pre>
<p>In your view, show a message for iPhone user agents directing them to the iPhone version.</p>
<pre>
&lt;% if iphone_user_agent? # Show message for iPhone users -%&gt;
&lt;div class="message"&gt;
    &lt;p&gt;Using an iPhone? &lt;a href="http://iphone.trawlr.com/"&gt;Use the optimised version&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;% end -%&gt;
</pre>
<h2>iPhone subdomain</h2>
<p>Instead of forcing users straight to our iPhone version, we offer them the option by using a separate subdomain (<a href="http://iphone.trawlr.com">iphone.trawlr.com</a>) with a link back to the <em>regular</em> site if they wish. When developing locally I modified my <code>/etc/hosts</code> file as follows so that I could use http://iphone.localhost.com:3000/.</p>
<p><code>/etc/hosts</code></p>
<pre>
127.0.0.1 iphone.localhost.com
</pre>
<p>You may need to flush the <span class="caps">DNS</span> cache after making the changes.</p>
<pre>
sudo dscacheutil -flushcache
</pre>
<h2>Adjust format for iPhone</h2>
<p>I chose to require login for all requests to the iPhone version of the site.</p>
<pre>
class ApplicationController &lt; ActionController::Base
    before_filter :adjust_format_for_iphone
    before_filter :iphone_login_required

private

  # Set iPhone format if request to iphone.trawlr.com
  def adjust_format_for_iphone
    request.format = :iphone if iphone_request?
  end

  # Force all iPhone users to login
  def iphone_login_required
    if iphone_request?
      redirect_to login_path unless logged_in?
    end
  end

  # Return true for requests to iphone.trawlr.com
  def iphone_request?
    return (request.subdomains.first == "iphone" || params[:format] == "iphone")
  end
end
</pre>
<p>Note that <code>sessions_controller.rb</code> (handles login) requires <code>skip_before_filter :iphone_login_required</code>.</p>
<h2>Using iUI and creating iPhone views</h2>
<p>The <a href="http://code.google.com/p/iui/">iUI</a> framework, based on Joe Hewitt&#8217;s iPhone navigation work, hugely simplifies iPhone web development. All you need to do is include the iUI JavaScript and <span class="caps">CSS</span> files along with included images and create your views in a particular structure to have native iPhone behaviour such as sliding menus and <span class="caps">AJAX</span> page loading.</p>
<p>Rails 2 makes it trivial to create different views depending upon the format, including layouts. Our iPhone layout includes a few specifics for iUI and a <code>viewport</code> meta tag for the device.</p>
<p><code>app/views/layouts/application.iphone.erb</code></p>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
    &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
    &lt;meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/&gt;
    &lt;title&gt;&lt;%= @page_title -%&gt;&lt;/title&gt;
  &lt;%= stylesheet_link_tag 'iui' %&gt;
  &lt;%= javascript_include_tag 'iui' %&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class="toolbar"&gt;
        &lt;h1 id="pageTitle"&gt;&lt;/h1&gt;
        &lt;a id="backButton" class="button" href="#"&gt;&lt;/a&gt;
    &lt;/div&gt;

    &lt;%= yield %&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>When creating your iPhone views you should follow the iUI style guide, an example page is given below. Standard hyperlinks are loaded using <span class="caps">AJAX</span> and <em>slide</em> into view, navigating back is handled by iUI. Links may be prefixed with <code>target="_self"</code> to replace the entire page or <code>target="_replace"</code> to replace the element with the response (using <span class="caps">AJAX</span>).</p>
<p><code>index.iphone.erb</code></p>
<pre>
&lt;ul title="Home" selected="true"&gt;
    &lt;li&gt;&lt;%= link_to 'Example action', example_path %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Logout', logout_path, :method =&gt; :delete, :target =&gt; '_self' %&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p><code>show.iphone.erb</code></p>
<pre>
&lt;div class="panel" title="Example" selected="true"&gt;
    &lt;h2&gt;Example Content&lt;/h2&gt;
    &lt;p&gt;Here's some content&lt;/p&gt;
&lt;/div&gt;
</pre>
<p>It&#8217;s important to remember that iUI will load content using <span class="caps">AJAX</span>, thus you <strong>only</strong> need to render a layout (such as <code>application.iphone.erb</code>) for the first request or page of your iPhone site. All following requests should use <code>render :layout =&gt; false</code> (unless loaded into a new page with <code>target="_replace"</code>). If you experience any wierd rendering issues it&#8217;ll most likely be due to this irregularity.</p>
<pre>
respond_to do |format|
    format.iphone do  # action.iphone.erb
      render :layout =&gt; false
    end
end
</pre>
<h2>Show, don&#8217;t tell</h2>
<p>Why not try <a href="http://iphone.trawlr.com/">iphone.trawlr.com</a> for yourself? It&#8217;ll work for your iPhone or any web browser. You&#8217;ll need to register via the <a href="http://www.trawlr.com/">normal site</a> if you don&#8217;t already have an account (quick, no email registration required)!</p>
<h2>References</h2>
<p>The following resources on the new Rails 2 iPhone format ability and iUI library were extremely helpful; the documentation from Apple not so much!</p>
<ul>
<li>http://developer.apple.com/iphone/</li>
<li>http://www.railspikes.com/2007/11/8/iphone-subdomains-with-rails</li>
<li>http://blog.nicksieger.com/articles/2007/09/18/railsconf-europe-david-heinemeier-hansson</li>
<li>http://www.joehewitt.com/blog/introducing_iui.php</li>
<li>http://code.google.com/p/iui/</li>
</ul>
<p>Yes, I&#8217;m still loving the iPhone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
