<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <id>tag:styledbits.com,2005:/articles</id>
  <link type="text/html" href="http://styledbits.com" rel="alternate" />
  
  <title>Styled Bits</title>
  <updated>2009-06-17T22:00:00Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/StyledBits" type="application/atom+xml" /><feedburner:emailServiceId>StyledBits</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
    <id>tag:styledbits.com,2005:Article/5</id>
    <published>2009-06-17T10:02:27Z</published>
    <updated>2009-06-18T01:40:06Z</updated>
    <link type="text/html" href="http://feedproxy.google.com/~r/StyledBits/~3/-jGNZAxSqfM/5" rel="alternate" />
    <title>Using Rails to Redirect Your Users to FeedBurner</title>
    <content type="html">&lt;p&gt;Previously, we built an &lt;a href="/articles/3"&gt;Atom feed generator&lt;/a&gt; for our little pet Rails project, &lt;a href="/project/1"&gt;TextMill&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, having signed up for a movable FeedBurner feed, we&amp;#8217;d like to redirect all users there so that we might change our underlying engine and feed out on a whim in the future.&lt;/p&gt;
&lt;p&gt;Our goals are clear:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;if a request for &amp;#8216;/articles.atom&amp;#8217; or &amp;#8216;/projects.atom&amp;#8217; comes from FeedBurner, serve up the appropriate Atom feed&lt;/li&gt;
	&lt;li&gt;if the request originates from anyone else, send a permanent redirect to the appropriate FeedBurner feed&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Implementation is even easier.  After watching the logs, I discovered that all requests from FeedBurner have the User-Agent header set to &amp;#8220;FeedBurner/1.0 (http://www.FeedBurner.com)&amp;#8221;.  Our Rails controllers have the ability to inspect the &amp;#8216;User-Agent&amp;#8217; header by examining the &amp;#8216;request.headers&amp;#8217; hash.&lt;/p&gt;
&lt;p&gt;To glue this all together, I just opened up &amp;#8216;app/controllers/articles_controller.rb&amp;#8217; and modified the index action to read like so (note lines 7-11):&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;def&lt;/span&gt; &lt;span style="color:#06B;font-weight:bold"&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;   &lt;span style="color:#33B"&gt;@articles&lt;/span&gt; = &lt;span style="color:#036;font-weight:bold"&gt;Article&lt;/span&gt;.all(&lt;span style="color:#A60"&gt;:conditions&lt;/span&gt; =&amp;gt; [&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;published = ?&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span style="color:#038;font-weight:bold"&gt;true&lt;/span&gt;], &lt;span style="color:#A60"&gt;:order&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;published_at DESC&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    respond_to &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;      format.html &lt;span style="color:#888"&gt;# index.html.erb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      format.xml  { render &lt;span style="color:#A60"&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span style="color:#33B"&gt;@articles&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;      format.atom &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span style="color:#080;font-weight:bold"&gt;if&lt;/span&gt; !request.headers[&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;User-Agent&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;].match(&lt;span style="background-color:#fff0ff"&gt;&lt;span style="color:#404"&gt;/&lt;/span&gt;&lt;span style="color:#808"&gt;FeedBurner&lt;/span&gt;&lt;span style="color:#404"&gt;/&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;          redirect_to &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;http://feeds2.feedburner.com/StyledBits&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:status&lt;/span&gt;=&amp;gt;&lt;span style="color:#A60"&gt;:moved_permanently&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As you can see, we do a simple regexp match against the User-Agent header to see if it contains the phrase &amp;#8216;FeedBurner&amp;#8217;.  If so, give them the raw atom feed.  Otherwise, give them a permanent redirect over to our FeedBurner url.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/StyledBits/~4/-jGNZAxSqfM" height="1" width="1"/&gt;</content>
    <author>
      <name>Michael Gorsuch</name>
    </author>
  <feedburner:origLink>http://styledbits.com/articles/5</feedburner:origLink></entry>
  <entry>
    <id>tag:styledbits.com,2005:Article/4</id>
    <published>2009-06-17T10:00:49Z</published>
    <updated>2009-06-17T10:15:02Z</updated>
    <link type="text/html" href="http://feedproxy.google.com/~r/StyledBits/~3/GRSmOlF-vcc/4" rel="alternate" />
    <title>Adding Syntax Highlighting to Your Rails App</title>
    <content type="html">&lt;p&gt;Wanting to spice things up when rendering code in my articles, I decided to implement syntax highlighting.&lt;/p&gt;
&lt;p&gt;Since I already take advantage of RedCloth for rendering textile, augustl&amp;#8217;s &lt;a href="http://github.com/augustl/redcloth-with-coderay/tree/master"&gt;redcloth-with-coderay&lt;/a&gt; gem looked like a great choice.&lt;/p&gt;
&lt;p&gt;Installation was nothing more than:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;sudo gem install redclothcoderay&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Once that completed, I modified &amp;#8216;config/environment.rb&amp;#8217; in my rails application to load up the appropriate gems:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;require &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;redcloth&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;coderay&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;redclothcoderay&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I altered my article erb &amp;#8216;show&amp;#8217; template to read:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&amp;lt;%&lt;span style="color:#036;font-weight:bold"&gt;RedclothCoderay&lt;/span&gt;.coderay_options &lt;span style="color:#A60"&gt;:line_numbers&lt;/span&gt; =&amp;gt; &lt;span style="color:#A60"&gt;:table&lt;/span&gt;%&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;%=&lt;/span&gt;&lt;span style=""&gt;textilize @article.body%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Finally, I had to add the following to my stylesheet to allow things to look pretty:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;25&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;35&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;45&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;47&lt;tt&gt;
&lt;/tt&gt;48&lt;tt&gt;
&lt;/tt&gt;49&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;50&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;51&lt;tt&gt;
&lt;/tt&gt;52&lt;tt&gt;
&lt;/tt&gt;53&lt;tt&gt;
&lt;/tt&gt;54&lt;tt&gt;
&lt;/tt&gt;55&lt;tt&gt;
&lt;/tt&gt;56&lt;tt&gt;
&lt;/tt&gt;57&lt;tt&gt;
&lt;/tt&gt;58&lt;tt&gt;
&lt;/tt&gt;59&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;60&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;61&lt;tt&gt;
&lt;/tt&gt;62&lt;tt&gt;
&lt;/tt&gt;63&lt;tt&gt;
&lt;/tt&gt;64&lt;tt&gt;
&lt;/tt&gt;65&lt;tt&gt;
&lt;/tt&gt;66&lt;tt&gt;
&lt;/tt&gt;67&lt;tt&gt;
&lt;/tt&gt;68&lt;tt&gt;
&lt;/tt&gt;69&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;70&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;71&lt;tt&gt;
&lt;/tt&gt;72&lt;tt&gt;
&lt;/tt&gt;73&lt;tt&gt;
&lt;/tt&gt;74&lt;tt&gt;
&lt;/tt&gt;75&lt;tt&gt;
&lt;/tt&gt;76&lt;tt&gt;
&lt;/tt&gt;77&lt;tt&gt;
&lt;/tt&gt;78&lt;tt&gt;
&lt;/tt&gt;79&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;80&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;81&lt;tt&gt;
&lt;/tt&gt;82&lt;tt&gt;
&lt;/tt&gt;83&lt;tt&gt;
&lt;/tt&gt;84&lt;tt&gt;
&lt;/tt&gt;85&lt;tt&gt;
&lt;/tt&gt;86&lt;tt&gt;
&lt;/tt&gt;87&lt;tt&gt;
&lt;/tt&gt;88&lt;tt&gt;
&lt;/tt&gt;89&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;90&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;91&lt;tt&gt;
&lt;/tt&gt;92&lt;tt&gt;
&lt;/tt&gt;93&lt;tt&gt;
&lt;/tt&gt;94&lt;tt&gt;
&lt;/tt&gt;95&lt;tt&gt;
&lt;/tt&gt;96&lt;tt&gt;
&lt;/tt&gt;97&lt;tt&gt;
&lt;/tt&gt;98&lt;tt&gt;
&lt;/tt&gt;99&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;100&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;101&lt;tt&gt;
&lt;/tt&gt;102&lt;tt&gt;
&lt;/tt&gt;103&lt;tt&gt;
&lt;/tt&gt;104&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;background-color&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#f8f8f8&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;border&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;1px&lt;/span&gt; &lt;span style="color:#088"&gt;solid&lt;/span&gt; &lt;span style="color:#088"&gt;silver&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;font-family&lt;/span&gt;: &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;Courier New&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;Terminal&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#088"&gt;monospace&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;color&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#100&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#080;font-weight:bold"&gt;pre&lt;/span&gt; { &lt;span style="color:#808"&gt;margin&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;0px&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;div&lt;/span&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; { }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;span&lt;/span&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; { &lt;span style="color:#808"&gt;white-space&lt;/span&gt;: &lt;span style="color:#088"&gt;pre&lt;/span&gt;; &lt;span style="color:#808"&gt;border&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;0px&lt;/span&gt;; &lt;span style="color:#808"&gt;padding&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;2px&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;table&lt;/span&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; { &lt;span style="color:#808"&gt;border-collapse&lt;/span&gt;: &lt;span style="color:#088"&gt;collapse&lt;/span&gt;; &lt;span style="color:#808"&gt;width&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;100%&lt;/span&gt;; &lt;span style="color:#808"&gt;padding&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;2px&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;table&lt;/span&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#080;font-weight:bold"&gt;td&lt;/span&gt; { &lt;span style="color:#808"&gt;padding&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;2px&lt;/span&gt; &lt;span style="color:#60E;font-weight:bold"&gt;4px&lt;/span&gt;; &lt;span style="color:#808"&gt;vertical-align&lt;/span&gt;: &lt;span style="color:#088"&gt;top&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.line_numbers&lt;/span&gt;, &lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.no&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;background-color&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#def&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;color&lt;/span&gt;: &lt;span style="color:#088"&gt;gray&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#808"&gt;text-align&lt;/span&gt;: &lt;span style="color:#088"&gt;right&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.line_numbers&lt;/span&gt; &lt;span style="color:#080;font-weight:bold"&gt;tt&lt;/span&gt; { &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;: &lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.no&lt;/span&gt; { &lt;span style="color:#808"&gt;padding&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;0px&lt;/span&gt; &lt;span style="color:#60E;font-weight:bold"&gt;4px&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.code&lt;/span&gt; { &lt;span style="color:#808"&gt;width&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;100%&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;ol&lt;/span&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; { &lt;span style="color:#808"&gt;font-size&lt;/span&gt;: &lt;span style="color:#60E;font-weight:bold"&gt;10pt&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;ol&lt;/span&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#080;font-weight:bold"&gt;li&lt;/span&gt; { &lt;span style="color:#808"&gt;white-space&lt;/span&gt;: &lt;span style="color:#088"&gt;pre&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.code&lt;/span&gt; &lt;span style="color:#080;font-weight:bold"&gt;pre&lt;/span&gt; { &lt;span style="color:#808"&gt;overflow&lt;/span&gt;: &lt;span style="color:#088"&gt;auto&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.af&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#00C&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.an&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#007&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.av&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#700&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.aw&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#C00&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.bi&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#509&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.c&lt;/span&gt;  { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#888&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ch&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#04D&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ch&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.k&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#04D&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ch&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#039&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.cl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#B06&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.co&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#036&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.cr&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#0A0&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.cv&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#369&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.df&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#099&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.di&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#088&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#088"&gt;black&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.do&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#970&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ds&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#D42&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.e&lt;/span&gt;  { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#666&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.en&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#800&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.er&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#F00&lt;/span&gt;; &lt;span style="color:#808"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#FAA&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ex&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#F00&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.fl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#60E&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.fu&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#06B&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.gv&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#d70&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.hx&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#058&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.i&lt;/span&gt;  { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#00D&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ic&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#B44&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; { &lt;span style="color:#808"&gt;background&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#eee&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; { &lt;span style="color:#808"&gt;background&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#ddd&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; { &lt;span style="color:#808"&gt;background&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#ccc&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.il&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;: &lt;span style="color:#088"&gt;bold&lt;/span&gt; &lt;span style="color:#f00"&gt;! important&lt;/span&gt;; &lt;span style="color:#808"&gt;color&lt;/span&gt;: &lt;span style="color:#0A0"&gt;#888&lt;/span&gt; &lt;span style="color:#f00"&gt;! important&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.in&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#B2B&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.iv&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#33B&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.la&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#970&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.lv&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#963&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.oc&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#40E&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.on&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#000&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.op&lt;/span&gt; { }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.pc&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#038&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.pd&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#369&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.pp&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#579&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.pt&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#339&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.r&lt;/span&gt;  { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#080&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.rx&lt;/span&gt; { &lt;span style="color:#808"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#fff0ff&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.rx&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.k&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#808&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.rx&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#404&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.rx&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.mod&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#C2C&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.rx&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.fu&lt;/span&gt;  { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#404&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;: &lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt;  { &lt;span style="color:#808"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#fff0f0&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt;  &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt; { &lt;span style="color:#808"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#ffe0e0&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt;  &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt;  &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt; { &lt;span style="color:#808"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#ffd0d0&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt;  &lt;span style="color:#B06;font-weight:bold"&gt;.k&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#D20&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.s&lt;/span&gt;  &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#710&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.sh&lt;/span&gt; { &lt;span style="color:#808"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#f0fff0&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.sh&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.k&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#2B2&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.sh&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#161&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.sy&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#A60&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.sy&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.k&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#A60&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.sy&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.dl&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#630&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ta&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#070&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.tf&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#070&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ts&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#D70&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.ty&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#339&lt;/span&gt;; &lt;span style="color:#808"&gt;font-weight&lt;/span&gt;:&lt;span style="color:#088"&gt;bold&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.v&lt;/span&gt;  { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#036&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#B06;font-weight:bold"&gt;.CodeRay&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;.xt&lt;/span&gt; { &lt;span style="color:#808"&gt;color&lt;/span&gt;:&lt;span style="color:#0A0"&gt;#444&lt;/span&gt; }&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;All in all, a very, very quick implementation that didn&amp;#8217;t even require me to do any regular expression work of my own!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/StyledBits/~4/GRSmOlF-vcc" height="1" width="1"/&gt;</content>
    <author>
      <name>Michael Gorsuch</name>
    </author>
  <feedburner:origLink>http://styledbits.com/articles/4</feedburner:origLink></entry>
  <entry>
    <id>tag:styledbits.com,2005:Article/3</id>
    <published>2009-06-17T02:15:42Z</published>
    <updated>2009-06-17T22:26:21Z</updated>
    <link type="text/html" href="http://feedproxy.google.com/~r/StyledBits/~3/HKlIJgQQLXg/3" rel="alternate" />
    <title>Easy Atom Feeds for Rails</title>
    <content type="html">&lt;p&gt;To get these articles out to the public, I needed to make sure that &lt;a href="/projects/1"&gt;TextMill&lt;/a&gt; could spout out Atom so others can syndicate my content.  As usual, Ruby on Rails made it too easy.&lt;/p&gt;
&lt;h3&gt;Accept the Format&lt;/h3&gt;
&lt;p&gt;Keeping with the RESTful model, I decided that articles would be syndicated by using a &lt;span class="caps"&gt;URL&lt;/span&gt; like &amp;#8216;/articles.atom&amp;#8217;.  In order to activate this, I just had to change this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;def&lt;/span&gt; &lt;span style="color:#06B;font-weight:bold"&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#33B"&gt;@articles&lt;/span&gt; = &lt;span style="color:#036;font-weight:bold"&gt;Article&lt;/span&gt;.all(&lt;span style="color:#A60"&gt;:conditions&lt;/span&gt; =&amp;gt; [&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;published = ?&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span style="color:#038;font-weight:bold"&gt;true&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    respond_to &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;      format.html &lt;span style="color:#888"&gt;# index.html.erb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      format.xml  { render &lt;span style="color:#A60"&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span style="color:#33B"&gt;@articles&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to look like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;def&lt;/span&gt; &lt;span style="color:#06B;font-weight:bold"&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#33B"&gt;@articles&lt;/span&gt; = &lt;span style="color:#036;font-weight:bold"&gt;Article&lt;/span&gt;.all(&lt;span style="color:#A60"&gt;:conditions&lt;/span&gt; =&amp;gt; [&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;published = ?&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span style="color:#038;font-weight:bold"&gt;true&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  respond_to &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;    format.html &lt;span style="color:#888"&gt;#index.html.erb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    format.xml { render &lt;span style="color:#A60"&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span style="color:#33B"&gt;@articles&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;    format.atom&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Pretty sweet, eh?&lt;/p&gt;
&lt;h3&gt;The Template&lt;/h3&gt;
&lt;p&gt;When &amp;#8216;/articles.atom&amp;#8217; is called, a &lt;a href="http://builder.rubyforge.org/"&gt;Builder&lt;/a&gt; template will be loaded to describe the feed&amp;#8217;s structure.  I just created &amp;#8216;app/views/articles/index.atom.builder&amp;#8217; like so:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;atom_feed &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |feed|&lt;tt&gt;
&lt;/tt&gt;  feed.title(&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;Styled Bits&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  feed.updated(&lt;span style="color:#33B"&gt;@articles&lt;/span&gt;.first.published_at)&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#33B"&gt;@articles&lt;/span&gt;.each &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |article|&lt;tt&gt;
&lt;/tt&gt;    feed.entry(article) &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |entry|&lt;tt&gt;
&lt;/tt&gt;      entry.title(article.title)&lt;tt&gt;
&lt;/tt&gt;      entry.content(textilize(article.body), &lt;span style="color:#A60"&gt;:type&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;html&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;      entry.author &lt;span style="color:#080;font-weight:bold"&gt;do&lt;/span&gt; |author|&lt;tt&gt;
&lt;/tt&gt;        author.name(&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;Michael Gorsuch&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;      &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;h3&gt;Auto Discovery&lt;/h3&gt;
&lt;p&gt;In order to enable auto discovery for &lt;span class="caps"&gt;RSS&lt;/span&gt; readers and browsers, the following was added to the default template in the &amp;#8216;&lt;title&gt;&amp;#8217; section:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&amp;lt;&lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;%=&lt;/span&gt;&lt;span style=""&gt; auto_discovery_link_tag(:atom, {:controller &lt;/span&gt;&lt;span style="color:#710"&gt;=&lt;/span&gt;&lt;/span&gt;&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;articles&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:action&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;index&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:format&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;atom&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;})%&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Not too hard, eh?&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/StyledBits/~4/HKlIJgQQLXg" height="1" width="1"/&gt;</content>
    <author>
      <name>Michael Gorsuch</name>
    </author>
  <feedburner:origLink>http://styledbits.com/articles/3</feedburner:origLink></entry>
  <entry>
    <id>tag:styledbits.com,2005:Article/2</id>
    <published>2009-06-16T23:03:21Z</published>
    <updated>2009-06-17T09:56:43Z</updated>
    <link type="text/html" href="http://feedproxy.google.com/~r/StyledBits/~3/vSw0N00oOvI/2" rel="alternate" />
    <title>RESTful Authentication Quick Start</title>
    <content type="html">&lt;p&gt;Since &lt;a href="/"&gt;Styled Bits&lt;/a&gt; isn&amp;#8217;t much more than a simple &lt;a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete"&gt;&lt;span class="caps"&gt;CRUD&lt;/span&gt;&lt;/a&gt; application, I needed to add basic authentication support to &lt;a href="/projects/1"&gt;TextMill&lt;/a&gt;.  The most popular choice for such things is &lt;a href="http://github.com/technoweenie/restful-authentication/tree/master"&gt;technoweenie&amp;#8217;s RESTful Authentication plugin&lt;/a&gt;, but I was unable to find a straight forward tutorial explaining how one puts it to use.  Hence this article.&lt;/p&gt;
&lt;h3&gt;Starting Out&lt;/h3&gt;
&lt;p&gt;For starters, you just want to run the following from the command prompt:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;./script/plugin install git&lt;span style="color:#A60"&gt;:/&lt;/span&gt;/github.com/technoweenie/restful-authentication.git&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This takes care of pulling down the latest version of the plugin and installing the basic generator.  Generators extend the abilities of the &amp;#8216;generate&amp;#8217; script, in this case adding an &amp;#8216;authenticate&amp;#8217; command.&lt;/p&gt;
&lt;p&gt;To generate the code for use within our app, run this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;./script/generate authenticate user sessions&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As you can see from the output, a wide array of files and routes are generated and inserted into your project.  First things first, let us take care of updating our database with the necessary migrations:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;rake db&lt;span style="color:#A60"&gt;:migrate&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;Now that we&amp;#8217;ve got that taken care of, it is time to figure out how to use this puppy.  As far as I&amp;#8217;m concerned at the time of this writing, I want to protect all methods of the Article and Project controllers except for &amp;#8216;show&amp;#8217;.&lt;/p&gt;
&lt;p&gt;If we browse to &amp;#8216;lib/authenticated_system.rb&amp;#8217;, we can see a wide variety of methods available for our use.  For our stated goal, the &amp;#8216;login_required&amp;#8217; seems appropriate.&lt;/p&gt;
&lt;p&gt;To be able to call this from our controllers, we have two choices: AuthenticatedSystem can either be included in each controller, or we can just place the include statement within the Application controller and allow all of the others to inherit it.  In our application, there is no apparent reason not to choose the latter.&lt;/p&gt;
&lt;p&gt;So, let us open up &amp;#8216;app/controllers/application_controller.rb&amp;#8217; and change it from this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;ApplicationController&lt;/span&gt; &amp;lt; &lt;span style="color:#036;font-weight:bold"&gt;ActionController&lt;/span&gt;::&lt;span style="color:#036;font-weight:bold"&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  ...&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;ApplicationController&lt;/span&gt; &amp;lt; &lt;span style="color:#036;font-weight:bold"&gt;ActionController&lt;/span&gt;::&lt;span style="color:#036;font-weight:bold"&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt; include &lt;span style="color:#036;font-weight:bold"&gt;AuthenticatedSystem&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  ...&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Since all of the methods contained with the AuthenticatedSystem module are now available to all of my controllers, we can open up &amp;#8216;app/controllers/articles_controller.rb&amp;#8217; and change it from:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;ArticlesController&lt;/span&gt; &amp;lt; &lt;span style="color:#036;font-weight:bold"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  ...&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;&lt;span style="color:#080;font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06;font-weight:bold"&gt;ArticlesController&lt;/span&gt; &amp;lt; &lt;span style="color:#036;font-weight:bold"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  before_filter &lt;span style="color:#A60"&gt;:login_required&lt;/span&gt;, &lt;span style="color:#A60"&gt;:except&lt;/span&gt; =&amp;gt; &lt;span style="color:#A60"&gt;:show&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  ...&lt;tt&gt;
&lt;/tt&gt;&lt;span style="color:#080;font-weight:bold"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The same procedure can be performed on &amp;#8216;app/controllers/projects_controller.rb&amp;#8217;.&lt;/p&gt;
&lt;h3&gt;Almost There&lt;/h3&gt;
&lt;p&gt;Once all of this is in place, it seems that the proper thing to do is prohibit anonymous user signups.&lt;/p&gt;
&lt;p&gt;All we have to do here is comment out or delete the following lines in &amp;#8216;config/routes.rb&amp;#8217;:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;map.register &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;/register&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:controller&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;users&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:action&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;create&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  map.signup &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;/signup&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:controller&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;users&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style="color:#A60"&gt;:action&lt;/span&gt; =&amp;gt; &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Finally, let us add our administrative user that will actually be capable of logging in.  Since we&amp;#8217;ve purged the &amp;#8216;/signup&amp;#8217; route, we&amp;#8217;ll have to go in via the console.  The following code will build your user:&lt;/p&gt;
&lt;pre&gt;&lt;code class="multiline_code"&gt;&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"&gt;user = &lt;span style="color:#036;font-weight:bold"&gt;User&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;user.login = &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;admin&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;user.email = &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;admin@mydomain.com&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;user.password = &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;mypass&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;user.password_confirmation = &lt;span style="background-color:#fff0f0;color:#D20"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style=""&gt;mypass&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;user.save&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Alright!  If we now try and hit up &amp;#8216;/articles/new&amp;#8217;, we&amp;#8217;ll be presented with a login prompt that will accept &amp;#8216;admin&amp;#8217; for the username and &amp;#8216;mypass&amp;#8217; for the password.&lt;/p&gt;
&lt;h3&gt;One Final Note on Security&lt;/h3&gt;
&lt;p&gt;Before committing your new changes to your source control, please make sure that you modify &amp;#8216;config/initializers/site_keys.rb&amp;#8217; and blank out &amp;#8216;REST_AUTH_SITE_KEY&amp;#8217;.  This key is used to generate your encrypted passwords, and if it gets out you are more vulnerable to attack.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/StyledBits/~4/vSw0N00oOvI" height="1" width="1"/&gt;</content>
    <author>
      <name>Michael Gorsuch</name>
    </author>
  <feedburner:origLink>http://styledbits.com/articles/2</feedburner:origLink></entry>
  <entry>
    <id>tag:styledbits.com,2005:Article/1</id>
    <published>2009-06-16T22:19:04Z</published>
    <updated>2009-06-16T22:31:16Z</updated>
    <link type="text/html" href="http://feedproxy.google.com/~r/StyledBits/~3/3zxYXE8WqGw/1" rel="alternate" />
    <title>Refreshed; Source Code Included</title>
    <content type="html">&lt;p&gt;After a lot of thought about what the heck I want to be doing with the little spare time I can find, I made the decision to dust the dandruff off of my site and start over.&lt;/p&gt;
&lt;p&gt;This time around, we&amp;#8217;ll focus only on technical related issues.  Should I want to discuss politics or religion, separate blogs will be spawned.  I was taking a look at my old blog&amp;#8217;s archives, and realized that I was writing a whole lot about nothing.&lt;/p&gt;
&lt;p&gt;Since the blog was originally intended to be personal, you could imagine how it meandered.  When &lt;em&gt;I&lt;/em&gt; write about personal stuff, the juicy stuff never gets put down.  I have a lot of wild ideas, most of which I just don&amp;#8217;t think the general culture is ready for ;-)&lt;/p&gt;
&lt;p&gt;To help maintain the technical focus, I&amp;#8217;ll be releasing the source code that powers this site as well as writing articles to discuss the changes as they happen.  It won&amp;#8217;t be mind blowing, but it&amp;#8217;ll help constrain.&lt;/p&gt;
&lt;p&gt;&lt;a href="/projects/1"&gt;Here ya go&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/StyledBits/~4/3zxYXE8WqGw" height="1" width="1"/&gt;</content>
    <author>
      <name>Michael Gorsuch</name>
    </author>
  <feedburner:origLink>http://styledbits.com/articles/1</feedburner:origLink></entry>
</feed>
