2010-09-30
■ [ruby] Rubyで書かれたミニマルなブログエンジン、toto

- Sinatraすら使わず、Rackのみで実装されている
- 記事のバージョン管理はgitで
- 記事のマークアップはmarkdownで(変更可能らしい)
- コメントはdisqusで
- サーバはThinなりPassengerなりunicornなり(CGIもいけそうな気がする)
- 記事はテキストファイルに書く
- 最初の数行にメタデータ(タイトルとか)を書く。
- 独自のメタデータを書いて、ERBテンプレートからそれを表示するようなカスタマイズも可能
データベースが不要で、テキストファイルを編集してgitでpushするだけっていうシンプルさが良いかも。
使い方
すぐに使い始められる状態になったものがgithubのcloudhead/dorothyにあるので、それをcloneする。
Herokuにアップロードする手順が公式サイトに載っている。(Herokuについては10月発売のWEB+DB PRESSに書くよ!)
$ git clone git://github.com/cloudhead/dorothy.git myblog $ cd myblog $ heroku create $ git push heroku master
ブログのコード自体はdorothyではなく、toto gemの方に入っている。名前は「」の主人公と、その愛犬ですね。
■ [ruby] mongoidのドキュメントを手元に置く方法
1.
$ git clone http://github.com/mongoid/mongoid-site.git
2.
$ bundle install # bundlerがなければ先に gem install bundler
3.
$ nanoc autocompile
4.
$ open http://localhost:3000/
5.
ArgumentError: invalid byte sequence in UTF-8 /Users/yhara/.rvm/gems/ruby-1.9.2-p0/gems/nanoc3-3.1.5/lib/nanoc3/data_sources/filesystem.rb:242:in `=~'
6. nanocェ…と言いながらrvm use 1.8.7して上の手順を繰り返す
7. 動きました

■ [ruby] mongoidのロケールを翻訳しようとしたのだが…
padrino (http://www.padrinorb.com/guides/localization ) も、mongoid (http://mongoid.org/docs/installation/ )も、英独仏伊西は翻訳者がいるけど日本語がなくて悲しい。言語の壁
[Twitter / yharaより引用]
と言うだけでは何なので自分で訳してみようと思ったんだが、これが思ったより難しい。英語と日本語ってちょっと違いすぎるよね。 下手に訳すと「メモリが"read"になることはできませんでした」みたいになりそうで怖い。
とりあえずやってみたのが以下。フィードバックください。
ja:
activemodel:
errors:
messages:
taken: は、既に利用されています
# is already taken
mongoid:
errors:
messages:
document_not_found:
idが%{identifiers}(のいずれか)である%{klass}クラスのドキュメントは見つかりませんでした。
# Document not found for class %{klass} with id(s) %{identifiers}.
invalid_database:
データベースがMongo::DBではなく、%{name}になっています。
# Database should be a Mongo::DB, not %{name}.
invalid_type:
%{klass}として定義されたフィールドに、%{value}という%{other}が渡されました。
# Field was defined as a(n) %{klass}, but received a %{other} with
# the value %{value}.
unsupported_version:
MongoDB %{version}はサポートされていません。
%{mongo_version}にアップグレードしてください。
# MongoDB %{version} not supported, please upgrade
# to %{mongo_version}.
validations:
バリデーションに失敗しました:%{errors}
# Validation failed - %{errors}.
invalid_collection:
埋め込まれたドキュメント%{klass}からはコレクションにアクセスできません。
ルートドキュメントからアクセスしてください。
# Access to the collection for %{klass} is not allowed since it
# is an embedded document, please access a collection from
# the root document.
invalid_field:
%{name}という名前のフィールドは定義できません。
Mongoidが内部で使用している属性やメソッドと重複する名前の
フィールドは定義できません。そのような名前については
Document#instance_methods を参照してください。
# Defining a field named %{name} is not allowed. Do not define
# fields that conflict with Mongoid internal attributes or method
# names. Use Document#instance_methods to see what names this includes.
too_many_nested_attribute_records:
%{association}の属性のネストは%{limit}レコードまでに制限されています。
# Accepting nested attributes for %{association} is limited
# to %{limit} records.
embedded_in_must_have_inverse_of:
embedded_inメソッドの:inverse_ofオプションは省略できません。
# Options for embedded_in association must include inverse_of.
dependent_only_references_one_or_many:
オプション :dependent => destroy/delete は、
references_oneまたはreferences_manyメソッドにのみ有効です。
# The dependent => destroy|delete option that was supplied
# is only valid on references_one or references_many associations.
association_cant_have_inverse_of:
このアソシエーションに:inverse_ofオプションは設定できません。
このオプションはembedded_inまたはreferences_manyにのみ有効です。
# Defining an inverse_of on this association is not allowed. Only
# use this option on embedded_in or references_many as array.
calling_document_find_with_nil_is_invalid:
Document#findの引数がnilです
# Calling Document#find with nil is invalid
おまけ
エルシャダイロケール
ja-ElShaddai:
activemodel:
errors:
messages:
taken: は既に利用されているが大丈夫か?
# (くだらなすぎるので以下略)
>(くだらなすぎるので以下略)<br>いえいえ、”そういうnlize”を彷彿とさせるので、ぜひ!
padrino のは翻訳して送っておきました
okkezさんかっこいい!<br><br>ムムリクさん:"そういうnlize"の元ネタが分かりませんでした…