<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>Death of a Gremmie</title>
    <link>http://deathofagremmie.com</link>
    <description>Brian Neal's blog about programming.</description>
    <pubDate>Sat, 21 Jan 2012 05:35:56 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Blogofile, reStructuredText, and Pygments</title>
      <link>http://deathofagremmie.com/2011/04/17/blogofile-restructuredtext-and-pygments</link>
      <pubDate>Sun, 17 Apr 2011 19:15:00 CDT</pubDate>
      <category><![CDATA[Pygments]]></category>
      <category><![CDATA[Blogofile]]></category>
      <category><![CDATA[reStructuredText]]></category>
      <guid isPermaLink="true">http://deathofagremmie.com/2011/04/17/blogofile-restructuredtext-and-pygments</guid>
      <description>Blogofile, reStructuredText, and Pygments</description>
      <content:encoded><![CDATA[<div class="document">
<p><a class="reference external" href="http://blogofile.com">Blogofile</a> has support out-of-the-box for <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> and <a class="reference external" href="http://pygments.org/">Pygments</a>. Blogofile's
<tt class="docutils literal">syntax_highlight.py</tt> filter wants you to mark your code blocks with a token such as
<tt class="docutils literal">$$code(lang=python)</tt>. I wanted to use the method I am more familiar with, by configuring
reStructuredText with a <a class="reference external" href="http://pygments.org/docs/rstdirective/">custom directive</a>. Luckily this is very easy. Here is how I did it.</p>
<p>First of all, I checked what version of Pygments I had since I used Ubuntu's package
manager to install it. I then visited <a class="reference external" href="https://bitbucket.org/birkenfeld/pygments-main">Pygments on BitBucket</a>, and switched to the tag that matched
my version. I then drilled into the <tt class="docutils literal">external</tt> directory. I then saved the <tt class="docutils literal"><span class="pre">rst-directive.py</span></tt>
file to my blog's local repository under the name <tt class="docutils literal">_rst_directive.py</tt>. I named it with a leading
underscore so that Blogofile would ignore it. If this bothers you, you could also add it to
Blogofile's <tt class="docutils literal">site.file_ignore_patterns</tt> setting.</p>
<p>Next, I tweaked the settings in <tt class="docutils literal">_rst_directive.py</tt> by un-commenting the <tt class="docutils literal">linenos</tt> variant.</p>
<p>All we have to do now is to get Blogofile to import this module. This can be accomplished by making
use of the <a class="reference external" href="http://blogofile.com/documentation/config_file.html#pre-build">pre_build() hook</a> in your <tt class="docutils literal">_config.py</tt> file. This is a convenient place to hang
custom code that will run before your blog is built. I added the following code to my
<tt class="docutils literal">_config.py</tt> module</p>
<div class="highlight"><pre><span class="k">def</span> <span class="nf">pre_build</span><span class="p">():</span>
    <span class="c"># Register the Pygments Docutils directive</span>
    <span class="kn">import</span> <span class="nn">_rst_directive</span>
</pre></div>
<p>This allows me to embed code in my <tt class="docutils literal">.rst</tt> files with the <tt class="docutils literal">sourcecode</tt> directive. For example,
here is what I typed to create the source code snippet above:</p>
<pre class="literal-block">
.. sourcecode:: python

   def pre_build():
       # Register the Pygments Docutils directive
       import _rst_directive
</pre>
<p>Of course to get it to look nice, we'll need some CSS. I used this Pygments command to generate
a <tt class="docutils literal">.css</tt> file for the blog.</p>
<div class="highlight"><pre><span class="nv">$ </span>pygmentize -f html -S monokai -a .highlight &gt; pygments.css
</pre></div>
<p>I saved <tt class="docutils literal">pygments.css</tt> in my <tt class="docutils literal">css</tt> directory and updated my site template to link it in.
Blogofile will copy this file into my <tt class="docutils literal">_site</tt> directory when I build the blog.</p>
<p>Here is what I added to my blog's main <tt class="docutils literal">.css</tt> file to style the code snippets. The important thing
for me was to add an <tt class="docutils literal">overflow: auto;</tt> setting. This will ensure that a scrollbar will
appear on long lines instead of the code being truncated.</p>
<div class="highlight"><pre><span class="nc">.highlight</span> <span class="p">{</span>
   <span class="k">width</span><span class="o">:</span> <span class="m">96%</span><span class="p">;</span>
   <span class="k">padding</span><span class="o">:</span> <span class="m">0.5em</span> <span class="m">0.5em</span><span class="p">;</span>
   <span class="k">border</span><span class="o">:</span> <span class="m">1px</span> <span class="k">solid</span> <span class="m">#00ff00</span><span class="p">;</span>
   <span class="k">margin</span><span class="o">:</span> <span class="m">1.0em</span> <span class="k">auto</span><span class="p">;</span>
   <span class="k">overflow</span><span class="o">:</span> <span class="k">auto</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>That's it!</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Blog reboot with Blogofile</title>
      <link>http://deathofagremmie.com/2011/04/17/blog-reboot-with-blogofile</link>
      <pubDate>Sun, 17 Apr 2011 14:10:00 CDT</pubDate>
      <category><![CDATA[Blogofile]]></category>
      <category><![CDATA[Blogging]]></category>
      <guid isPermaLink="true">http://deathofagremmie.com/2011/04/17/blog-reboot-with-blogofile</guid>
      <description>Blog reboot with Blogofile</description>
      <content:encoded><![CDATA[<div class="document">
<p>Welcome to my new blog. I've been meaning to start blogging again for some time, especially since
the new version of <a class="reference external" href="http://surfguitar101.com">SurfGuitar101.com</a> went live almost two months ago. But the idea of dealing with
WordPress was putting me off. Don't get me wrong, WordPress really is a nice general purpose
blogging platform, but it didn't really suit me anymore.</p>
<p>I considered creating a new blog in <a class="reference external" href="http://djangoproject.com">Django</a>, but I really want to spend all my time and energy on
improving SurfGuitar101 and not tweaking my blog. I started thinking about doing something
simpler.</p>
<p>Almost by accident, I discovered <a class="reference external" href="http://blogofile.com">Blogofile</a> by seeing it mentioned in my Twitter feed. Blogofile is
a static blog generator written in Python. After playing with it for a while, I decided to use it
for a blog reboot. It is simple to use, Pythonic, and very configurable. The advantages for me to go
with a static blog are:</p>
<ol class="arabic simple">
<li>No more dealing with WordPress and plugin updates. To be fair, WordPress is very easy to update
these days. Plugins are still a pain, and are often needed to display source code.</li>
<li>I can write my blog posts in <a class="reference external" href="http://daringfireball.net/projects/markdown/">Markdown</a> or <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> using my <a class="reference external" href="http://www.vim.org">favorite editor</a> instead
of some lame Javascript editor. Formatting source code is dead simple now.</li>
<li>All of my blog content is under version control.</li>
<li>Easier to work offline.</li>
<li>Easier to deploy. Very little (if any) server configuration.</li>
<li>I can use version control with a post-commit hook to deploy the site.</li>
</ol>
<p>Disadvantages:</p>
<ol class="arabic simple">
<li>Not as &quot;dynamic&quot;. For my blog, this isn't really a problem. Comments can be handled by a service
like <a class="reference external" href="http://disqus.com/">Disqus</a>.</li>
<li>Regenerating the entire site can take time. This is only an issue if you have a huge blog with
years of content. A fresh blog takes a fraction of a second to build, and I don't anticipate
this affecting me for some time, if ever. I suspect Blogofile will be improved to include caching
and smarter rebuilds in the future.</li>
</ol>
<p>It should be noted that Blogofile seems to require Python 2.6 or later. My production server is
still running 2.5, and I can't easily change this for a while. This really only means I can't use
Mercurial with a <em>changegroup</em> hook to automatically deploy the site. This should only be a temporary
issue; I hope to upgrade the server in the future.</p>
<p>Blogofile comes with some scripts for importing WordPress blogs. Looking over my old posts, some of
them make me cringe. I think I'll save importing them for a rainy day.</p>
<p>The bottom line is, this style of blogging suits me as a programmer. I get to use all the same
tools I use to write code: a good text editor, the same markup I use for documentation, and version
control. Deployment is a snap, and I don't have a database or complicated server setup to maintain.
Hopefully this means I will blog more.</p>
<p>Finally, I'd like to give a shout-out to my friend <a class="reference external" href="http://trevoroke.com/2011/04/12/converting-to-jekyll.html">Trevor Oke</a> who just switched to a static blog
for many of the same reasons.</p>
</div>
]]></content:encoded>
    </item>
  </channel>
</rss>

