<?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>Hackdiary &#187; rest</title>
	<atom:link href="http://www.hackdiary.com/category/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackdiary.com</link>
	<description></description>
	<lastBuildDate>Mon, 05 Dec 2011 17:15:30 +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>REST On Rails</title>
		<link>http://www.hackdiary.com/2005/11/03/rest-on-rails/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rest-on-rails</link>
		<comments>http://www.hackdiary.com/2005/11/03/rest-on-rails/#comments</comments>
		<pubDate>Thu, 03 Nov 2005 10:18:45 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=73</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>XML.com have just published an article I wrote for them last month entitled <a href="http://www.xml.com/pub/a/2005/11/02/rest-on-rails.html">REST On Rails</a>.</p>
<p><span id="more-73"></span><br />
It outlines one approach that I&#8217;ve been developing for the API in the BBC programme catalogue. One of the things I like a great deal about Rails is its URL routing and dispatch mechanism. Creating mappings from URLs to model instances makes a resource-oriented style feel very natural, which sits very well with REST.</p>
<p>Isn&#8217;t this a wonderfully literal interpretation of the article&#8217;s title?</p>
<p><img src="http://www.hackdiary.com/images/111-rest_on_rails.gif" alt='REST on Rails' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2005/11/03/rest-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Photo-annotating bot</title>
		<link>http://www.hackdiary.com/2003/01/09/photo-annotating-bot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=photo-annotating-bot</link>
		<comments>http://www.hackdiary.com/2003/01/09/photo-annotating-bot/#comments</comments>
		<pubDate>Thu, 09 Jan 2003 13:02:47 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[bots]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=19</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>A background project for a while has been to write a bot to help me annotate the fairly large number of pictures I post to <a href="http://www.picdiary.com/cgi-bin/frontpage.pl">picdiary</a> (1496 at the last count). Creating a document of <a href="http://www.picdiary.com/rss/highwalk.rss">RSS-based metadata</a> is a slightly cumbersome text-editor job every time I post a new set of pics.</p>
<p><span id="more-19"></span><br />
After much thought, coding and discussion over the summer with <a href="http://husk.org/bots/">#bots</a> people, I came to the conclusion that a good architectural style for bots is, as <a href="http://space.frot.org/techdetails.html">jo puts it</a>, &#8220;a stateful conversational interface to an aspect of the semantic web&#8221;. Querying and updating information is modeled by HTTP GET and POST respectively. The code is structured after the Model-View-Controller pattern commonly used in GUI development: the View is a represention over IRC or another messaging system, the Controller responds to messages generated by running a <a href="http://www.webgain.com/products/java_cc/">grammar-based parser</a> over the user&#8217;s input, and the Model lives on the web. The bot only keeps state relevant to the conversation (e.g. which picture we are currently talking about).</p>
<p>To get the bot up and running, I started by creating a GET-able query system based on <a href="http://www.hpl.hp.com/semweb/jena-top.html">jena</a>. It has a nice RDF query language that&#8217;s somewhat SQLish, and can use berkeleydb and rdbms backends. I modeled <a href="http://www.picdiary.com/~mattb/queries.rdf">a store of queries</a> in RDF and wrote a java servlet to run queries and return results in <a href="http://www.picdiary.com:8180/rss/query/depicts?mbox=mailto:edd@usefulinc.com">naive XML</a> or <a href="http://www.picdiary.com:8180/rss/query/depicts?mbox=mailto:edd@usefulinc.com&#038;rdf=1">RDF</a> formats.</p>
<p>With this flexible backend, I was able to write a commandline version of a bot using simple HTTP requests and the <a href="http://jakarta.apache.org/commons/digester/">Jakarta Digester</a> to extract information from the XML. Adding a new feature is mostly a case of augmenting the parser&#8217;s grammar and adding a new query to the query store.</p>
<p>Here&#8217;s a sample session with the commandline version of the bot:</p>
<pre>
> find mailto:jo@abduction.org
mailto:jo@abduction.org depicted in http://www.picdiary.com/xcom/IMG_1676.jpg
> read xcom
0: http://www.picdiary.com/xcom/IMG_1674.jpg
1: http://www.picdiary.com/xcom/IMG_1676.jpg
2: http://www.picdiary.com/xcom/IMG_1677.jpg
3: http://www.picdiary.com/xcom/IMG_1678.jpg
> current file
xcom
> use 0
Using pic with uri http://www.picdiary.com/xcom/IMG_1674.jpg
> current pic

http://www.picdiary.com/xcom/IMG_1674.jpg

> depicts
mailto:edd@usefulinc.com
mailto:ben@hammersley.com
> use 1
Using pic with uri http://www.picdiary.com/xcom/IMG_1676.jpg
> depicts
mailto:jo@abduction.org
</pre>
<p>The next step is to extend the query system to allow updates and creates, and I&#8217;ll be nearly done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2003/01/09/photo-annotating-bot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To bots about gatebot</title>
		<link>http://www.hackdiary.com/2002/08/26/to-bots-about-gatebot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=to-bots-about-gatebot</link>
		<comments>http://www.hackdiary.com/2002/08/26/to-bots-about-gatebot/#comments</comments>
		<pubDate>Mon, 26 Aug 2002 14:41:05 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[bots]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=6</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>A mail <a href="http://london.pm.org/pipermail/bots/2002-August/000125.html">to the bots list</a> about a web-to-IRC gateway.</p>
<p><span id="more-6"></span><br />
<b>Subject: [Bots] gatebot &#8211; making bots URL-addressable</b><br />
From: Matt Biddulph<br />
<i>Date: Mon Aug 26 14:41:05 2002</i></p>
<p>I&#8217;ve put up a new experimental service that allows code to talk to IRC<br />
bots over the web without making a direct IRC connection.</p>
<p>You can try it out here via a dodgy web form interface:</p>
<p><a HREF="http://www.picdiary.com/bot/index.html">http://www.picdiary.com/bot/index.html</a></p>
<p>But it&#8217;s really meant as some kind of web API for access by code (e.g.<br />
so web apps could ask the foafbot for people-related information). It<br />
works like this:</p>
<p>POST to<br />
<a HREF="http://www.picdiary.com/bot/servlet/GatebotServlet/some.irc.server/somebotnick">http://www.picdiary.com/bot/servlet/GatebotServlet/some.irc.server/somebotnick</a><br />
with a query of &quot;say=what%20you%want%20to%say&quot;. The web service sends a<br />
proxy bot onto some.irc.server and privmsgs somebotnick with what you<br />
want to say.</p>
<p>You get back a simple HTML document, with a 201 Created status to<br />
indicate the creation of a new session URL for you to read back what is<br />
said. This session URL is given both in the HTML (for browser-based<br />
testing) and in the HTTP Location: header. Every time you hit this URL,<br />
it&#8217;ll give you a line-by-line dump of what have been privmsged back to<br />
the proxy bot (obviously this will be blank if you hit the URL quickly -<br />
if you expect an answer then poll it at some regular interval).</p>
<p>If nothing is said to the bot for 60 seconds, it leaves the IRC network<br />
but the URL remains available &#8216;indefinitely&#8217; (it&#8217;s kept in memory and<br />
will die when my webserver restarts). You should also be able to say<br />
further things to the same bot in the same session by POSTing to the<br />
session URL with &quot;say=whatever&quot;</p>
<p>Source code (perl for the bot bits, java servlet for the web bits) is<br />
here:<br />
<a HREF="http://www.picdiary.com/~mattb/bots/gatebot-0.2.tar.gz">http://www.picdiary.com/~mattb/bots/gatebot-0.2.tar.gz</a><br />
Apologies for any hard-coded paths or other cruftiness. The version of<br />
Bot::BasicBot in there is slightly modified to listen on STDIN so that<br />
the web layer can communicate with its proxy bots by spawning processes<br />
and using STDIN/STDOUT.</p>
<p>There are a couple of pieces of demo client code in the tarball.<br />
getkarma asks the infobot &#8216;robert&#8217; on #pants for karma of things via a<br />
commandline interface. There&#8217;s also an infobotkarmabot that does the<br />
same thing but with an IRC interface.</p>
<p>Here&#8217;s the IRC karma bot connecting to #bots on london.rhizomatic.net:</p>
<p>&#8211;&gt; robertpro (~<a HREF="mailto:robertpro@217.158.195.49">robertpro@217.158.195.49</a>) has joined #bots<br />
&lt;mattb&gt; robertkarma test<br />
&lt;robertpro&gt; robert says test has karma of 1</p>
<p>and the action this triggered on #gatebot (where proxy bots hang out<br />
while they&#8217;re privmsging) on the irc network where #pants lives:</p>
<p>&#8211;&gt; EUUREbot (<a HREF="mailto:tomcat4@pod-124.dolphin-server.co.uk">tomcat4@pod-124.dolphin-server.co.uk</a>) has joined #gatebot<br />
&lt;EUUREbot&gt; robert said &#8216;test has karma of 1&#8242;</p>
<p>Feel free to play with this, and flame me royally if it breaks or sucks.</p>
<p>Cheers,<br />
Matt.</p>
<hr />
<p>and a later <a href="http://london.pm.org/pipermail/bots/2002-August/000129.html">response</a> to a followup:</p>
<p>On Mon, 2002-08-26 at 17:16, Mark Fowler wrote:<br />
> Hmm.  Any reason this can&#8217;t be a GET?  Aside from the breaking of the<br />
> idempotent nature of requests I mean (pah, RFCs.)  It&#8217;d just be nice so<br />
> that you can use it with Mozilla&#8217;s bookmark keywords function (where you<br />
> can type &#8216;$keyword $foo&#8217; and it looks up a url you&#8217;ve associated with<br />
> $keyword changing &#8216;%s&#8217; for a URI encoded version of $foo.)</p>
<p>Yeah, preserving the semantics of POST seems quite important here &#8211; this<br />
is initiating an action, which causes the creation of a resource (both<br />
in the sense of the URL and the process actually forked). This resource<br />
then becomes readable in an idempotent way, its content changing as it<br />
(hopefully) interacts with the remote bot it&#8217;s talking to.</p>
<p>In order to support an application such as &#8216;return me this information&#8217;<br />
for bookmark-keywords purposes, I would rather a wrapper application<br />
were used that was truly GETtable &#8211; it would make the initial POST and<br />
poll the resulting GETtable session until it returned some useful<br />
information. Only then would it return 200 OK and some content to the<br />
client. A directly GETtable gatebot service would 99% of the time simply<br />
return a blank screen to the browser because it has no way of knowing<br />
how long to wait (if it should wait for a response at all).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2002/08/26/to-bots-about-gatebot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

