posted to this is not a weblog
on jul 22nd, 2007

tagged camping, meta, nerd, php, ruby
and commented on twice

share this page

hello. this is my new site. it doesn't look that much different, but it is entirely rewritten in ruby using the tiny camping framework. the ruby code is much easier to work with than the php version and made things like adding the new search and comment functionality take only a few minutes.

though file/line size isn't really a good indicator, here is the old php version versus the new ruby one:

-rw-r--r--  1 jcs  jcs  19943 Jul  8 17:48 global.php
-rw-r--r--  1 jcs  jcs  11128 Jul  8 17:48 index.phtml
-rw-r--r--  1 jcs  jcs   2374 Jun 27 21:38 rss
-rw-r--r--  1 jcs  jcs   9910 Jul 21 13:13 controllers.rb
-rw-r--r--  1 jcs  jcs  14330 Jul 22 19:03 models.rb
-rw-r--r--  1 jcs  jcs  12802 Jul 22 19:03 views.rb

each icon in the upper right is a "feed" and a separate class extended from a basic Feed class which stores data in its sqlite3 table and has simple methods to find recent data, present data in html, search, etc. the Notaweblog class operates on flat files that i used in the php version of the site and responds to the same methods as the Feed class to hide the details from the controllers, which just organize Feed objects by date and show them in an html page or xml rss feed.

nearly all of the html generated on the site is done through markaby, which lets me write ruby in views.rb as well:

xhtml_transitional do
  head do
    title(@pagetitle || @title || "platonic")
    link :rel => "stylesheet", :type => "text/css",
      :href => "#{$B}platonic.css"
    link :rel => "alternate", :type => "application/rss+xml",
      :title => "RSS 2.0",
      :href => "#{$B}rss/#{@only_feed ? @only_feed + '/' : ''}"
    meta :name => "robots", :content => "noarchive,nosnippet"
  end
  body do
   ...
  end
end

after some basic profiling and adding simple cache storage/retrieval of a large hash used to build the calendar in the upper right, most of the site responds quicker or as quick as the php version. when the hash needs to be rebuilt, the main page takes about 1.5 seconds to build.

while i wanted to use mongrel or lighttpd to do the http processing, my site lives on a server with a bunch of others and i share an ip using header-based virtual hosting in apache (which is also chrooted, so no ruby cgi). i installed fastcgi and configured it in apache to communicate to ruby over a socket, which lives inside the chroot. then i start the ruby process outside of the chroot and have it operate on that socket. eventually i will have the ruby process chroot to the site's directory and drop privileges after initialization.

i have an openbsd port of camping made, but there are enough (non-openbsd-specific) problems in the current 1.5 version that i have to patch around that i'd rather wait until a new version comes out to import the port. as well, there is no license on a tiny module dependency which i have already asked the author about with no reply.

two comments

colin smith (authentic) on july 23rd, 2007 at 00:39:48:

First, great blog. I just came into possession of an older Thinkpad X-series, and the information you have here on running OpenBSD has been invaluable!

I was wondering, though, if you'll be bringing code/ and such back? The directories seem to have gotten clobbered in this upgrade.

joshua (authentic) on july 23rd, 2007 at 17:00:05:

i've brought the laptops page back, but code/ will have to wait until i can integrate it nicer so updates to files get shown on the main page and in the rss feeds.


leave your comment or contact me

if you want to be able to mark your comment as authentic or delete it later, include your e-mail address (it won't be shown on the site). you'll be e-mailed instructions with a copy of your comment.

basic html allowed; be nice
required


optional


optional