Futzing around with Ruby, other languages, and further occasional idiosyncrasies.

Friday, September 25, 2009

begin

Why? because some of my colleagues believe code they find on blogs more than the some of the stuff I write, so the solution: publish my own blog. But seriously, also to give some back for the myriad times I've gotten unstuck thanks to some helpful blogger.

Some logistics: I'll expect to be having source code, so some easy way to publish code is needed. I found this: SyntaxHighlighter. Does it work?
class DoesItWork
  def yay!
  end
end

The documentation is a bit unclear, but to get it working using the author's hosted css and js files, you add this to the bottom of the page:
<link href='http://alexgorbatchev.com/pub/sh/2.0.320/styles/shCore.css' rel='stylesheet' type='text/css'>
<link href='http://alexgorbatchev.com/pub/sh/2.0.320/styles/shThemeDefault.css' rel='stylesheet' type='text/css'>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shCore.js'>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushRuby.js'>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJScript.js'>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushXml.js'>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.defaults.gutter = false;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>

I added this to the bottom of the Blogger template, and then simply surrounded the code with
<pre name="code" class="brush:ruby">
class DoesItWork
  def yay!
  end
end
</pre>

The .swf (Adobe/Macromedia Shockwave) is to enable the neat clipboard functionality.

0 comments:

Post a Comment