<?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>Todd Huss &#187; WAP and WML</title>
	<atom:link href="http://gabrito.com/post/category/technical/wap-and-wml/feed" rel="self" type="application/rss+xml" />
	<link>http://gabrito.com</link>
	<description>Anecdotes on Technology Leadership, Ruby, Java, Scala, Cloud Computing, Open-Source, SEO, and Design</description>
	<lastBuildDate>Thu, 08 Dec 2011 00:21:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Making your Rails app mobile with WAP and WML</title>
		<link>http://gabrito.com/post/making-your-rails-app-mobile-with-wap-and-wml</link>
		<comments>http://gabrito.com/post/making-your-rails-app-mobile-with-wap-and-wml#comments</comments>
		<pubDate>Thu, 31 Aug 2006 10:02:45 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[WAP and WML]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/making-your-rails-app-mobile-with-wap-and-wml</guid>
		<description><![CDATA[I&#8217;d been wanting to make my Ruby on Rails based San Francisco Sailing Weather site available for mobile / cell phones. Now that I&#8217;m on vacation in Germany I had a stretch on a train ride where I was able &#8230; <a href="http://gabrito.com/post/making-your-rails-app-mobile-with-wap-and-wml">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d been wanting to make my <a href="http://windandtides.com">Ruby on Rails based San Francisco Sailing Weather</a> site available for mobile / cell phones. Now that I&#8217;m on vacation in Germany I had a stretch on a train ride where I was able to crank out a simple working version. Here are the steps I took:<br />
<span id="more-153"></span><br />
1. Set the WAP WML content type. You can do this on each controller method, or by using a controller specific before_filter, or an application wide before_filter as I did that applies to all actions with the name wap in <strong>app/controllers/application.rb</strong>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;small&gt;<br />
before_filter :set_wap_content_type, &lt;span&gt;:&lt;/span&gt;only =&gt; :wap<br />
&lt;/small&gt;</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;small&gt;<br />
def set_wap_content_type<br />
&amp;#160;&amp;#160;@headers[&quot;Content-Type&quot;] = &quot;text/vnd.wap.wml; charset=iso-8859-1&quot; <br />
end<br />
&lt;/small&gt;</div></div>
<p><!--adsense--></p>
<p>2. Next I created an <strong>app/views/layouts/wap.rhtml</strong> decorator to wrap all of my WML documents with:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;small&gt;<br />
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;<br />
&amp;lt;!DOCTYPE wml PUBLIC &quot;-//WAPFORUM//DTD WML 1.1//EN&quot; &quot;http://www.wapforum.org/DTD/wml_1.1.xml&quot;&amp;gt;<br />
&amp;lt;wml&amp;gt;<br />
&amp;lt;card title=&quot;&amp;lt;%= @title %&amp;gt;&quot;&amp;gt;<br />
&amp;lt;p align=&quot;center&quot;&amp;gt;<br />
&amp;lt;%= @content_for_layout %&amp;gt;<br />
&amp;lt;/p&amp;gt;<br />
&amp;lt;/card&amp;gt;<br />
&amp;lt;/wml&amp;gt;<br />
&lt;/small&gt;</div></div>
<p>3. Then I added a wap method to my index controller so that users can access the mobile version of the site via <a href="http://webcab.de/cgi-bin/wcl.cgi?a=UPG1%20UP%2F4.0&amp;m=text%2Fvnd.wap.wml&amp;URL=http://windandtides.com/wap">http://windandtides.com/wap</a></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;small&gt;<br />
def wap<br />
&amp;#160;&amp;#160;@title = &quot;San Francisco Sailing Weather&quot;<br />
&amp;#160;&amp;#160;render(:layout =&gt; &quot;wml&quot;)<br />
end<br />
&lt;/small&gt;</div></div>
<p>4. Finally I created a <strong>app/views/index/wap.rhtml</strong> to provide the content for the home page:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;small&gt;<br />
&amp;lt;%= link_to 'NOAA Marine Forecast', { :controller =&gt; '/marine/forecast', :action =&gt; 'wap' } %&amp;gt;&amp;lt;br/&amp;gt;<br />
&amp;lt;%= link_to 'Wind Readings', { :controller =&gt; '/marine/wind', :action =&gt; 'wap' } %&gt;&amp;lt;br/&amp;gt;<br />
&amp;lt;%= link_to 'Current Predictions', { :controller =&gt; '/marine/tide', :action =&gt; 'wap' } %&amp;gt;<br />
&lt;/small&gt;</div></div>
<p>Here is <a href="http://webcab.de/cgi-bin/wcl.cgi?a=UPG1%20UP%2F4.0&amp;m=text%2Fvnd.wap.wml&amp;URL=http://windandtides.com/wap">a demo of the result</a>. You could probably also use your regular actions and <a href="http://www.loudthinking.com/arc/000572.html">adjust the content-type and view you serve based on the accepts header which you can access via the respond_to method</a>. WAP/WML enabling the sub pages turned out to be a snap as I&#8217;d already broken out the content into partials from when I added RSS support so I was able to re-use those partials without any additional changes.</p>
<p>Some helpful web tools and references that I used were:<br />
<a href="http://www.w3schools.com/wap/"><br />
W3schools WAP tutorial</a><br />
<a href="http://www.w3schools.com/wap/wml_reference.asp">W3schools WML reference</a><br />
<a href="http://webcab.de/wcl.htm">Web based WAP Emulator</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/making-your-rails-app-mobile-with-wap-and-wml/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

