<?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>James Pearce &#187; Programming</title>
	<atom:link href="http://tripleodeon.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://tripleodeon.com</link>
	<description>Living the mobile dream</description>
	<lastBuildDate>Mon, 30 Aug 2010 06:42:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<cloud domain='tripleodeon.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Mobile Analytics With Python, Django, ASP.NET, Java, and node.js</title>
		<link>http://tripleodeon.com/2010/08/mobile-analytics-with-python-django-asp-net-java-and-node-js/</link>
		<comments>http://tripleodeon.com/2010/08/mobile-analytics-with-python-django-asp-net-java-and-node-js/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 06:42:30 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tripleodeon.com/?p=380</guid>
		<description><![CDATA[A few weeks ago, the PercentMobile team came to me to see if I could help write some new libraries for them. Contemporary web and mobile web sites are written on a vast array of different platforms… and obviously the more that PercentMobile supports, the better. Something I love about programming is that there are [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, the <a href="http://percentmobile.com">PercentMobile</a> team came to me to see if I could help write some new libraries for them. Contemporary web and mobile web sites are written on a vast array of different platforms… and obviously the more that PercentMobile supports, the better.</p>
<p>Something I love about programming is that there are so many languages to choose from &#8211; why restrict yourself to learning or becoming an expert at one when the same problems are also being solved in other, sometimes better, ways? Each language or platform has strengths and weaknesses of course. But I believe that understanding the differences &#8211; and more often, the similarities &#8211; makes one a better programmer.</p>
<p>So, generous polyglot that I am, I took the challenge, and plunged in.</p>
<p>(Sign up for the free PercentMobile service to get the libraries described in this post.)</p>
<h2>Python &amp; Django</h2>
<p>I love <a href="http://python.org" target="_blank">Python</a> &#8211; its readability, its libraries, and its overall philosophies. In a web server environment, Python can be used in a fairly raw way, behind a generic Web Service Gateway Interface (WSGI), but there are also a number of powerful web application frameworks using the language &#8211; most notably <a href="http://djangoproject.com/" target="_blank">Django</a>. PercentMobile want to provide painless Django support, but also to make sure that other Python server environments were not precluded.</p>
<p><code>percentmobile.py</code> is the single file that provides everything you need.</p>
<p>If you are running code in a WSGI environment, you will have a handle to the WSGI environment. This is normally called <code>environ</code> by convention, and is passed in to your application via your top-level WSGI callable. To make the PercentMobile tracking code work, you need only make one call to the <code>percentmobile.tracker_cookie_insert</code> function. It returns two values: the cookie that you’ll need to set in the HTTP response headers, and the HTML that you should insert into your page.</p>
<p>Say, for example, you had a very simple WSGI app. This responds to requests with an HTTP 200 status code, a single header and some simple HTML:</p>
<pre><code>def my_app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type','text/html')]
    start_response(status, response_headers)
    return ["Hello world"]</code></pre>
<p>To add PercentMobile tracking to this code, you need to firstly import the tracker library of course, and then call the <code>tracker_cookie_insert</code> function:</p>
<pre><code>import percentmobile
cookie, insert = percentmobile.tracker_cookie_insert(environ, '1234555')</code></pre>
<p>(Of course you should replace the final string with your own site ID!)</p>
<p>The <code>cookie</code> return value is actually a dictionary of the different parts needed to construct its string serialization. This will allow you to splice together multiple cookies, or alter the expiry time, path scope and so on. To convert the dictionary to a string, and to get the Set-Cookie header sent back in the request headers, the following code will suffice:</p>
<pre><code>cookie = "%s=%s; expires=%s; path=%s" % (
    cookie['name'],
    cookie['value'],
    cookie['expires'],
    cookie['path']
)
response_headers = [('Content-type','text/html'), ('Set-Cookie', cookie)]</code></pre>
<p>Finally, you need to make sure the HTML fragment, in the <code>insert</code> variable, gets placed in the HTML response:</p>
<pre><code>return ["&lt;html&gt;&lt;body&gt;Hello world %s&lt;/body&gt;&lt;/html&gt;" % insert]</code></pre>
<p>And that’s a wrap. The whole, PercentMobile-tracked WSGI application looks like this:</p>
<pre><code>def my_app(environ, start_response):
    cookie, insert = percentmobile.tracker_cookie_insert(environ, '1234555')
    cookie = "%s=%s; expires=%s; path=%s" % (
        cookie['name'],
        cookie['value'],
        cookie['expires'],
        cookie['path']
    )
    status = '200 OK'
    response_headers = [('Content-type','text/html'), ('Set-Cookie', cookie)]
    start_response(status, response_headers)
    return ["&lt;html&gt;&lt;body&gt;Hello world %s&lt;/body&gt;&lt;/html&gt;" % insert]</code></pre>
<p>Pretty easy, huh? Well, not as easy as tracking an app if you’re using the amazing Django framework! Contained in the same <code>percentmobile.py</code> file is a class that can be used as Django middleware. It uses the same underlying function as the WSGI implementation, but also takes care of the headers and insertion for you.</p>
<p>Assuming you’ve placed the library file in your Python or Django path, you simply need to add two lines of code in the settings file. Firstly add the <code>percentmobile.PercentMobileDjangoMiddleware</code> class to your list of middleware:</p>
<pre><code>MIDDLEWARE_CLASSES = (
    ...
    'percentmobile.PercentMobileDjangoMiddleware'
)</code></pre>
<p>And secondly, add your PercentMobile site ID to the settings file too:</p>
<pre><code>PERCENTMOBILE_SITE_ID = '1234555'</code></pre>
<p>Um… that’s it. The middleware will intercept the request, figure out the cookie that will need to be sent in the response, create the insertion code, and place it just before <code>&lt;/body&gt;</code> in the response. You’re golden. I love Django.</p>
<h2>ASP.NET: C# &amp; VB.NET</h2>
<p>Switching over to another world altogether, let’s take a quick look at the <a href="http://asp.net/" target="_blank">ASP.NET</a> implementation of the tracking code. One of the great things about .NET is that you can choose between all sorts of different languages to write your applications and pages in. I decided to write the tracking library in C#, but you can use it declaratively in your page code, or programmatically from C#, VB.NET, or any other supported language.</p>
<p>The library is implemented as a User Control &#8211; that is, as a .ascx file. You need to download and add <code>PercentMobile.ascx</code> to your web application project.</p>
<p>To embed the tracking logic into a page (or probably preferably, a master page), you simply register the user control as residing in that file:</p>
<pre><code>&lt;%@ Register TagPrefix="pm" TagName="Tracker" Src="~/PercentMobile.ascx" %&gt;</code></pre>
<p>And then embed the control straight into the .aspx file contents, wherever you want it to be:</p>
<pre><code>&lt;pm:Tracker runat="server" SiteId="1234555" /&gt;</code></pre>
<p>So a simple, tracked .aspx file might look something like this:</p>
<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" %&gt;
&lt;%@ Register TagPrefix="pm" TagName="Tracker" Src="~/PercentMobile.ascx" %&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;
    &lt;body&gt;
        &lt;form id="form1" runat="server"&gt;
            &lt;div&gt;Hello World&lt;/div&gt;
            &lt;pm:Tracker runat="server" SiteId="1234555" /&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>To be honest, this is so simple that I would expect most people to use the control declaratively. But if, for some reason, the control needs to be inserted programmatically, that’s pretty easy too. You need to use the <code>Reference</code> directive, instead of <code>Register</code>, at the top of the file, but otherwise it’s not much harder. Here, we’re using VB.NET to programmatically achieve exactly the same result as above:</p>
<pre><code>&lt;%@ Page Language="VB" AutoEventWireup="true" %&gt;&lt;%@ Reference Control="~/PercentMobile.ascx" %&gt;

&lt;script runat="server"&gt;
    Private tracker As PercentMobile.Tracker
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        tracker = CType(LoadControl("~/PercentMobile.ascx"), PercentMobile.Tracker)
        tracker.siteId = "1234555"
        form1.Controls.Add(tracker)
    End Sub
&lt;/script&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/head&gt;
    &lt;body&gt;
        &lt;form id="form1" runat="server"&gt;
            &lt;div&gt;Hello World&lt;/div&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;

</code></pre>
<p>(It should be fairly straightforward to see how to do this in other .NET languages &#8211; PercentMobile includes some examples in their install instructions.)</p>
<h2>Java</h2>
<p>Onwards. Let’s take a look at the tracking code for <a href="http://java.com" target="_blank">Java</a>. There are numerous ways in which Java can be used for web or application server environments. To keep things simple, I decided that supporting JSP was more or less the most familiar and reusable approach.</p>
<p>JSP doesn’t enjoy the rich page event model that I was able to use in ASP.NET to intercept headers, write cookies, and insert HTML, all with one include. <code>&lt;jsp:include&gt;</code> is OK for adding the HTML snippets, but wouldn’t let me access the HTTP headers. <code>&lt;jsp:forward&gt;</code> does, but would only work if you weren’t planning to emit any HTML of your own after the tracking code &#8211; something of a radical assumption.</p>
<p>So I settled for an approach where an include <em>directive</em> creates an instance of an inner <code>PercentMobile</code> class defined within the JSP class. To cut a long story short, this means you merely add a reference to the library file at the top of the JSP file:</p>
<pre><code>&lt;%@ include file="percentmobile.jsp" %&gt;</code></pre>
<p>And then call the track method on that instance, somewhere within the page:</p>
<pre><code>&lt;%percentMobile.track("1234555");%&gt;</code></pre>
<p>The included JSP file takes care of instantiating the <code>percentMobile</code> object and giving it references to the request and response stream. This means it can read and write cookies, and later emit HTML. Your tracked Hello World in Java then? It’s as simple as this:</p>
<pre><code>&lt;%@ include file="percentmobile.jsp" %&gt;
 &lt;html&gt;
  &lt;body&gt;
    Hello World
    &lt;%percentMobile.track("1234555");%&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>
<h2>node.js</h2>
<p>OK, OK. Python, ASP.NET, Java. No big deal, right? That’s all so 2003 or so, right?</p>
<p>Well, there’s an alternative future for web server technologies. It’s one that’s blazingly fast, lightweight, event-driven, and… where you write your server logic in Javascript.</p>
<p><a href="http://nodejs.org/" target="_blank">node.js</a> is one of the most exciting things I’ve seen for a long time, and I know I’m not alone. Fresh, fashionable, and somewhat unproven, admittedly, it’s had a lot of gushing coverage. But since it turns the web server model (almost literally) inside out, I do believe there’s something important going on.</p>
<p>Would it be possible to write a web app with node.js and still have it tracked by PercentMobile? My challenge.</p>
<p>I decided to rely on <a href="http://howtonode.org/connect-it" target="_blank">Connect</a>, a middleware framework for node.js, which, if you are writing web applications, provides a whole host of other helpful web logic. Using Connect to create a simple node.js app is extremely easy:</p>
<pre><code>var Connect = require('connect');
Connect.createServer(
  function (req, res, next) {
    res.simpleBody(200,
      "&lt;html&gt;&lt;body&gt;Hello World" +
      "&lt;/body&gt;&lt;/html&gt;",
      {
        "Content-Type": "text/html"
      }
    );
  }
).listen(88);</code></pre>
<p>To add PercentMobile tracking to this application firstly requires you to pull in the PercentMobile module:</p>
<pre><code>var PercentMobile = require('./percentmobile');</code></pre>
<p>(Where the <code>percentmobile.js</code> file has been placed in your node.js environment or in the common modules location.)</p>
<p>The module needs to be initialized as a piece of Connect middleware in the createServer function:</p>
<pre><code>PercentMobile.init('1234555')</code></pre>
<p>There are then two module functions, <code>cookie</code> and <code>html</code>, which both take a reference to the response object, and which return the cookie string and HTML to insert, respectively. These can be used in Connect’s <code>simpleBody</code> function, for example, meaning that our tracked application is as simple as this:</p>
<pre><code>var Connect = require('connect');
var PercentMobile = require('./percentmobile');
Connect.createServer(
  PercentMobile.init('1234555'),
  function (req, res, next) {
    res.simpleBody(200,
      "&lt;html&gt;&lt;body&gt;Hello World" +
        PercentMobile.html(res) +
      "&lt;/body&gt;&lt;/html&gt;",
      {
        "Content-Type": "text/html",
        "Set-Cookie": PercentMobile.cookie(res)
      }
    );
  }
).listen(88);</code></pre>
<h2>That’s a wrap</h2>
<p>So that’s it. A whistle-stop tour of the new languages and frameworks supported by PercentMobile. I’d love to hear your feedback on how easy (or hard!) these new APIs are to use.</p>
<p>And, oh… who will be the first to build a mobile web app on node.js? <img src='http://tripleodeon.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tripleodeon.com/2010/08/mobile-analytics-with-python-django-asp-net-java-and-node-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WhitherApps</title>
		<link>http://tripleodeon.com/2010/08/whitherapps/</link>
		<comments>http://tripleodeon.com/2010/08/whitherapps/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 03:10:20 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://tripleodeon.com/?p=363</guid>
		<description><![CDATA[Why spend your life recompiling native client apps when you have HTML5 and the mighty mobile web at your disposal? WhitherApps sets out to debunk some contemporary mobile myths. WhitherApps is a bandwagon-busting experiment. I believe there are far too many native client apps which could have been far better written as mobile web apps. [...]]]></description>
			<content:encoded><![CDATA[<p>Why spend your life recompiling native client apps when you have HTML5 and the mighty mobile web at your disposal? <a href="http://whitherapps.com">WhitherApps</a> sets out to debunk some contemporary mobile myths.</p>
<p><span id="more-363"></span></p>
<p>WhitherApps is a bandwagon-busting experiment. I believe there are  far too many native client apps which could have been far better written  as mobile web apps. What I&#8217;m trying to do with the project is take a few particularly obvious examples, apply a little reverse-engineering, and rewrite them, warts  and all, with web technologies.</p>
<p>I&#8217;m focussing on native client apps that are free to download. These  wouldn’t have suffered commercially had they been written this way in  the first place. Obviously, I’ll also focus on feasible genres of apps. No 3D games  or background apps, for example. To start with, informational media apps  (such as newspapers and broadcasters) will be in the spotlight.</p>
<p>But otherwise, I may not need to pull too many punches. Offline  access? Through the wonders of HTML5, that should be OK. Native device  API access? Well, BONDI and proprietary libraries permitting, I’ll have  a go – and there’s always PhoneGap too.</p>
<p>Each post on the site will be a walkthrough (or part of a walkhrough)  of the process. As I get my hands dirty, from the protocol-sniffing  to the pixel-jiggling, you can follow the steps I took.</p>
<p>Stay tuned and wish me luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://tripleodeon.com/2010/08/whitherapps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The WordPress Mobile Pack is back! And here&#8217;s how.</title>
		<link>http://tripleodeon.com/2009/12/the-wordpress-mobile-pack-is-back-and-heres-how/</link>
		<comments>http://tripleodeon.com/2009/12/the-wordpress-mobile-pack-is-back-and-heres-how/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 19:13:09 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tripleodeon.com/?p=348</guid>
		<description><![CDATA[Just a quick post to confirm that the WordPress Mobile Pack plugin is back online at wordpress.org. Most WordPress plugins, if &#8216;GPL-compatible&#8217;, are hosted on wordpress.org &#8211; it provides an easy way for people to view and upgrade them. The increasingly popular Mobile Pack is no exception, and we&#8217;ve been happily listed there for over [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to confirm that the <a href="http://wordpress.org/extend/plugins/wordpress-mobile-pack/">WordPress Mobile Pack</a> plugin is back online at wordpress.org.</p>
<p>Most WordPress plugins, if &#8216;GPL-compatible&#8217;, are hosted on wordpress.org &#8211; it provides an easy way for people to view and upgrade them. The increasingly popular Mobile Pack is no exception, and we&#8217;ve been happily listed there for over 6 months.</p>
<p><strong>But what do you do when it suddenly disappears?</strong> About 3 days ago, that&#8217;s exactly what happened. I&#8217;m the administrator of the plugin and could see it when I logged in. But suddenly none of my collaborators &#8211; nor the general public! &#8211; could see or download the plugin.</p>
<p>Our sole channel for software distribution had mysteriously dropped into a black hole &#8211; without a word of notification from WordPress themselves.</p>
<ul>
<li>Assuming it could only therefore be a bug with the wordpress.org web site, I filed a number of support tickets. No response.</li>
<li>Assuming it could only therefore be a permissions or licence issue, I raised a number of forum threads on the site (as, kindly, did Dennis Bournique, over at <a href="http://wapreview.com/">WAP Review</a>). No response.</li>
<li>Assuming I was somehow falling between the cracks, I even emailed <a href="http://ma.tt">Matt Mullenweg</a>. <span style="text-decoration: line-through;">Less surprisingly, no response</span>. UPDATE: I received an apology shortly after this post.</li>
</ul>
<p><strong>Hmm. All rather unsatisfactory.</strong></p>
<p>Well, this morning, a breakthrough. My WPMP partner in crime, <a href="http://blog.trasatti.it/">Andrea Trasatti</a> thought of joining the <a href="https://irclogs.wordpress.org/chanlog.php?channel=wordpress&amp;day=2009-12-18&amp;sort=asc#m336865">WordPress IRC channel</a>. (Obviously he&#8217;s a bit more old school than me). But finally found someone who would be prepared to answer the puzzle.</p>
<p>At this point, I need to point out there there are (true!) other mobile plugins out there. One particularly popular one has been <a href="http://www.andymoore.info/">Andy Moore</a>&#8216;s. He hadn&#8217;t hosted his on wordpress.org due, I guess, to his choice of license, and his &#8211; disclosed &#8211; use of automatic ads in the resulting pages, which WordPress does not permit.</p>
<p>For whatever reason, Andy recently closed down his plugin&#8217;s page, and had kindly redirected it to ours. This probably accounts for our <a href="http://wordpress.org/extend/plugins/wordpress-mobile-pack/stats/">nice increase in traffic</a> in mid-November. Thanks Andy!</p>
<p>However, one of Andy&#8217;s previous plugin downloaders apparently complained about an <a href="http://romanticrobot.net/moreimages/Picture19.png">error message</a> they had received. The WordPress administrators investigated by visiting Andy&#8217;s site, and of course got redirected to our Mobile Pack page. Thinking our plugin was at fault, they then disabled <em>our</em> plugin for violating the no-ads rule.</p>
<p><strong>Oh, and no-one thought to drop me an email to tell me.</strong></p>
<p>But Andrea&#8217;s investigations and protestations prompted us to get re-approved, and we&#8217;re back!</p>
<p>(In the process of investigating this, it also turns out that when WordPress says &#8216;GPL-compatible&#8217; and points you to a list of licenses, that doesn&#8217;t mean much at all. You also have to work out that they actually mean &#8216;GPL2-compatible&#8217;, and not &#8216;GPL3-compatible&#8217;, as our more permissive Apache license is. So I guess we&#8217;ll have to change our license too &#8211; which is a shame.)</p>
<p><strong>I don&#8217;t think WordPress covered themselves with glory here.</strong> In the interests of constructive criticism, I would suggest the company should:</p>
<ul>
<li>Inform a plugin owner whenever there is a complaint raised against it. I would have been able to point out the complaint was aimed at a different piece of software.</li>
<li>Inform a plugin owner when &#8211; or better, before &#8211; disabling a plugin from the listing. I could have had a grace period to have investigated any issues, rather than hear it first as complaints from users.</li>
<li>Respond to &#8216;site bug&#8217; tickets raised on the site.</li>
<li>Make the licensing requirements for plugins more clear. The phrase &#8216;GPL-compatible&#8217; <a href="http://wordpress.org/extend/plugins/about/">here</a>, (and its link), is certainly not precise enough.</li>
<li>Remember that plugin authors work hard to support your business of running the most popular blog platform in the world. Those individuals&#8217; reputations, to a fair extent, rest on your responsible syndication of that code, and they get the grief when you pull the plug.</li>
</ul>
<p>Anyway, thanks guys (and <a href="http://romanticrobot.net/">Mark</a> in particular) for putting it back. And special thanks to Andrea, who now overtakes me in the chocolate-for-favours race.</p>
<p><strong>Now&#8230; back to the roadmap of Mobile Pack coolness. Stay tuned.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://tripleodeon.com/2009/12/the-wordpress-mobile-pack-is-back-and-heres-how/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress Mobile Pack v1.1</title>
		<link>http://tripleodeon.com/2009/07/wordpress-mobile-pack-v11/</link>
		<comments>http://tripleodeon.com/2009/07/wordpress-mobile-pack-v11/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 10:14:09 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[dotMobi]]></category>

		<guid isPermaLink="false">http://tripleodeon.com/?p=322</guid>
		<description><![CDATA[The dotMobi WordPress Mobile Pack is a complete toolkit to help mobilize your WordPress site and blog. We just launched v1.1, compatible with the latest version of WordPress. Download it, read the changelog, read about the features in full, or even join the team. The plugin includes a mobile switcher to select themes based on [...]]]></description>
			<content:encoded><![CDATA[<p>The dotMobi WordPress Mobile Pack is a complete toolkit to help mobilize your WordPress site and blog.</p>
<p>We just launched v1.1, compatible with the latest version of WordPress. <a href="http://wordpress.org/extend/plugins/wordpress-mobile-pack/">Download it</a>, read <a href="http://www.assembla.com/spaces/wordpress-mobile-pack/milestones/95962">the changelog</a>, read about the <a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack">features in full</a>, or even join <a href="http://www.assembla.com/spaces/wordpress-mobile-pack/team">the team</a>.<br />
<span id="more-322"></span></p>
<p>The plugin includes a mobile switcher to select themes based on the type of user that is visiting the site, a selection of mobile themes, extra widgets, device adaptation and a mobile administration panel to allow users to edit the site or write new posts when out and about.</p>
<p>Features include:</p>
<ul>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.1">Mobile switcher</a> to detect mobile visitors and provide an appropriate experience</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.2">Base mobile theme</a> for quick-and-easy XHTML-MP compliance</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.3">Extended mobile themes</a> so you can unleash your mobile creativity</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.4">Transcoding and device adaptation</a> to optimise the mobile experience</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.5">DeviceAtlas integration</a> for world-class adaptation</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.6">Mobile admin panel</a> for when posts can&#8217;t wait</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.7">Mobile ad widget</a> to make you some money</li>
<li><a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack#p2.8">Barcode widget</a> to help users bookmark your blog</li>
</ul>
<p>I have a lot of fun writing this plugin and there&#8217;s a bunch of cool ideas we have for the future. Check out the <a href="http://www.assembla.com/spaces/wordpress-mobile-pack">Assembla project</a> to see the work as it happens &#8211; and maybe toss us some new ideas too.</p>
<p>It&#8217;s always a work in progress, but thousands of users seem happy enough so far. See what you think&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://tripleodeon.com/2009/07/wordpress-mobile-pack-v11/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simple &#8216;on-server&#8217; mobile AJAX in Django</title>
		<link>http://tripleodeon.com/2009/06/simple-on-server-mobile-ajax-in-django/</link>
		<comments>http://tripleodeon.com/2009/06/simple-on-server-mobile-ajax-in-django/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 11:30:52 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tripleodeon.com/?p=318</guid>
		<description><![CDATA[Or "How your mobile site may not be much more complicated than building one with a data API or AJAX"]]></description>
			<content:encoded><![CDATA[<p>&#8211;or&#8211;</p>
<p>&#8220;How your mobile site may not be much more complicated than building one with a data API or AJAX&#8221;</p>
<p>I am working on a project called &#8216;IvyRoot&#8217; that is predominantly mobile and which is going to make me fabulously rich and famous.</p>
<p>OK, OK. It&#8217;s predominantly mobile, at least. It&#8217;s all in Django.</p>
<p>There&#8217;s a &#8216;desktop&#8217; web site to go with it, and this contains panels within pages. Some of these panels might take a few moments to process and so I use XHR to call back to get them once the main page has loaded, displaying a pretty spinning icon in the meantime.</p>
<p>I also use XHR to populate in-page tables which might have many rows &#8211; so that pagination and sorting are fast without having to load the whole page again.</p>
<p>I also want to expose a number of data APIs (providing XML, JSON, basic HTML and the like) so that people can build 3rd party clients, their own consuming sites, and widgets.</p>
<p>Finally, I want to provide a mobile web version of the site. I&#8217;ll probably do some sort of device detection to refine the behaviour, but I should assume that plenty of browsers will not be able to do the XHR bit, and should have the page (containing all the panels) in one go &#8211; admittedly after a slightly longer wait.</p>
<p>Well, it occurs to me that these requirements can all be solved at the same time. Switching templates based on URL (or other HttpRequest clues) is pretty easy, so one thing I could do is have a filename extension convention for all my URLs. Imagine a &#8216;things&#8217; view that lists things.</p>
<ul>
<li> <strong>http://ivyroot.com/things</strong> &#8211; this is the human-consumable page: the view surrounded by menus, logos, graphics and the like. Knows how to switch outer template, <a href="http://mobiforge.com/designing/story/a-very-modern-mobile-switching-algorithm-part-i">based on various things</a>, between desktop and mobile.</li>
<li> <strong>http://ivyroot.com/things.html</strong> &#8211; this is the table at the heart of the page, perhaps using unstyled markup containing the list of things itself.</li>
<li> <strong>http://ivyroot.com/things.xml</strong>, <strong>http://ivyroot.com/things.json</strong> etc &#8211; data APIs that list things in various serializations.</li>
</ul>
<p>So perhaps we can set up URL routes like this:</p>
<pre>...
(r'^things$', things),
(r'^things.(?P&lt;mode&gt;[a-z0-9]+)$', things),
...</pre>
<p>And have a view that looks something like this:</p>
<pre>def things(request, mode=''):
    if not mode:
        mode = desktop_or_mobile()
    template = "things.%s" % mode
    ...</pre>
<p>(Or, I suppose we could pass the mode into the template via the context and have some sort of a switch statement in the template itself. It might be good to pass it in, anyway, in case there is any further refinement required within each template.)</p>
<p>Anyway, let&#8217;s also assume that the things list is very long and takes a while to generate. For the desktop users, we might want to either load the table as HTML asynchronously using XHR, or paged into a jQuery grid control. For these two approaches, I can call back to /things.html or /things.json respectively (and do a little extra plumbing to make sure the JSON is in the right format for the grid control to consume).</p>
<p>But what of mobile? Well, for many devices, I can&#8217;t expect any XHR activity to be supported, so we need to insert the table HTML into the body of the things.mobile page before it departs for the client &#8211; and we may need to pre-page it too (if it&#8217;s long). But the good news is that, if I made it simple enough, the HTML generated by things.html might be good enough for either type of browser.</p>
<p>(And if not, I could easily do a little adaptation on <em>that</em> view too &#8211; perhaps turn my table into a list.)</p>
<p>So what I would like to have a is a way of embedding the output of one view (or even URL) into another, whilst the response is still being put together on the server. Try as I could, there didn&#8217;t seem to be anything in Django to do this.</p>
<p>Enter my first <a href="http://www.djangosnippets.org/snippets/1568/">DjangoSnippet</a>!</p>
<p>This basically allows me to put a template tag into the mobile template that pulls the output from one of the other views (identified by view name, with arguments; or a verbatim URL which would be the same as the one used in the desktop&#8217;s XHR request &#8211; nifty!)</p>
<p>It also makes sure that the context for <em>that</em> view is sandboxed with what <em>it</em> needs to render itself &#8211; so that I don&#8217;t have to worry about getting the context ready in the &#8216;outer&#8217; view. That&#8217;s not necessary in our simple example above &#8211; but it might be useful later on if I am dynamically choosing which panels to place on a page, and I want them to gather together their own context prior to template rendering.</p>
<p>Now, I&#8217;ll need to be careful to make sure that any interaction elements within the table &#8211; say, some actions available on each item in the list, or a paginator &#8211; behave suitably for their location. But this may be as simple as toggling between further XHR requests (for desktop) and simple anchor links (for mobile). Forms-in-panels will be harder but similar.</p>
<p>So&#8230; there we are, a glimpse at the inner workings of a mystery application that&#8217;s many weeks away from seeing the light of day.</p>
<p>But hopefully I&#8217;ve raised a few thoughts about how you can treat the mobile version of your site as being a cousin of the data APIs that you might have written anyway. And also how you might be able to sneakily bring some of the funky XHR &#8211; that you wanted to impress your friends with on the desktop &#8211; up into the server to keep your mobile pals happy too.</p>
]]></content:encoded>
			<wfw:commentRss>http://tripleodeon.com/2009/06/simple-on-server-mobile-ajax-in-django/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
