<?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>BigSmoke &#187; URL</title>
	<atom:link href="http://blog.bigsmoke.us/tag/url/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bigsmoke.us</link>
	<description>Smokes your problems, coughs fresh air.</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:03:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Silent change in URLs of Ruby on Rails svn repository</title>
		<link>http://blog.bigsmoke.us/2009/02/19/silent-change-in-urls-of-ruby-on-rails-svn-repository</link>
		<comments>http://blog.bigsmoke.us/2009/02/19/silent-change-in-urls-of-ruby-on-rails-svn-repository#comments</comments>
		<pubDate>Thu, 19 Feb 2009 13:41:11 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=413</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
I don&#8217;t know why, but everything associated with Ruby on Rails seems to change all the time, without notice, or (in the case of URLs) without redirect.
</p>

<p>
We used <tt>http://svn.rubyonrails.org/</tt>rails for our <tt>svn:external</tt> deployment of rails 1.2.6. But that suddenly stopped working. The Ruby on Rails weblog doesn&#8217;t contain any information on it (that I can find), going to <tt>svn.rubyonrails.org</tt> with my web browser yielded just the front page of the weblog and Googling didn&#8217;t help much. That is, until I accidentally found <tt>http://dev.rubyonrails.org/svn/rails</tt>.
</p>

<p>
So, I changed the <tt>svn:externals</tt> from &#8220;<tt>rails http://svn.rubyonrails.org/rails/tags/rel_1-2-6/</tt>&#8221; to &#8220;<tt>rails http://dev.rubyonrails.org/svn/rails/tags/rel_1-2-6/</tt>&#8221; and now it works again.
</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2009/02/19/silent-change-in-urls-of-ruby-on-rails-svn-repository/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress feed pagination</title>
		<link>http://blog.bigsmoke.us/2009/02/16/wordpress-feed-pagination</link>
		<comments>http://blog.bigsmoke.us/2009/02/16/wordpress-feed-pagination#comments</comments>
		<pubDate>Mon, 16 Feb 2009 21:52:37 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=399</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Wiebe uses his <a href="/author/halfgaar/feed/atom">author Atom feed</a> to generate a list of his blog posts here <a href="http://www.halfgaar.net/articles">on his own website</a>. WordPress feeds only display the latest 10 entries. He has written 16 so far. What he needs is a feed with <strong>all</strong> his entries.</p>

<p>First, I tried if pagination works for feeds. Appending &#8220;<tt>/page/2</tt>&#8221; (as is used an non-feed lists) to a feed URL gives a 404 so I was kind of stuck there. Four days ago, after Googling for some time, unable to find a solution anywhere, I <a href="http://wordpress.org/support/topic/242847">asked</a> on the forum. Still no answer today so I tried to find out which parameters WordPress accepts in the <tt>QUERY_STRING</tt>. The WordPress Codex does explain <a href="http://codex.wordpress.org/Query_Overview">how queries are handled</a> but not which parameters are accepted.</p>

<p>Digging into <tt>wp-includes/query.php</tt>, with much trial and error, I found out that I can append <q><tt>?paged=2</tt></q> to the URL to get the next page. At least I got that sorted then. There are a number of much more promising parameters supported by <tt>get_posts()</tt>, but these don&#8217;t seem to be parsed by <tt>parse_query()</tt>. Next time, I&#8217;d like to find out how how to use two of these: <tt>nopaging</tt> and <tt>posts_per_page</tt>.</p>

<p>Wiebe could complete his list by merging together all the pages of the feed, but I&#8217;d much prefer to find a relatively painless method to produce a feed with an unlimited number of posts.</p>

<h2>Notes</h2>

<ul>
<li>http://codex.wordpress.org/Query_Overview</li>
<li>http://codex.wordpress.org/Function_Reference/WP_Query</li>
<li>http://codex.wordpress.org/Template_Tags/query_posts</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2009/02/16/wordpress-feed-pagination/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Allowing dots in WordPress post slugs</title>
		<link>http://blog.bigsmoke.us/2007/05/30/dots-in-wordpress-post-slugs</link>
		<comments>http://blog.bigsmoke.us/2007/05/30/dots-in-wordpress-post-slugs#comments</comments>
		<pubDate>Tue, 29 May 2007 23:42:10 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[BigSmoke.US]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/2007/05/30/dots-in-wordpress-post-slugs</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I was once again annoyed by the fact that WordPress doesn&#8217;t allow dots in post slugs. Luckily, this time I hadn&#8217;t published the post with a botched URL yet. (I don&#8217;t like changing permalinks because they&#8217;re meant to be permanent; <a href="http://www.w3.org/Provider/Style/URI">cool URLs don&#8217;t change</a>.) A quick <a href="http://www.google.com/search?q=wordpress+dots+in+slugs">googling</a> pointed me to a <a href="http://wordpress.org/support/topic/91025">post</a> in the WordPress support forum with a reference to the <a href="http://txfx.net/code/wordpress/periods-in-titles/">Periods in Titles WordPress plugin</a>.</p>

<p>The plugin works great and allowed me to post <a href="/2007/05/30/jeroen-dekker.com">http:///2007/05/30/jeroen-dekker.com</a> with dots and without problems.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2007/05/30/dots-in-wordpress-post-slugs/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nested hashes derail Rails&#8217; url_for helpers</title>
		<link>http://blog.bigsmoke.us/2007/02/19/nested-hashes-derail-rails-url-helpers</link>
		<comments>http://blog.bigsmoke.us/2007/02/19/nested-hashes-derail-rails-url-helpers#comments</comments>
		<pubDate>Mon, 19 Feb 2007 18:42:47 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[link_to]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[url_for]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/2007/02/19/nested-hashes-url-helpers-on-rails</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>While working on the Sicirec PostgreSQL database front-end today, I had to pass a lot of nested parameters to a <tt><a href="http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M000485">link_to</a></tt> helper in Rails. Software being what it is, this didn&#8217;t work.</p>

<p>There are a few patches awaiting acceptance. The <a href="http://dev.rubyonrails.org/ticket/4947">most promising</a> of these patches was part of an open Trac ticket. Because we use Rails as an svn external, applying the patch myself wouldn&#8217;t work when deploying unless I&#8217;d create a vendor branch for Rails in our own repository. Hoping that someone had forgotten to close the ticket, I first tried to upgrade to Rails 1.2.2, which was about time anyway because we were still in the 1.1 branch. The upgrade went fine but didn&#8217;t fix the problem.</p>

<p>Next, I tried to integrate the patch by redefining the methods changed by the patch in our <tt>lib/</tt> directory. When this didn&#8217;t work, I decided to simply do some flattening of the hash myself for this one particular case.</p>

<p>A bit of <a href="http://www.google.com/search?q=url_for+nested+hashes">googling around</a> gave me <a href="http://www.ruby-forum.com/topic/72705">many</a> <a href="http://www.railsweenie.com/forums/1/topics/131">clues</a> <a href="http://blog.bigsmoke.us/wp-admin/post.php?action=edit&#038;post=13">that</a> the problem has cost a lot of people lots of time already.</p>

<p>Eventually, I settled with a derivate of <a href="http://marklunds.com/articles/one/314">some code</a> by <a href="http://marklunds.com/">Peter Marklund</a> to flatten my hashes:

<pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Hash
  <span style="color:#008000; font-style:italic;"># Flatten a hash into a flat form suitable for an URL.</span>
  <span style="color:#008000; font-style:italic;"># Accepts as an optional parameter an array of names that pretend to be the ancestor key names.</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># Example 1:</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;">#   { 'animals' =&gt; {</span>
  <span style="color:#008000; font-style:italic;">#       'fish' =&gt; { 'legs' =&gt; 0, 'sound' =&gt; 'Blub' }</span>
  <span style="color:#008000; font-style:italic;">#       'cat' =&gt; { 'legs' =&gt; 4, 'sound' =&gt; 'Miaow' }</span>
  <span style="color:#008000; font-style:italic;">#   }.flatten_for_url</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;">#   # =&gt; { 'animals[fish][legs]'  =&gt; 0,</span>
  <span style="color:#008000; font-style:italic;">#          'animals[fish][sound]' =&gt; 'Blub',</span>
  <span style="color:#008000; font-style:italic;">#          'animals[cat][legs]'   =&gt; 4,</span>
  <span style="color:#008000; font-style:italic;">#          'animals[cat][sound]'  =&gt; 'Miaow'</span>
  <span style="color:#008000; font-style:italic;">#        }</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># Example 2:</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;">#   {'color' =&gt; 'blue'}.flatten_for_url( %w(world things) )  # =&gt; {'world[things][color]' =&gt; 'blue'}</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> flatten_for_url<span style="color:#006600; font-weight:bold;">&#40;</span>ancestor_names = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flat_hash = Hash.<span style="color:#9900CC;">new</span>
&nbsp;
    each <span style="color:#9966CC; font-weight:bold;">do</span> |key, value|
      names = <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>ancestor_names<span style="color:#006600; font-weight:bold;">&#41;</span>
      names &lt;&lt; key
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">if</span> value.<span style="color:#9900CC;">is_a</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>Hash<span style="color:#006600; font-weight:bold;">&#41;</span>
        flat_hash.<span style="color:#9900CC;">merge</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>value.<span style="color:#9900CC;">flatten_for_url</span><span style="color:#006600; font-weight:bold;">&#40;</span>names<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        flat_key = names.<span style="color:#9900CC;">shift</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">dup</span>
        names.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |name|
          flat_key &lt;&lt; <span style="color:#996600;">&quot;[#{name}]&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
        flat_key &lt;&lt; <span style="color:#996600;">&quot;[]&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> value.<span style="color:#9900CC;">is_a</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">Array</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        flat_hash<span style="color:#006600; font-weight:bold;">&#91;</span>flat_key<span style="color:#006600; font-weight:bold;">&#93;</span> = value
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    flat_hash
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>

<p>As you can see, I turned my code into a single method of the <tt>Hash</tt> class. It can be used simply in any <tt>url_for</tt> (based) call as in the following example:</p>

<pre class="ruby">url_for <span style="color:#006600; font-weight:bold;">&#123;</span>
    :controller =&gt; 'post',
    :action =&gt; 'new',
    'author' =&gt; <span style="color:#006600; font-weight:bold;">&#123;</span>'name' =&gt; 'Rowan', 'gender' =&gt; 'm'<span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">flatten_for_url</span>
  <span style="color:#008000; font-style:italic;"># =&gt; /post/new?author[name]=Rowan&amp;author[gender]=m </span></pre>

<p>Now if only some Rails developer would commit <a href="http://dev.rubyonrails.org/ticket/4947">the patch</a> already.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2007/02/19/nested-hashes-derail-rails-url-helpers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

