Mephisto に移行

July 8th, 2007

Typo にページキャッシュをつけて、できるだけ Apache の段階 (Rails より前) でリクエストをさばけるようにしようと作業していたんだけど、いきづまってふと Mephisto をみてみたらページキャッシュがあったので、移行してみた。

Mephisto は Riding Rails (Rails 公式) でも使われているブログソフトウェア。ちなみに Typo の開発自体はふつうに続いています。Typo の Trac を参照。

データベースの中身をうつす

Converting Typo to Mephisto にあるように、コンバータが用意されているので、けっこう簡単です。

ただ permalink は title から再生成してしまうらしく、そこだけ script/console から書き換えました。

ページネーション

なぜかページネーションが無いので、pagination plugin をインストール。

ページごとの記事数は /admin/settings ではなく /admin/sections の "Articles per page" から変更するようです。

パーマリンク

個別ページの URI はデフォルトだと /YYYY/M/D/NAME なので Typo にそろえて /articles/YYYY/MM/DD/NAME に変更。

/articles をつけるのは /admin/settings で変更できるのですが、月・日をつねに二桁にするのはソースをいじらないとだめでした。

diff -uNr mephisto-0.7.3.orig/lib/mephisto/dispatcher.rb mephisto-0.7.3/lib/mephisto/dispatcher.rb
--- mephisto-0.7.3.orig/lib/mephisto/dispatcher.rb      2006-11-23 10:57:06.000000000 -0800
+++ mephisto-0.7.3/lib/mephisto/dispatcher.rb   2007-07-07 22:00:24.000000000 -0700
@@ -132,7 +132,13 @@
       end

       def self.variable_value_for(article, variable)
-        variable == 'id' ? article.article_id.to_s : article.send(variable).to_s
+        if variable == 'id'
+          article.article_id.to_s 
+        elsif variable == 'month' or variable == 'day'
+          '%02d' % article.send(variable)
+        else
+          article.send(variable).to_s
+        end
       end
   end
-end
\ No newline at end of file
+end

トラックバック

ありません。どうしよう。

テンプレート

テンプレートは eRuby ではなく Liquid というものを使うようです。

Liquid is an extraction from the e-commerce system Shopify. Shopify powers many thousands of e-commerce stores which all call for unique designs. For this we developed Liquid which allows our customers complete design freedom while maintaining the integrity of our servers.

アプリケーションを動かす権限 != テンプレートの編集権限な環境を想定すると、確かに eRuby はこわいってのはわかるけど、このブログはふたつの権限が同じだからちょっとまどろっこしい。ミニ言語はあんまり好きじゃないな。

フィード

FeedBurner かましているので FeedBurner 側の設定をいじるのと .htaccess で

RewriteCond %{HTTP_USER_AGENT} !^FeedBurner.*$
RewriteRule ^feed/atom.xml$ http://feeds.feedburner.com/kzys [L,R=permanent]

しておくだけ。