<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Tom Moertel's Weblog: Tag delicous</title>
    <link>http://blog.moertel.com/articles/tag/delicous?tag=delicous</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Quality rants on programming theory and stuff geeks like</description>
    <item>
      <title>Adding reddit and del.icio.us buttons to articles in Typo</title>
      <description>&lt;p&gt;Here&amp;#8217;s quick patch I made to my &lt;a href="http://typosphere.org"&gt;Typo&lt;/a&gt; 4.0
installation to add &lt;a href="http://reddit.com"&gt;Reddit&lt;/a&gt; and
&lt;a href="http://del.icio.us/"&gt;del.icio.us&lt;/a&gt; buttons to articles.  Now one click
is all it takes to submit an article to either site.  (These buttons
appear on my blog at the end of each article.)&lt;/p&gt;


	&lt;p&gt;If you want to apply the patch, be sure to also place copies of the
button images into &lt;code&gt;public/images&lt;/code&gt;.  You can snag the
images from my site or from the Reddit and del.icio.us sites.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s the patch:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;--- typo.orig/app/helpers/articles_helper.rb    2006-07-24 11:04:27.000000000 -0400
+++ typo/app/helpers/articles_helper.rb    2006-08-09 17:06:51.000000000 -0400
@@ -73,7 +74,26 @@
       code &amp;lt;&amp;lt; tag_links(article)        unless article.tags.empty?
       code &amp;lt;&amp;lt; comments_link(article)    if article.allow_comments?
       code &amp;lt;&amp;lt; trackbacks_link(article)  if article.allow_pings?
-    end.join("&amp;amp;nbsp;&amp;lt;strong&amp;gt;|&amp;lt;/strong&amp;gt;&amp;amp;nbsp;")
+      code &amp;lt;&amp;lt; submit_this_article_links(article)
+    end.join("&amp;amp;nbsp;| ")
+  end
+
+  def submit_this_article_links(article)
+    u_url = u(url_of(article, false))
+    u_title = u(article.title)
+    [  # move me into a database table
+      [ "Submit to Reddit.com",
+        "http://reddit.com/submit?url=&amp;lt;URL&amp;gt;&amp;#38;title=&amp;lt;TITLE&amp;gt;",
+        image_tag("reddit.gif", :size =&amp;gt; "18x18", :border =&amp;gt; 0)
+      ],
+      [ "Save to del.icio.us",
+        "http://del.icio.us/post?v=2&amp;#38;url=&amp;lt;URL&amp;gt;&amp;#38;title=&amp;lt;TITLE&amp;gt;",
+        image_tag("delicious.gif", :size =&amp;gt; "16x16", :border =&amp;gt; 0)
+      ]
+    ].map do |submit_title, submit_url, image_tag|
+      submit_url = submit_url.gsub(/&amp;lt;URL&amp;gt;/, u_url).gsub(/&amp;lt;TITLE&amp;gt;/, u_title)
+      %(&amp;lt;a href="#{h submit_url}" title="#{h submit_title}: &amp;amp;#x201C;#{h article.title}&amp;amp;#x201D;"&amp;gt;#{image_tag}&amp;lt;/a&amp;gt;)
+    end.join("&amp;amp;nbsp;")
   end

   def category_links(article)
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The code is begging for a little refactoring love, but I&amp;#8217;m off for vacation
in about twenty minutes, so it will have to wait.&lt;/p&gt;</description>
      <pubDate>Wed, 09 Aug 2006 18:25:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:517cb441-e204-4713-94c5-321917af0d73</guid>
      <author>Tom Moertel</author>
      <link>http://blog.moertel.com/articles/2006/08/09/adding-reddit-and-del-icio-us-buttons-to-articles-in-typo</link>
      <category>site news</category>
      <category>typo</category>
      <category>hacks</category>
      <category>typo</category>
      <category>reddit</category>
      <category>delicous</category>
      <trackback:ping>http://blog.moertel.com/articles/trackback/152</trackback:ping>
    </item>
  </channel>
</rss>
