<?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>Jan Varwig &#187; javascript</title>
	<atom:link href="http://jan.varwig.org/archive/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://jan.varwig.org</link>
	<description>Somewhere between Hello World and HAL9000</description>
	<lastBuildDate>Sat, 03 Dec 2011 00:15:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>REST in Place now with Multiline Editor</title>
		<link>http://jan.varwig.org/archive/rest-in-place-now-with-multiline-editor?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rest-in-place-now-with-multiline-editor</link>
		<comments>http://jan.varwig.org/archive/rest-in-place-now-with-multiline-editor#comments</comments>
		<pubDate>Fri, 05 Feb 2010 18:00:36 +0000</pubDate>
		<dc:creator>Jan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[rest in place]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://jan.varwig.org/?p=247</guid>
		<description><![CDATA[Yesterday I pushed the changes introducing the Multiline editor to REST in Place I announced last week. The definition of forms for editing inline-content is now separated from the Code that deals with Ajax and editing state. This makes it very easy to extend REST in Place with your own Editors. I also decided to [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I pushed the changes introducing the Multiline editor to REST in Place I announced last week.</p>

<p>The definition of forms for editing inline-content is now separated from the Code that deals with Ajax and editing state.
This makes it very easy to extend REST in Place with your own Editors.</p>

<p>I also decided to keep the jQuery backwards compatibility for a bit longer.</p>

<p>Check out the changes at <a href="http://github.com/janv/rest_in_place.git">http://github.com/janv/rest_in_place.git</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jan.varwig.org/archive/rest-in-place-now-with-multiline-editor/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST in Place: Major update ahead</title>
		<link>http://jan.varwig.org/archive/rest-in-place-major-update-ahead?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rest-in-place-major-update-ahead</link>
		<comments>http://jan.varwig.org/archive/rest-in-place-major-update-ahead#comments</comments>
		<pubDate>Mon, 25 Jan 2010 00:08:44 +0000</pubDate>
		<dc:creator>Jan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[inplace editor]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[rest in place]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://jan.varwig.org/?p=237</guid>
		<description><![CDATA[This week, I&#8217;ll roll out a major update to REST in Place. I have completely restructured the code and made the Plugin much more object-oriented, modular and maintainable. Existing installations should be able to upgrade without a hitch. The most important change for users will be the jQuery 1.4 support and support for different editors [...]]]></description>
			<content:encoded><![CDATA[<p>This week, I&#8217;ll roll out a major update to <a href="http://github.com/janv/rest_in_place/">REST in Place</a>. I have completely restructured the code and made the Plugin much more object-oriented, modular and maintainable. Existing installations should be able to upgrade without a hitch. The most important change for users will be the jQuery 1.4 support and support for different editors (such as textarea, checkbox, etc.).</p>

<p>In November I got some pull requests for REST in Place which I didn&#8217;t get to really have a look at until last week. I haven&#8217;t really touched REST in Place in ages and wasn&#8217;t really aware that it was that popular. It has 72 followers and 11 forks on github and who knows how many other people are just silently using it! So, I merged in the contributions and dealt with some issues in the tracker and thought about how to go on.</p>

<p>REST in Place originally was a mere proof of concept and one of my first projects in JavaScript and jQuery. I have since written a lot more complicated applications and even a diploma thesis on JavaScript and the old code just isn&#8217;t up to my standards anymore. Additionally I have received several pull requests for textarea support which all couldn&#8217;t be merged because they were just copypasted and modified a little from the input-tag version. The only solution was a complete rewrite and that&#8217;s what I did. While the plugin still works the same way, the code is properly split up and more modular now. This enables easy extension and maintenance from now on and hopefully quicker development from me and better patches from all users.</p>

<p>This new development has some drawbacks too, unfortunately. This massive improvement will only go to the jQuery version of REST in Place. Since I don&#8217;t know much about Prototype or mootools, I can&#8217;t support both versions anymore. If someone is willing to work with me on this, I&#8217;ll happily accept their contributions but I can&#8217;t do this on my own. If anyone is willing to do so, please reply in the comments, so we can work out a plan. I want to keep all three versions as similar as possible, this means the Prototype and mootools versions should follow the same object-oriented structure as the jQuery version.</p>

<p>One last thing: I will support jQuery &lt; 1.4 until 1.4.1 comes out. 1.4 introduced some very nice changes which I&#8217;d like to make use of but since 1.4 seems a little buggy still, I&#8217;ll continue to support the older versions for a little while.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.varwig.org/archive/rest-in-place-major-update-ahead/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The end is near</title>
		<link>http://jan.varwig.org/archive/the-end-is-near?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-end-is-near</link>
		<comments>http://jan.varwig.org/archive/the-end-is-near#comments</comments>
		<pubDate>Wed, 21 Jan 2009 19:55:48 +0000</pubDate>
		<dc:creator>Jan</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Studium]]></category>
		<category><![CDATA[diploma]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[serverside]]></category>

		<guid isPermaLink="false">http://jan.varwig.org/?p=96</guid>
		<description><![CDATA[No, not of my blog! Quite the contrary, I plan to slowly increase my blogging frequency and extend my topics beyond software. No, the end of my time at Dortmund Technical University is in sight. Yesterday I registered my diploma thesis which I have six months to work on from now, with a deadline of [...]]]></description>
			<content:encoded><![CDATA[<p>No, not of my blog!</p>

<p>Quite the contrary, I plan to slowly increase my blogging frequency and extend my topics beyond software.</p>

<p>No, the end of my time at Dortmund Technical University is in sight. Yesterday I registered my diploma thesis which I have six months to work on from now, with a deadline of July 20th.</p>

<p>I&#8217;ll probably even blog about my progress here since the topic is something a few web dev fellows might be interested in: <em>A thin Web Application Framework based on Serverside JavaScript</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jan.varwig.org/archive/the-end-is-near/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX vs. REST</title>
		<link>http://jan.varwig.org/archive/ajax-vs-rest?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ajax-vs-rest</link>
		<comments>http://jan.varwig.org/archive/ajax-vs-rest#comments</comments>
		<pubDate>Fri, 14 Dec 2007 23:30:09 +0000</pubDate>
		<dc:creator>Jan</dc:creator>
				<category><![CDATA[on Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[inplace editor]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://jan.varwig.org/archiv/ajax-vs-rest</guid>
		<description><![CDATA[A small shop I&#8217;ve been writing for for fathers pharmacy was a welcome playground for modeling my domain RESTful. During my ventures, two big issues had me thinking quite hard for a while and there&#8217;s still no proper solution available. One of them was a DRY implementation of controllers for nested resources which I&#8217;ll describe [...]]]></description>
			<content:encoded><![CDATA[<p>A small shop I&#8217;ve been writing for for fathers pharmacy was a welcome playground for modeling my domain RESTful.
During my ventures, two big issues had me thinking quite hard for a while and there&#8217;s still no proper solution available. One of them was a DRY implementation of controllers for nested resources which I&#8217;ll describe later, the other one was the outdated <a href="http://svn.rubyonrails.org/rails/plugins/in_place_editing/">inplace editor plugin</a> in Rails.</p>

<p><span id="more-70"></span>
<h3>In-Place editing RESTful resources</h3></p>

<p>Writing applications in <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm">REST</a>-style encourages an even stricter separation of view and controller logic than the usual Rails&#8217; stack.
A key principle is that the client alone should provide the user means to manipulate and PUT/POST data to the server. This is easier said than done in current browsers and with the HTML format (which just wasn&#8217;t made for building GUIs, but that&#8217;s a topic for another post). AJAX is the closest we can come to this ideal, enabling a seamless transition from a plain view of a resource to a editable form without going through too much pain.</p>

<p>A widely used way to achieve these transitions are inplace editors, made popular by Flickr and supported through nice helper methods in rails. The probem now is that these helper methods were written around, or even before Rails 1.0 with not the slightest hint of REST in them. Planting <code>in_place_edit_for :object, :attribute</code> in your controller creates a <code>set_object_attribute</code>  action that finds an object by id, updates only <code>attribute</code> and renders <code>attribute</code>s new value as a plain, short string to the client. The client, in this case the XMLHttpRequest, takes that response and puts it in the appropriate place in the HTML document.</p>

<p>There are several problems with this approach:</p>

<ol>
<li>The generated actions are extremely simple and devoid of any form of sophisticated flow control (authorization, exception handling)</li>
<li>The generated actions perform a task that can be done in the good old <code>update</code> action and are thusly redundant.</li>
<li>Those new actions aren&#8217;t at all RESTful.</li>
<li>Ideally, no special server side code should be necessary.</li>
</ol>

<p>While problem 1 can be easily countered by implementing your own version of <code>in_place_edit_for</code>, the real point are the other issues. The <code>update</code> action already performs the task of updating one or more attributes and is equipped with whatever authorization checks are necessary (does object belong to the logged in user?). The <code>update</code> action corresponds to the REST-verb <code>POST</code> and doesn&#8217;t violate REST principles.</p>

<p>A solution that solves all these problems would have to look like this (client-side Javascript only):</p>

<ul>
<li>The inplace editor posts to the objects url (something like <code>/object/123</code>), passing the attribute to be updated as a HTTP parameter.</li>
<li>The server sends a response when the update is completed successfully or unsuccessfully.</li>
<li>In case of an unsuccessful update some form of status could be transferred in the response</li>
<li>In case of a successful update, the server doesn&#8217;t send the updated attributes value, instead the client should GET
the object requesting a <em>text/json</em> content-type, extract the desired attribute from the json and update the HTML with its value.</li>
</ul>

<p>I already tried building my own inplace editor Javascript helper but since much of the functionality of the rails inplace editor depends on the the editor defined in script.aculo.us I gave up. On the one hand the problem wasn&#8217;t so pressing that I could justify spending a weekend digging through the source, on the other hand I&#8217;d really like to see a good jQuery integration in rails and think maybe I could hit two birds with one stone if I try to go this direction one day.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.varwig.org/archive/ajax-vs-rest/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

