<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>bits in a short bit</title>
	<atom:link href="http://bitsinashortbit.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bitsinashortbit.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 19 Nov 2007 23:32:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bitsinashortbit.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>bits in a short bit</title>
		<link>http://bitsinashortbit.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bitsinashortbit.wordpress.com/osd.xml" title="bits in a short bit" />
	<atom:link rel='hub' href='http://bitsinashortbit.wordpress.com/?pushpress=hub'/>
		<item>
		<title>NestedSortable Rails Plugin</title>
		<link>http://bitsinashortbit.wordpress.com/2007/11/19/nestedsortable-rails-plugin/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/11/19/nestedsortable-rails-plugin/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 22:52:28 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Nested Sortable]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/11/19/nestedsortable-rails-plugin/</guid>
		<description><![CDATA[If you are a Ruby on Rails developer (if not you should become one) I have good news for you: a Rails plugin that makes it really easy to implement a NestedSortable Widget data source is almost ready for primetime. That will make implementing the NestedSortable Widget as easy as 1-2-3. It is already working, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=21&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are a Ruby on Rails developer (if not you should become one) I have good news for you: a Rails plugin that makes it really easy to implement a NestedSortable Widget data source is almost ready for primetime. That will make implementing the NestedSortable Widget as easy as 1-2-3.  It is already working, as a matter of fact, its only missing some automated tests, helpers I want to create (for including the NestedSortable widget in your views) and documentation. It works for Rails 1.2.3, I haven&#8217;t tested it with Rails edge yet.</p>
<p>I will give a brief overview of how it works. All you need is a model with a column that should hold a foreign key to the parent and a column to  hold an index number for the position of the element inside its hierarchy. The defaults (convention over configuration!) are &#8220;parent_id&#8221; and &#8220;position&#8221;. Suppose our model (the one we want to nest and sort) is named &#8220;Item&#8221;. You will only need one line of code to implement a data source for it in your controller:</p>
<pre>class ItemsController &lt; ApplicationController
	nested_sortable_data_source_for :item
end</pre>
<p>By default the data source will be created under an action named &#8220;order&#8221;, inside your controller. Don&#8217;t worry, all the defaults can be overridden (wait for the docs or take a peak at the code).</p>
<p>In your view, it will be pretty easy to add the NestedSortable Widget, as always:</p>
<pre>&lt;script&gt;
	jQuery( function($) {
		$('#items_sort').NestedSortableWidget({
 			loadUrl: "/items/order/1.json"
 		});
	});
&lt;/script&gt;
&lt;div id="items_sort"&gt;&lt;/div&gt;</pre>
<p>Don&#8217;t forget that you will need to include the scripts (jQuery, Interface, etc) and the CSS file for the widget, by putting something like this in the HEAD of your HTML file, in your layout file probably:</p>
<pre>&lt;%= stylesheet_link_tag 'ns/nestedsortablewidget' %&gt;
&lt;%= javascript_include_tag "jquery-1.1.4.js" %&gt;
&lt;%= javascript_include_tag "interface-1.2.js" %&gt;
&lt;%= javascript_include_tag "inestedsortable-1.0.1.pack.js" %&gt;
&lt;%= javascript_include_tag "jquery.nestedsortablewidget-1.0.pack.js" %&gt;</pre>
<p>Ok, you say. That is neat, but how do I customize what data will be displayed in the columns by my NestedSortable Widget? The default is to display all the columns/attributes your model has (excluding the ID and foreign keys). You can use the :columns option of the nested_sortable_data_source_for to make your data source display pretty much anything you want, in any order you want. Just an example:</p>
<pre>nested_sortable_data_source_for(
	:item,
	:columns=&gt;[
		[:title, 'Title of the Item'],
		[:description, 'Description of the Item'],
		[ lambda {|i| i.created_at.to_date.to_formatted_s(:long)}, 'Creation Date'],
		[ lambda {|i| i.attachments.count}, 'Attachments']
	]
)</pre>
<p>If you are smart enough you already got it: it will display a table with 4 columns, the title of the item, description, creation date and the number of attachments it has. Note the use of lambdas (functions that are passed as variables). It gives you the power to display whatever you want in the columns of your NestedSortable Widget.</p>
<p>Ok again, you say. The way things are until now will only allow me to have one set of items per database table. In your application, you will usually have a lot of users, and will not want to create one table per user. You want everything in the same table, and your &#8220;item&#8221; model probably have a &#8220;user_id&#8221; foreign key. That has been thought of as well. You have the :conditions option, which will give you the flexibility you need. An example:</p>
<pre>nested_sortable_data_source_for(
	:item,
	:conditions=&gt; lambda {|controller| {:user_id =&gt; controller.params[:id]} }
)</pre>
<p>Note the funky lambdas again. Instead of a lambda, you may pass in a symbol, like :conditions_generator with the name of a method in your controller (make it protected, please) that will generate the conditions for you. The conditions are exactly like the ones you may use in your finders in Rails: they may be strings with SQL, they may be arrays like ["a = ?", "b"], and anything else that is allowed in Rails conditions.</p>
<p>In your view, in the part you set up the widget, you would probably use something like:</p>
<pre>loadUrl: "/items/order/&lt;%=current_user.id%&gt;.json"</pre>
<p>This is insecure: users could easily change the order of the items that belong to other users, with little effort. To implement security, you need to make our condition generator a little bit smarter. It is up to you, though&#8230;</p>
<p>Briefly, that is what this plugin for Rails does: it makes it ridiculously easy to implement a NestedSortable Widget in your Rails apps (I bet you could do it in 5 minutes!). Don&#8217;t show it to your boss, he will probably fire you and begin doing it himself. Note that the data source you create fully supports pagination: you may use any option the NestedSortable Widget provides and it should work like a charm.</p>
<p>To try the plugin, install it using Rails install command, in your Rails application path:</p>
<p><em>script/plugin install https://nestedsortables.googlecode.com/svn/trunk/rails/nested_sortable</em></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=21&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/11/19/nestedsortable-rails-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>New minor version of NestedSortable</title>
		<link>http://bitsinashortbit.wordpress.com/2007/10/17/new-minor-version-of-nestedsortable/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/10/17/new-minor-version-of-nestedsortable/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 12:33:22 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Nested Sortable]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/10/17/new-minor-version-of-nestedsortable/</guid>
		<description><![CDATA[The plain Nested Sortable plugin just had its first official version shift, with a minor improvement: you can now prevent a few elements from receiving children, by applying a class to them, and make sure they will always be nodes in the tree. You can configure this using the &#8220;noNestingClass&#8221; option. Thanks for Peter for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=20&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The plain Nested Sortable plugin just had its first official version shift, with a minor improvement: you can now prevent a few elements from receiving children, by applying a class to them, and make sure they will always be nodes in the tree. You can configure this using the &#8220;noNestingClass&#8221; option. Thanks for Peter for giving the idea and figuring out a simple way to do it (it took 3 lines of code).</p>
<p>Get it here: <a href="http://nestedsortables.googlecode.com/">http://nestedsortables.googlecode.com/</a></p>
<p>jQuery 1.2 was released and it is incompatible with Interface. Some things work, some don&#8217;t, and it turns out there is a bug with jQuery 1.2 and the Sortable, in IE only (thanks<span class="author">  n3dst4 for reporting)</span>. So I am updating my tests to use jQuery 1.1.4, and recommend you guys avoiding  jQuery 1.2 until Interface gets updated (probably never) or the new jQuery user interface plugin, jQuery UI,  is usable enough  to replace it entirely (it is still a little far from it). I wonder whether releasing jQuery 1.2, without making sure it was compatible with Interface,  or waiting until jQuery UI was fully baked, was a good move. It might hurt jQuery popularity, since its current version doesn&#8217;t have a decent set of UI plugins (Interface being incompatible and jQuery UI pre-alpha), the first thing people look for when using a JS library.</p>
<p>So, in the not so distant future, I might need to update NestedSortable plugins to use jQuery UI, instead of Interface. It will be a good excuse for a 2.0 version&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=20&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/10/17/new-minor-version-of-nestedsortable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>The final bits of GSoC</title>
		<link>http://bitsinashortbit.wordpress.com/2007/09/16/the-final-bits-of-gsoc/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/09/16/the-final-bits-of-gsoc/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 05:51:12 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>
		<category><![CDATA[Nested Sortable]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/09/16/the-final-bits-of-gsoc/</guid>
		<description><![CDATA[I am now considering finalized my work on the GSoC project (from now on call it voluntary work&#8230; ). After a lot of bug fixing and some documentation, I am releasing the 1.0 version of both NestedSortables jQuery plugins. Please, visit the plugins&#8217; homepage to check out and comment on the documentation. I have compiled [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=19&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am now considering finalized my work on the GSoC project (from now on call it voluntary work&#8230; <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ). After a lot of bug fixing and some documentation, I am releasing the 1.0 version of both NestedSortables jQuery plugins. Please, visit the <a href="http://nestedsortables.googlecode.com/">plugins&#8217; homepage</a> to check out and comment on the documentation. I have compiled the scripts into compressed format and they are now about 75% smaller, and will download pretty fast.</p>
<p>After a lot of helpful comments from folks at the WP-Hackers list, I improved a few details in the WordPress page ordering. I also managed to fix all the remaining problems I mentioned in my last post (more about them later on), so I believe it is now ready to be rolled out in the development version. To try it out, you can check <a href="http://bernardopadua.com/wp-sandbox/19-sep-2007/wp-admin/edit-pages.php">my sandbox</a> (user: test / pass: test), download the <a href="http://www.bernardopadua.com/wordpress/downloads/wordpress_with_page_ordering_19_september_2007.zip">development version of WordPress with it</a> (up-to-date as of 19-Sep 2007 <strike>16-Sep-2007</strike> WP from trunk), or apply it to your own working copy of WordPress from SVN trunk using <a href="http://www.bernardopadua.com/wordpress/patches/ajax%20sortable%20pages%20for%20wp.19-09-07.patch">this patch</a> (you will probably also need <a href="http://www.bernardopadua.com/wp-sandbox/19-sep-2007/wp-admin/images/progress_indicator.gif">this image</a>, which I think can&#8217;t be included in the patch). I will submit the patch to the WordPress TRAC. I hope it gets reviewed and accepted.</p>
<p><span id="more-19"></span><br />
Besides cosmetic improvements (animations, button position), I changed two configuration parameters for the NestedSortable Widget (can be easily reverted at <strong>wp-admin/js/edit-page-order.js</strong>), when compared to the first showcase. It is now paginating at 20 items. I also am turning on the &#8220;greddy&#8221; option, what means the list will be downloaded all at once, even though it will be displayed paginated. Why would I want to do that? Three reasons:</p>
<ul>
<li> Each additional item in the list takes about 90 bytes, on average. So, if you had 1000 pages, it would be only 90kB to download. Downloading 90kB at once is way faster than downloading 5kB 20 times, mostly because of server processing.</li>
<li>Server processing is what takes longer here. When fetching just 50 items out of 1000, the server is actually loading the whole list, then filtering only what we want (yes, this could be optimized, but the issues with hierarchies make it a complex task). So, if we load tiny parts of the list 20 times, it should take 20 times more processing than loading the whole thing at once.</li>
<li>Paginating the list on the client is still important, because the JavaScript will get heavy on the client&#8217;s CPU when you have lists of more than 50 items to sort.</li>
</ul>
<p>If you still prefer the old fashioned way, all it takes is setting &#8216;greddy&#8217; to false in <strong>wp-admin/js/edit-page-order.js</strong>.</p>
<h3> What did I have to change in WordPress?</h3>
<p>Due to the component nature of the plugins I developed, very little had to be changed into the native WordPress code to add this functionality. The only &#8216;real&#8217; PHP code created was for the data source that feeds the plugin with JSON and saves the page order, and it was less than 200 lines long. JavaScript was also minimal, since 99% of the logic was in the jQuery plugins I created. The other modifications were minor. Even the <em>edit-pages.php</em> was almost untouched.</p>
<p>I will briefly describe the files that were altered/added:</p>
<p><strong>wp-includes/class-page-order.php</strong> &#8211; <em>added </em>- this class encapsulates most of the &#8220;data-source&#8221; functionality, and takes care of both loading the page list, with pagination support, and saving it back to the DB.</p>
<p><strong>wp-includes/class-JSON.php</strong> &#8211; <em>added </em>- class by Michal Migurski that will convert php data structures to JSON (and also from, but I didn&#8217;t need it).</p>
<p><strong>wp-admin/admin-ajax.php</strong> &#8211; <em>altered </em>- Added two actions to serve as the data source for the widget, one for fetching ( &#8216;page-order-load&#8217;) and other for saving (&#8216;page-order-save&#8217;) the order. The actions are small, since they use the Page_Order class.</p>
<p><strong>wp-admin/edit-pages.php</strong> &#8211; <em>altered </em>- Just a couple of lines to load the JavaScript and CSS that builds the widget, if the user has the permission to order pages.</p>
<p><strong>wp-admin/js/edit-page-order.js</strong> &#8211; <em>added </em>-  This script will add the &#8220;Edit Page Order&#8221; button, that will build the NestedSortable Widget on the user&#8217;s demand. It also holds the configuration of the widget.</p>
<p><strong>wp-admin/css/nestedsortablewidget.css</strong> &#8211; <em>added </em>- CSS for the plugin.</p>
<p><strong>wp-admin/images/progress_indicator.gif</strong> &#8211; <em>added </em>- AJAX loading animated gif.</p>
<p><strong>wp-admin/includes/schema.php</strong> &#8211; <em>altered </em>- Had to change this to add a &#8216;order-pages&#8217; type of permission to the database. This is likely to break as the DB version number evolves.</p>
<p><strong>wp-admin/includes/upgrade.php</strong> &#8211; <em>altered </em>- Had to change this to add a &#8216;order-pages&#8217; type of permission to the database. This is likely to break as the DB version number evolves.</p>
<p><strong>wp-includes/version.php  &#8211; </strong><em>altered </em><strong>- </strong>I had to increment the DB version to make WP upgrade the DB and add the &#8216;order-pages&#8217;  permission.</p>
<p><strong>wp-includes/script-loader.php </strong>- <em>altered </em>- added the declaration for the JavaScript files I added, and the text with internationalization.</p>
<p><strong>wp-includes/js/jquery/inestedsortable.js &#8211; </strong><em>added </em><strong>- </strong>the first of my two jQuery plugins, compressed<strong><br />
</strong></p>
<p><strong>wp-includes/js/jquery/jquery.nestedsortablewidget.js &#8211; </strong><em>added </em><strong>- </strong>the second of my two jQuery plugins, compressed</p>
<h3> Will I assemble it as a WordPress plugin?</h3>
<p>The sort answer is no, unless there is great demand and strong reasons not to apply this to the core WordPress. Don&#8217;t take me wrong, I love plugins. But I don&#8217;t think this is good for a plugin, it is too much of a basic functionality. Most people won&#8217;t ever even look for a plugin to make sorting their pages faster, only in very special cases; they will just go ahead and sort them the hard way. There is already a plugin with this intention (<a href="http://geekyweekly.com/mypageorder/">my page order</a>) and the author admits it doesn&#8217;t have that much demand. Making an analogy: car accessories are also great; but you wouldn&#8217;t be very happy with a car where the tires and the steering wheel were accessories.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=19&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/09/16/the-final-bits-of-gsoc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>First showcase of page sorting in WordPress</title>
		<link>http://bitsinashortbit.wordpress.com/2007/09/03/first-showcase-of-page-sorting-in-wordpress/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/09/03/first-showcase-of-page-sorting-in-wordpress/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 01:28:51 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>
		<category><![CDATA[Nested Sortable]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/09/03/first-showcase-of-page-sorting-in-wordpress/</guid>
		<description><![CDATA[I have finished the integration of the nested sortable widget into WordPress. I have set up a Sandbox WordPress installation, which can be accessed here (use test/test for login, go to &#8220;Manage-&#62;Pages&#8221;, and click &#8220;Edit Page Order&#8221; in the end of the page list). I have also put up a diff file (untested), which can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=18&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have finished the integration of the nested sortable widget into WordPress. I have set up a Sandbox WordPress installation,  which can be <a href="http://bernardopadua.com/wordpress/wp-admin/edit-pages.php">accessed here</a> (use test/test for login, go to &#8220;Manage-&gt;Pages&#8221;, and click &#8220;Edit Page Order&#8221; in the end of the page list). I have also put up a <a href="http://bernardopadua.com/wordpress/patches/ajax%20sortable%20pages%20for%20wp.02-09-07.patch">diff file</a> (untested), which can be applied to your WordPress SVN checkout if you want to try it out on your own instalation (Automattic folks, don&#8217;t apply this yet to the WordPress SVN, there are a few details left to be solved, such as compressing the JS code and others, as I explain bellow).</p>
<p><span id="more-18"></span>I have set it up to paginate at only 10 items (please add more pages to play with it, I am lazy), to make it easier to see this functionality (the final version should paginate at 50 or more &#8220;pages per page&#8221;). Besides that, it is pretty much as it should be in a final version. There are probably a lot of minor details in the overall interaction and appearance which can be improved, so I am waiting for suggestions.</p>
<p>Here are a few ideas, questions and dark spots, that I would like people to comment on:</p>
<ul>
<li>Is the text used in the buttons/widget ok?</li>
<li>If the user changes the order of a few pages, doesn&#8217;t save, and navigate away, he will lose his changes. Should a &#8220;Are you sure?&#8221; warning be displayed in this case?</li>
<li>The position for the &#8220;Edit Page Order&#8221; button is ok? Perhaps it could it be duplicated or appear at the top of the original page list. Perhaps it could be a link. I think people shouldn&#8217;t use it that often, that is why I placed it the way it is now.</li>
</ul>
<p>There is also a tiny problem that is bothering me a lot. The current version of Interface (1.2), that is in the WordPress SVN, has a bug that prevents the &#8220;AutoScroll&#8221; (which makes the browser window scroll when you are dragging a page near the edge of the viewport) functionality of the NestedSortable plugin to work. I don&#8217;t actually know where in Interface&#8217;s code this bug is, but I know it is fixed in its latest SVN version, which is the one I am using in all my examples (I have added it to my WordPress Sandbox and my patch, so you shouldn&#8217;t notice it). The problem is that the Interface from SVN is not JS compressed and is not unified in a single file, as is the 1.2 &#8220;stable&#8221; version. Adding it to WordPress would require doing that, and there are no &#8220;compile&#8221; scripts in the Interface SVN, as there are for jQuery, for instance. I don&#8217;t even know whether Interface is being maintained, so there might never be a 1.3 version out. I could disable it, but without &#8220;AutoScroll&#8221; it becomes obnoxious to drag the pages when you have long lists , which should be the case if you have more than 10 pages or so.  You have to use the scrolling wheel, which some people don&#8217;t even have.</p>
<p>There is also another technical detail: I should probably add a &#8220;order_pages&#8221; permission to WordPress. I can&#8217;t use the &#8220;edit_page X&#8221; permission, as it is applied in an individual basis and there is no way to do that when you are ordering all the pages at once. Is it ok to create that? I will have to figure it out (never played with adding permissions to WordPress before), but I believe it should be no big deal. I also don&#8217;t know to what roles I should add it (Editor? Author?).</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=18&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/09/03/first-showcase-of-page-sorting-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>The widget is feature complete now</title>
		<link>http://bitsinashortbit.wordpress.com/2007/08/25/the-widget-is-feature-complete-now/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/08/25/the-widget-is-feature-complete-now/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 18:54:26 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>
		<category><![CDATA[Nested Sortable]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/08/25/the-widget-is-feature-complete-now/</guid>
		<description><![CDATA[UPDATE: The plugin has now reached its 1.0 version, and is available in a compressed version and with documentation. Please check the project homepage at: http://nestedsortables.googlecode.com/ The widget is feature complete now and working well with the major browsers I have tested it (that is, FF2, IE7, IE6 and Safari 3). It took a little [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=17&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong>: The plugin has now reached its 1.0 version, and is available in a compressed version and with documentation. Please check the project homepage at: <a href="http://nestedsortables.googlecode.com/">http://nestedsortables.googlecode.com/</a></p>
<p>The widget is feature complete now and working well with the major browsers I have tested it (that is, FF2, IE7, IE6 and Safari 3). It took a little bit of hacking to remove the bugs in IE, but in Safari it worked like a charm the first time I tried it (and Safari is also the browser where it looks and feels faster &#8211; they probably have the best JavaScript interpreter out there). I changed a few things in the underlying Nested Sortable plugin, so it should be a lot faster now, in all browsers. The test <a href="http://www.bernardopadua.com/nestedSortables/test/widget/">demo can be seen here</a> as usual and is now up-to-date with my latest SVN updates.</p>
<p>Serialization will, by default, send the data using POST and encoding the data using the &#8220;query string standard&#8221; , which most server side languages should automatically convert to their equivalent data structures for arrays and hashes. You can also configure the widget to return the data in JSON format (for that you need to include the JSON jQuery pluing) and process it in your server using one of the countless JSON libraries available. Following the <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST principles</a> under the HTTP protocol, if the HTTP response has a success code the widget will think data was saved correctly. You can even use the same server path (ie. the same script) to retrieve and save the data, since it will use GET to retrieve and POST to save.</p>
<p>I am aware that the &#8220;incremental&#8221; feature (showcased in the last example) does have a few problems when you change the item from one &#8220;page&#8221; to the next (even though you see things in a continuum , what you see is actually the different pages, each inside its own UL with a NestedSortable, being rendered in sequence). I am also aware there is a minor cosmetic issue with the spacing of columns in IE6. I am not much of a CSS browser quircks&#8217; wizard and &#8220;incremental&#8221; shouldn&#8217;t be used in WordPress, I presume, so I am going to leave those issues to be solved after the Widget is integrated in WordPress.</p>
<p>If you find any other bugs or have more suggestions, please post a comment.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=17&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/08/25/the-widget-is-feature-complete-now/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>New Improvements in the Widget</title>
		<link>http://bitsinashortbit.wordpress.com/2007/08/21/new-improvements-in-the-widget/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/08/21/new-improvements-in-the-widget/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 21:16:55 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>
		<category><![CDATA[Nested Sortable]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/08/21/new-improvements-in-the-widget/</guid>
		<description><![CDATA[Following Mike&#8217;s suggestions, I am now using jQuery&#8217;s slideIn() and slideOut() as the default effect for page transitions. They are being applied in parallel (the old page slides out while the next slides in). To make this change I had to do some changes to the way different parts of the widget are displayed, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=16&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Following Mike&#8217;s suggestions, I am now using jQuery&#8217;s <strong>slideIn()</strong> and <strong>slideOut()</strong> as the default effect for page transitions. They are being applied in parallel (the old page slides out while the next slides in). To make this change I had to do some changes to the way different parts of the widget are displayed, I believe things are &#8220;jumping up&#8221; a lot less when you change from one page to the other.  I also added the possibility for the user to use his own custom functions for the transition, which can be applied in parallel or in series.</p>
<p>I have also added the &#8220;incremental&#8221; option,  which will make the new pages that are loaded be incremented to the existing ones in the user display. This is usable by itself. My intention was to allow the user to display the list inside a scrollable div to go along with this option, but after a few tests, I am seeing the dimensions stored in the Sortables would need to be recalculated every time you scroll the div, and I am afraid making this work seamlessly could take some time and possible changes to Interface&#8217;s Sortables itself. It would probably be unbearably slow as well.</p>
<p>I changed the demo to showcase these and also a lot of other options that are available. The demo will now load 5 different instances of the widget.</p>
<p><a href="http://www.bernardopadua.com/nestedSortables/test/widget/">It can be seen here</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=16&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/08/21/new-improvements-in-the-widget/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>Nested Sortable Widget</title>
		<link>http://bitsinashortbit.wordpress.com/2007/08/19/nested-sortable-widget/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/08/19/nested-sortable-widget/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 13:55:25 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/08/19/nested-sortable-widget/</guid>
		<description><![CDATA[UPDATE:  The plugin has now reached its 1.0 version, and is available in a compressed version and with documentation. Please check the project homepage at: http://nestedsortables.googlecode.com/ I am posting a demo of what I am calling the Nested Sortable Widget here. In this example I am only showing a small subset of the possible configuration [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=15&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong>:  The plugin has now reached its 1.0 version, and is available in a compressed version and with documentation. Please check the project homepage at: <a href="http://nestedsortables.googlecode.com/">http://nestedsortables.googlecode.com/</a></p>
<p>I am posting a demo of what I am calling the <a href="http://www.bernardopadua.com/nestedSortables/test/widget/">Nested Sortable Widget here</a>.</p>
<p>In this example I am only showing a small subset of the possible configuration options it has. The component/widget is basically finished, but there is still a tiny bug in IE when you drag items with more than one hierarchy, which I am going to investigate soon. The &#8220;save&#8221; function also need a few extra hours of work to be finished, but that doesn&#8217;t affect the demo. Reports for any other bugs are welcome.</p>
<p>The main features of the component are:</p>
<ul>
<li> Loads data from a JSON data source, with a predefined format (I will explain it once I create the final doc. for the widget, but it is very simple and can be inferred from the demo) . This format is very compact and very easy to generate and manipulate in any server side language, since it only uses standard data structures, like arrays and hashes, unlike XML.</li>
<li>Support for pagination, both in the server (it will only load smaller chunks of data each time) and in the client (it will display smaller chunks of data at a time).</li>
<li>Funky way to move items from one page to another, following Mike&#8217;s suggestion.</li>
<li>Can display data with multiple columns, all you have to do is change your data source.</li>
<li>Allows you to change the nesting direction to right to left, and it will change the order of the columns automatically.</li>
<li> Lots and lots of easy options to to customize the visual appearance of the widget and most of it other aspects. Don&#8217;t worry, I will document them all (or you may dig in the code and figure it out now <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</li>
</ul>
<p><span id="more-15"></span></p>
<h3>More details about pagination</h3>
<p>In the demo I am showing it being used with pagination, with 5 items per page, on a dataset of about 30 items. I set up a simple PHP page as a demo data source that will spit clusters of a bigger JSON with the whole data, according to the page requested (actually, you request the first item and the total number of items you want, as I will explain). Optionally, you may simplify the data source and always reply with the whole dataset, pagination will still happen in the client side. Or your data source may be &#8220;greedy&#8221; and reply with a bigger chunk than the one requested. The component will be smart enough not to request any data it already has. Using Firebug in Firefox allows you to see very easily when and what data is being requested/returned.</p>
<p>In most cases I think sending the whole chunk of data could be the simpler and also the faster way to handle pagination, specially in the WordPress page list use case. It would be very unlikely, to have a user with more than, say, 100 pages to order, which are still very fast to load at once (I am guessing it would take less than 5kB for 100 items). If you do that, the client will still see the data paginated, but the server doesn&#8217;t need to worry about it at all. The component obviously has support for no pagination as well, you only have to turn a flag off, and in this case the client will see all the data at once.</p>
<p>You will notice that in my demo a page won&#8217;t always have 5 items, sometimes it will have more: this is by design, as if I was to enforce only 5 items per page we would have to break hierarchies in half, what would be weird for the user and terrible to program, as well, as I have discussed in earlier posts. The way I figured to solve the inconsistencies and avoid duplicate items among pages is described in the following paragraphs:</p>
<p>First, what does the component displays in each page then? Initially, when it is loaded, it requests the first item of the page being loaded. If loading the third page with 5 elements per page, that would be the element with the zero-based index order of 15. But it will actually display the first element after the one with index 15 that doesn&#8217;t have any parents &#8211; we will call it a &#8216;root&#8217; element from now on. And it will display <em>at least</em> 5 items, since it will always show complete hierarchies.</p>
<p>When the component needs some data to display a page, it will make a request with 2 parameters:</p>
<ul>
<li><strong>firstIndex </strong>(what is the zero-based ordered position of the next item I want to fetch and display. Note the component actually wants to display, as the first item in the page being shown to the user, the first root element after it, but it doesn&#8217;t know in advance what it is )<strong><br />
</strong></li>
<li><strong>count </strong>(how many items, at minimum, should be returned)</li>
</ul>
<p>The server should reply with the data, in JSON format, that, besides the data itself, has the following parameters:</p>
<ul>
<li><strong>requestFirstIndex </strong>(what <em>firstIndex </em>was requested)</li>
<li><strong>count </strong>(how many items were actually returned, which should be greater or equal to what was requested)</li>
<li><strong>firstIndex </strong>(what was the index of the first element actually returned; ideally, it should be the first root item after <em>requestFirstIndex </em>, but it could be also be any root element before it, it could even be &#8217;0&#8242;, if the server decided to return the whole dataset )</li>
<li><strong>totalCount </strong>(how many items does the dataset has in total)</li>
</ul>
<p>Note that the server should always return the whole data that the component wanted to display. Eg: if we request <em>firstIndex = 10, count=5</em><strong>, </strong>the server could return<strong> </strong><em>firstIndex = 5, count=20</em>, but not  <em>firstIndex = 5, count=8</em>.</p>
<p>To be brief: The server should always return what the component wants to display right now, but it could also return more, to the left, or to the right. I know it may sound a little confusing, but it is actually not that big deal.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=15&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/08/19/nested-sortable-widget/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>News</title>
		<link>http://bitsinashortbit.wordpress.com/2007/08/08/news/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/08/08/news/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 18:56:15 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/08/08/news/</guid>
		<description><![CDATA[I am currently working on the &#8220;Nested Sortable Widget&#8221; that I mentioned in the last post. I wanted to be able to showcase it in this post already, but I realized I was taking too long to give out some feedback, so I decided to write just to give some news. The widget is almost [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=14&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am currently working on the &#8220;Nested Sortable Widget&#8221; that I mentioned in the last post. I wanted to be able to showcase it in this post already, but I realized I was taking too long to give out some feedback, so I decided to write just to give some news.</p>
<p>The widget is almost complete, but I am running some issues with pagination, which is a lot more complex than I initially thought, primarily because you can&#8217;t show exactly the same number of items per page, due to the nesting (the pagination needs to be &#8220;soft&#8221;). But I think I am on my way and should be complete in the next 2 or 3 days. Summing up it will be able to fetch a list of  nested elements represented in JSON, will display it,  allow the user to change the order/nesting and will send it back to the server.</p>
<p>In the meanwhile I created a Google Code project for the NestedSortable plugin  and <a href="http://code.google.com/p/nestedsortables/">hosted it there</a>.</p>
<p>I hope to be able to write again pretty soon, with good news!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=14&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/08/08/news/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>Nested Sortable jQuery Plugin</title>
		<link>http://bitsinashortbit.wordpress.com/2007/07/22/nested-sortable-jquery-plugin/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/07/22/nested-sortable-jquery-plugin/#comments</comments>
		<pubDate>Sun, 22 Jul 2007 07:23:15 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/07/22/nested-sortable-jquery-plugin/</guid>
		<description><![CDATA[UPDATE: The plugin has now reached its 1.0 version, and is available in a compressed version and with documentation. Please check the project homepage at: http://nestedsortables.googlecode.com/ I am showing now the first version of what I call the &#8220;Nested Sortable&#8221; jQuery plugin. It is based on the same nesting idea shown on the previous prototypes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=13&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong> UPDATE</strong>:  The plugin has now reached its 1.0 version, and is available in a compressed version and with documentation. Please check the project homepage at: <a href="http://nestedsortables.googlecode.com/">http://nestedsortables.googlecode.com/</a></p>
<p>I am showing now the first version of what I call the &#8220;Nested Sortable&#8221; jQuery plugin. It is based on the same nesting idea shown on the previous prototypes and used on the bbPress forum ordering, but it is totally rewritten and has a very different (and I believe simpler/more efficient) inner working.</p>
<p><a href="http://www.bernardopadua.com/nestedSortables/test/nested_sortable/">A demo of it can be seen here.</a></p>
<p>The highlights of it are:</p>
<ul>
<li>Built on top of <a href="http://interface.eyecon.ro/docs/sort">Interface</a><a href="http://interface.eyecon.ro/docs/sort"> &#8216;s Sortable</a> and maintains compatibility with it. This means you can use the same options available on the Sortable, plus a few extra ones specific to the nesting. You can also mix Sortables and NestedSortables on the same page.</li>
<li>Just as easy to use (see the code examples on the demo).</li>
<li>Can be easily configured for left-to-right or right-to-left nesting.</li>
<li>Can be used with any type of HTML element (that allows nesting), not only ULs and LIs.</li>
<li>You can define a class for the nesting the draggable is currently hovering on, to make it clearer to the user (see my ugly yellow example &#8211; could be made pretty with some css styling).</li>
<li>All the previous bugs/misbehaviours with the prototype are gone (hopefully without additional ones being introduced).</li>
</ul>
<p>It was tested under IE7 and FF2. <strike>What is still lacking for it to be complete (and useable) is a serialization function, which I should finish in a few days</strike> (serialization is now complete, see my comment bellow). As things evolve I should probably add a few callbacks to allow its behavior to be easily configured.</p>
<p>So, the next step for the WordPress page list project is to create a higher level jQuery plugin that will be built on top of this one and will, given a JSON object input, fetched via AJAX, dynamically create the Nested Sortable, with pagination support, using the idea Mike gave on the last comment (the user hovers over a Droppable, which should fetch and display the additional pages). It will be more like a widget.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=13&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/07/22/nested-sortable-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>60</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
		<item>
		<title>More advances</title>
		<link>http://bitsinashortbit.wordpress.com/2007/07/10/more-advances/</link>
		<comments>http://bitsinashortbit.wordpress.com/2007/07/10/more-advances/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 07:51:26 +0000</pubDate>
		<dc:creator>bernardops</dc:creator>
				<category><![CDATA[Google Summer of Code]]></category>

		<guid isPermaLink="false">http://bitsinashortbit.wordpress.com/2007/07/10/more-advances/</guid>
		<description><![CDATA[First things first: I made some updates in the prototype. It now works as expected, allowing you to make a page a child of another page which doesn&#8217;t have children yet. I also show in it what I think is the best way of handling pagination. The idea is to display an item from the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=11&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First things first:  I made some <a href="http://www.bernardopadua.com/wordpress/wp_pagelist_ajax2/edit-pages.php.htm">updates in the prototype</a>. It now works as expected, allowing you to make a page a child of another page which doesn&#8217;t have children yet.</p>
<p>I also show in it what I think is the best way of handling pagination. The idea is to display an item from the main hierarchy before and another one after the items that belongs to the current page, in the ordering view. If the before/after main hierarchy item has children, all of its children should be displayed as well. In the demo, my before and after main hierarchy items are child less, therefore the &#8220;items bellow this&#8221; and &#8220;items above this&#8221; markers show up after one item, but that would vary. I did a lot thinking into this and think this is the only (and simpler) way you can move main items from one page into the other, without having &#8220;dark spots&#8221; (elements that are &#8220;stuck&#8221; in a page).</p>
<p>In trying to understand what was making nesting not working in the prototype, I had to dissect the Interface plugin code for the Draggables, Dropables and Sortables. I found the code pretty cluttered and hard to understand, filled up with variables with names such as &#8220;oC&#8221;, &#8220;oD&#8221;, &#8220;a&#8221;. In fact, almost no variables have meaningful, unabridged names. I had to do a lot of debugging, using <a href="http://www.getfirebug.com/">Firebug</a>. The code is very coupled as well as, for instance, you have calls to the Sortables plugin being made from the Draggable and Dropable (you would expect the Draggables and Dropables, as lower level elements, to be unaware of the Sortables existance). I didn&#8217;t like the code, but at least I understand it now.</p>
<p>Meanwhile, I found out the the jQuery team (John Resig, the creator, included) are creating an official, brand new set of UI plugins for jQuery. It is called <a href="http://docs.jquery.com/UI">jQuery UI</a>. I wonder why they decided to skip Interface all together. It was not released yet, but already have working Draggables, Dropables and Sortables. I checked it out from SVN, looked at its code and tested it. The code is a great step foward from what I saw in Interface. Much cleaner, commented, well organized and easy to understand. Impressively, it also looks like they managed to keep it a lot smaller (30kB against 46kB of Interface&#8217;s). The coupling problem I mentioned doesn&#8217;t exist, as they created a generic callback in the Dragabble (called dropBehaviour), that the Sortable implements. That way, I could, for instance, create a brand new Sortable-like plugin, without having to modify Draggable&#8217;s or Dropable&#8217;s code. They seem to be tackling the &#8220;Sortable with Hierachy&#8221; problem as well, and have some partially working demos for it, in their test files.</p>
<p>Regarding the server side implementation, I am leaning towards passing the javascript a JSON representation of the page list, instead of generating the whole UL list in the server side. I think it will make things much more reusable, in both ways (reusing the javacript and the server side script). It will also download a lot faster for the client. I was thinking of using a JSON like this:</p>
<p><code>{<br />
"columns":["Title(ID)", "Owner", "Updated"],<br />
"items":<br />
[<br />
{<br />
"id":1,<br />
"info":["My Title(1)", "My Owner", "My Date"],<br />
"children":<br />
[<br />
{<br />
"id":2,<br />
"info":["My Title(2)", "My Owner", "My Date"],<br />
},<br />
{<br />
"id":3,<br />
"info":["My Title(3)", "My Owner", "My Date"],<br />
}<br />
]<br />
},<br />
]<br />
}</code></p>
<p>In this example we have a parent page which has two children.  It doesn&#8217;t look so good because I can&#8217;t indent the code to display it here. I already implemented it on the prototype, so now, instead of loading the page list from an file with HTML and just displaying it, it loads a file with JSON and processes it to create the HTML on the fly. The JSON file for the prototype can be seen here: <a href="http://www.bernardopadua.com/wordpress/wp_pagelist_ajax2/list_demo_json.js">list_demo_json.js</a>  The JSON file has 2kB, versus 6kB for the HTML with the exact same data.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/bitsinashortbit.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/bitsinashortbit.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bitsinashortbit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bitsinashortbit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bitsinashortbit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bitsinashortbit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bitsinashortbit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bitsinashortbit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bitsinashortbit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bitsinashortbit.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bitsinashortbit.wordpress.com&amp;blog=1192046&amp;post=11&amp;subd=bitsinashortbit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bitsinashortbit.wordpress.com/2007/07/10/more-advances/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e12b4e08465871a3770f67ebc0abf805?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Bernardo Pádua</media:title>
		</media:content>
	</item>
	</channel>
</rss>
