Tag: blogs

 

Typo 4.0ish

I’ve upgraded this blog to typo 4.0.1(ish). The process was slightly less harrowing than previously as I decided to switch to using svk to manage mirroring the typo trunk. Previously, I had been using subversion vendor branches, but a couple of odd fluctuations in the typo source made that choke (files that turned into directories and vice versa). SVK appears to be more intelligent. Hurrah.

Anyway, typo 4 definitely appears to be shinier than the last release by a long way. It’s got tags (which I’ve had for a while), a revamped admin interface, better support for draft articles and lots more. It also appears that it’s less inclined to spout reams of garbage into the logs, which is nice.

As usual, please let me know if something is acting up. I’ll do my best to fix it.

Blog Buttons

I’ve seen links to “add this to del.icio.us” for some time now. I never use them. It’s a complete waste of time, my links toolbar is perfectly adequate.

A couple of months ago, I saw that people started adding more buttons to their blog posts. “Add to del.icio.us.” “Digg This!” “Reddit?”

Again, all a complete waste of time, and precious page space.

Unfortunately, today I have just witnessed this vile insanity:

Blog Buttons

I mean, really, what the hell are all those little things? And more to the point, who cares?

Typo Upgrade

I’ve finally bit the bullet and upgraded Typo to the trunk, so I can get everything up to Rails 1.1. Unfortunately, this was quite a painful process…

Normally, I track bits of software I might want to hack on in a vendor branch in subversion, and use svn_load_dirs.pl to update to new releases. This works extremely well with wordpress at work, for instance.

Sadly, svn_load_dirs.pl couldn’t cope with the typo trunk, as a directory got replaced by a symlink. Ooops. I tried working around it, but eventually, it was easier to give up and start afresh, redoing the changes I’d already made in subversion. I suppose it would have been a lot easier with SVK.

Unfortunately, a number of things haven’t caught up with the latest typo changes. In particular, the origami theme that I was using needs some loving attention. So it’s back to the default theme, “azure” for the moment, until I can spend some time on it.

Also, I couldn’t figure out how to make the google sitemaps patch work, so that’s another “gone for now” feature.

Please let me know if you spot anything else…

Update: Comments now enabled. Sorry about that.

Update#2: I’ve now fixed the comments feed a bit. It turns out that one of the migrations missed out on creating guids for all the comments…

  % ruby script/console production
  >> comments = Comment.find_all
  >> comments.reject { |c| c.guid }.each { |c| c.create_guid; c.save }

Typo Times Fix

After a bit of searching, I’ve found the problems with the odd times on this weblog. It’s a problem with ActiveRecord (part of Rails) and in particular, PostgreSQLAdaptor.

Basically, it computes a default value once, inside Ruby, and then caches it. Which is a bit odd, to say the least.

There are a number of open tickets related to this: 2873, 2877, 2257 and probably more. But looking at them, it seems that the problem will be fixed in Rails 1.1, which should be released “soon”.

Meanwhile, I’ll patch this particular instance of Typo to update the time on create. This is what I’ve used, and it seems to be working ok.

Index: app/models/article.rb
===================================================================
--- app/models/article.rb       (revision 727)
+++ app/models/article.rb       (working copy)
@@ -94,6 +94,9 @@
     self.extended_html = HtmlEngine.transform(extended, self.text_filter)
   end

+  # Work around PostgreSQL adaptor (http://dev.rubyonrails.org/ticket/2873)
+  before_create { |art| art.created_at = Time.now }
+
   def self.time_delta(year, month = nil, day = nil)
     from = Time.mktime(year, month || 1, day || 1)

Index: app/models/comment.rb
===================================================================
--- app/models/comment.rb       (revision 727)
+++ app/models/comment.rb       (working copy)
@@ -29,4 +29,7 @@
     self.body_html = HtmlEngine.transform(body, config["comment_text_filter"], [:filter_html])
   end

+  # Work around PostgreSQL adaptor (http://dev.rubyonrails.org/ticket/2873)
+  before_create { |art| art.created_at = Time.now }
+
 end

Locomotive / Typo bug

I’ve been trying to get typo working on my mac, using the very shiny Locomotive. Sadly, I kept getting display errors in my sidebar. After spending 3 hours looking at it last night, I’m now pretty sure that it’s a bug in YAML::load, which is called from inside ActiveRecord::Base#object_from_yaml. It works fine on my FreeBSD server running ruby 1.8.4. But under Locomotive (ruby 1.8.2), Instead of getting back a hash, I get some internal YAML class. Hmmm.

Thankfully, a simple patch is all that’s required to get things working properly.

Index: app/models/sidebar.rb
===================================================================
--- app/models/sidebar.rb       (revision 724)
+++ app/models/sidebar.rb       (working copy)
@@ -27,7 +27,10 @@
   end

   def active_config
-    self[:active_config]||{}
+    ac = self[:active_config]||{}
+    # XXX Work around a bug in some versions of Ruby / YAML.
+    ac = ac.value if ac.respond_to? "value"
+    ac
   end

   def html_id

I’m so glad that I imported typo into subversion on a vendor branch. It makes this sort of thing a heck of a lot easier.

I should go and file a bug in the typo trac. But I have to admit to not being sure that it’s up and running properly yet…

Makeovers

I’ve just switched the theme on this blog to Origami, winner of the typo theme contest. Whilst I think it looks good, it feels a bit slow. And I really dislike the Flash technique for replacing the texts of the headlines. It means you can’t select the text properly any more. So the theme may change again shortly. Given my level of artistic inability, it’s won’t be an original creation though.

Meanwhile, Jeremy Keith has given his blog engine a makeover—Everything old is new again. It looks exactly the same as before, but now comes with added searchy goodness. Of course, he used MySQL instead of a real database, but we can forgive small foibles. ;-)

My only minor critique is that a permanent redirect should be set up on the RSS feed to direct clients towards the new URL. Something like this in .htaccess should do the trick.

  Redirect permanent /journal/journal.rss  http://adactio.com/journal/rss

I never understood why Apache required you to specify an absolute URL for the destination there. It should be able to work it out if you’ve left the hostname and scheme off…

Typo TimeZones

One minor annoyance that I’ve noticed since I started using typo is that the times are out by about 8 hours. For instance, this post probably says “created 8 hours ago”, even though I created it only a few minutes ago. Looking at the previous post in the database, which has never been edited:

created_at     | 2006-01-24 00:29:00
updated_at     | 2006-01-24 08:52:04

The updated_at field is correct.

So now I have to figure out which of the many components is defaulting to Eastern Standard Time. Could it be Ruby? Rails? PostgreSQL? Apache? JavaScript? Safari? Who knows, I have to go to work now…

Update: It turns out that HowtoSetDefaultTimeZone has the answer. Put this into config/environment.rb:

ActiveRecord::Base.default_timezone = :utc

Moved to Typo

After much delay, I’ve finally moved this blog to typo. It’s a good example of running rails in “production” mode.

Now I just need to find a good blog editor client. It’d be nice if it supported Textile, which I’ve recently been converted to.

Oh, and it’d be really cute if I could figure out how to get tags like pdcawley. I suspect that I need to run the trunk of typo to get that though. Or maybe there’s a plugin somewhere…

FastCGI

I spent a little while yesterday attempting to work out how to get FastCGI installed. Unfortunately, because I’m using Apache 2.2, this wasn’t straightforward. In fact, I’d pretty much given up. Later on, I found this patch on the fastcgi-devel list, which purports to work (and looks like it will, given my experiences yesterday).

All this is just so that I can sensibly run Typo, a rails app. There are other ways to do it, but they’re less preferrable. I could use plain CGI, but that’s dog-slow. I could set up lighttpd, but I’d rather not, seeing as I’m already running Apache for so many other services. I suppose that I could run the standalone script/server tool and use mod_proxy to connect to it. But I that means that I then have to ensure that the process stays up the whole time and gets started correctly. Overall, FastCGI seems like the best choice.

So, today I’ll have a go at plumbing that patch into the FreeBSD port.

Blogging Software

It started innocently enough, but as usual turned into yak shaving rather quickly. I wanted to try out some graphical editors for posting to my blog. Sounds simple enough. Except that a while back, I chose wordpress-pg. Its a version of wordpress, but it talks to PostgreSQL instead. Except that for some reason, my copy doesn’t have the xmlrpc.php file needed. So heading over to the wordpress-pg site, I am greeted by this lovely message.

WARNING! This version is probably subject to flaws in xmlrpc handling. Delete xmlrpc.php if present in your install. This flaw can allows outside attackers to execute arbitrary commands as the user your web server runs as.

Oh dear. So I won’t be doing that then. But part of the problem is that it’s already fixed in wordpress 1.5 (MySQL edition). Sadly, wordpress-pg is a very inactive project. I know, it’s open source, fix it yourself. But right now, I more or less just want something to work. And I don’t want to delve into scary php if I can help it (I know, that’s rich coming from a Perl programmer). So what are the choices?

I could look at getting MySQL installed and moving over to wordpress proper. Well, I’ve finally gotten around to doing some MySQL at work and I now understand it a little bit, even if I don’t like it that much. But I still have to get the actual database ported from PostgreSQL to MySQL somehow, which seems jolly arduous.

The alternative is to take a look at Typo, a Rails powered blogging engine. The selling points are that it appears to be actively maintained, it’s written in Rails (which I wish to play with) and also that it has a wordpress import script. So I’ve just spent an hour attempting to convert my wordpress-pg install over to typo. And I have to say that it works pretty well. Here’s what I found.

Firstly, I followed the basic install to get typo up and running. I saw Piers complaining about it, but it’s reasonable for me. But I’ve used rails before, so I’m probably not the target market. Anyway, I got to the admin screens and set up a test account pretty quickly. I then ran the import script giving it my old wordpress database name. Needless to say, it didn’t work first time. I had to make these changes to the script:

  1. Get rid of all backquotes, that’s some weird MySQLism.
  2. I had to change all entry['ID'] to entry['id']. PostgreSQL downcases things.
  3. I had to rework the trackback support slightly. Because wordpress-pg is based on wordpress 1.2, trackbacks are stored as a comment that starts with <trackback /> at the beginning. So I had to change comment_type = 'trackback' into comment_content LIKE '<trackback />%'
  4. The import script runs in the dev environment by default, but I had been testing in the production environment. This meant I had no users set up in my dev environment. Consequently, I had to patch up the relationships between the users and the articles afterwards (update articles set user_id=1;). Actually, looking at the script, it doesn’t seem to make those links anyway…

The biggest problem was actually getting the script to access the original data. The script assumes that you can do the MySQLish thing of accessing another database by specifying dbname.table. This doesn’t work in PostgreSQL. But, you can take advantage of the fact that PostgreSQL does support schemas, so instead, you can create a schema called wordpress and load a dump of the main database into there. I had to make a few edits to the dumpfile before loading it in though.

  1. Get rid of the stuff about plpgsql at the top. I don’t use it.
  2. Add CREATE SCHEMA wordpress and SET search_path = wordpress, public, pg_catalog.
  3. Comment out all the ALTER foo SET OWNER TO wordpress lines. You have to import it as the typo user and don’t want that changing behind your back.

After the import you can just run DROP SCHEMA wordpress CASCADE to clean up.

After that, I now have a working blog with all my old content. Hurrah! Not simple, but not too difficult either.

Now before I get this main blog converted over, I just need to work out how to run FastCGI scripts from Apache, something I haven’t done before. And then I’ll be away, and I can uninstall wordpress-pg.