最近の投稿
人気のページと投稿
アーカイブ
月 | 火 | 水 | 木 | 金 | 土 | 日 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
AWS, Content Delivery Network and Debian
donrailsと名づけてrails0.12のときはじめたblogツールはwordpressへの移行ツール公開にて終了。
donrailsは日記や、blogの作成をするためのrubyプログラムです。 記事の作成には、webからの入力のほか、AtomAPIを使用することができます。
donrailsは、これを作る前からずっとHNSで書いていた日記があったので、hnf記法に対応したblogツールが欲しかったので複数の記法に対応するblogツールとして2005の7月に5日ほど休暇があったときに作ったのでした。
もともと、ぼそ&ayが「railsのいいところはActiveRecord」と主張していたので興味を持って、何かつくりつつアイディアを試そうと思ってはじめたものだった。いろいろ試したけど、マイルストーンは何だったのか思いかえしてみる。
こう考えると、2008以降はほとんどメンテモードで何も新しいことは試してないのでした。今年は本当にrailsまわりのコードを新規に書くこともしてないので、波及効果も限定的でした。
というわけでまた思いだすこともあるかもしれないけど、ひとまず終了。
GithubにてApacheライセンスの下、公開しました。https://github.com/armaniacs/blog-import-export
やれること
具体的には、donrailsからwordpressへの引越しは問題なくできました。
Apacheライセンスなのでいくらでもsnippetして使ってください。
ArgumentError (A copy of ApplicationHelper has been removed from the module tree but is still active!): app/helpers/application_helper.rb:459:in `don_get_oldconfig' app/helpers/application_helper.rb:453:in `don_get_config' lib/akismet.rb:41:in `initialize'
というエラーが,JRubyでdevelopment modeで動作させたときだけ発生していた.
Commit d37ac7958fc88fdbf37a8948102f6b4e45c530b3 to rails’s rails – GitHub
でなおっているらしい.
donrailsでつかっているlibxml-rubyとlibxml-xmlrpcをconfig.gemでいれられるようにしていたのだが,そのconfig.gemで指定しても,
Missing these required gems: libxml-ruby libxml-xmlrpc You're running: ruby 1.8.7.160 at /opt/local/bin/ruby rubygems 1.3.4 at /Users/yaar/.gem/ruby/1.8, /opt/local/lib/ruby/gems/1.8
といわれるのでした.
もちろんlibxml-rubyもlibxml-xmlrpcも存在している.
/opt/local/lib/ruby/gems/1.8/gems$ ls libxml-ruby* libxml-ruby-0.8.3: CHANGES RAKEFILE doc/ lib/ test/ LICENSE README ext/ setup.rb libxml-ruby-0.9.7: CHANGES README doc/ lib/ test/ LICENSE Rakefile ext/ setup.rb libxml-ruby-1.1.3: CHANGES README doc/ lib/ test/ LICENSE Rakefile ext/ setup.rb
どうやら
#LibXML Ruby - Dependency of Solr Ruby config.gem "libxml-ruby", :lib=>"xml/libxml", :version=>"~>0.8.3"
こんなかんじで中でよんでる :libの形にあわせて書け,とそういうことらしい.
config.gem "libxml-ruby", :lib=>"xml/libxml" config.gem "libxml-xmlrpc", :lib=>"xmlrpc/client"
に.変更した.これでok
研究でつかってるprogramの前哨戦で,donrailsのrails2.3化を行った.
actionmailer (2.3.2) actionpack (2.3.2) actionwebservice (2.3.2) activerecord (2.3.2) activeresource (2.3.2) activesupport (2.3.2) hpricot (0.8.1) libxml-ruby (1.1.3) libxml-xmlrpc (0.1.5) mocha (0.9.5) mysql (2.7) packet (0.1.15) rails (2.3.2) rake (0.8.4) rubygems-update (1.3.2) will_paginate (2.2.2)
使うのはこんなかんじ.
gem build actionwebservice-2.3.2.gem gem install actionwebservice.gem --local
<%= hidden_field_tag(:session_id_validation, security_token) %>
その数は.
cfardm-2:~/playground/donrails/app/views$ gfind -name \*.rhtml |xargs grep token |wc 35 324 5043
かなり多いな.面倒なので,
module ApplicationHelper def security_token # dummy for 2.3.2 return rand.to_s end
という具合でdummyをいれた.
protect_from_forgery :except => [:catch_trackback, :trackback, :catch_ping]
post :delete_article, :deleteid => {'40000' => '1'} assert_equal "<br>Not exists (no delete):40000", flash[:note2] assert_redirected_to :action => 'manage_article' post :delete_article, :hideid => {'4' => '0'}, :deleteid => nil assert_equal "<br>Hyde status:4 is 0", flash[:note2] assert_redirected_to :action => 'manage_article'
こんなんじで引数を変えて,2つの postを評価しているときには,2つ目のほうには使わない引数には nil を与えるなどしてやらないといかん
NameError (uninitialized constant ApplicationController::AntiSpam): app/controllers/application_controller.rb:199:in `don_is_spam?'
とかでたので,environment.rbをいじった.
config.load_paths += %W( #{RAILS_ROOT}/lib )
ちょっとdonrailsでrails2.3がどんなものかやってみることにした.donrailsはrailsが0.11のころから作っているので,いろんなものをひきずっていて,これで動けばまあ自分の範囲では問題ないから,というのがある.
rake rails:update をまず.
application.rbがapplication_controller.rbにかわった.
次のはまり道
load_missing_constant’: uninitialized constant ActionController::AbstractRequest (NameError)
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::AbstractRequest (NameError) from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing' from /opt/local/lib/ruby/site_ruby/1.8/action_web_service/protocol/abstract.rb:74 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from /opt/local/lib/ruby/site_ruby/1.8/action_web_service/protocol.rb:1 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
このaction_web_serviceの問題か?
http://github.com/datanoise/actionwebservice/tree/masterを見ると2.3.2に対応したとかかいてあるな.
とりあえず plugin install でいれた.
config/environment.rb で
# config.frameworks += [ :action_web_service, :action_mailer ]
というかんじでコメントにしたらokだった.
さて.rake testがまだなので実環境ぶっこみはまだ先だ.
本日の仕事. サーボモータが電力オーバーになるのの対処に時間をとられまくり.
今までは,1のようになっていたpageを2のように更新.
というのもおそらくmod_rewriteの魔境にはまってしまったのだが,1のpageが常にhttp://donrails.araki.net/archives/にredirectされるようになってしまって不便このうえなかったので..
blog記事はふつう記事にリンクを貼るので page をつかうことはないと思うけど,もし影響した人がいたらごめんなさい.
昨日にひきつづき,donrailsをrails2.2.2に対応させるべくいろいろやって,
対応させました.
これで,とりあえずrails2.2対応は終了したのでやっと機能追加にはいれます.
今日やったこと.
DEPRECATION WARNING: truncate takes an option hash instead of separate length and omission arguments. (called from_run_rhtml_app47views47notes47recent_trigger_title_a46rhtml at /Users/yaar/playground/donrails-rails-2.2.2/app/views/notes/recent_trigger_title_a.rhtml:34)
ときたので,
truncate(txt, 76)
となっていたところを
truncate(txt, :length => 76)
にする.
他にも二箇所あったので修正.
donrailsを2.0から2.2に一気にあげなかった理由はこれがなおるかもしれない,と思ったからなのだがやっぱりひっかかった.
(ArgumentError) “Object is not missing constant TagsController!”
こまったな.たしかにdevelopment modeではこれは発生していない.
http://www.nabble.com/forum/Search.jtp?query=activesupport%202.2.2%20load_missing_constant
いろいろ試行錯誤してみると,どうも自分の場合は typoから移植したantispam.rbを models/comment.rbで使っていることにあるようだ.
class Comment < ActiveRecord::Base belongs_to :article validates_presence_of :author validates_length_of :password, :minimum => 4 validates_length_of :body, :minimum => 5 validates_antispam :url validates_antispam :ipaddr validates_antispam :body validates_antispam :author validates_antispam :title (略)
としてるこの validates_antispamをとりあえずどけた.
rails2.0で動いてたdonrailsを2.1に対応させてみた.前もひとつやったけどdonrailsってナニなことをやっているんだなあ,という気にさせられた..
Rendering template within ./MT/notes Rendering notes/./MT/noteslist
というかんでpathの途中に /./ がはいるといかんようだ.
- return File.join(path, theme, filename) + if path == "." + return File.join(theme, filename) ## for rails2.1 + else + return File.join(path, theme, filename) + end
application_helper.rbの中でrenderを呼んでいるときは :inline を指定してやる.
rails2.0のときは
- content += render("shared/attachments/picture", "atta" => atta)
こんなかんじでrender先でつかう変数は"hoge"でくくってやれば使えたが,rails2.1では
+ content += render(:inline => "shared/attachments/picture", :locals => {:atta => atta})
とまあ,:localsを使って指定しなければならない.
app/viewsの下でrenderを呼ぶときは,:template で指定してやる
-<%= render(don_get_theme("shared/category_title_list"), "category" => "donrails ") %> +<%= render :template => don_get_theme("shared/category_title_list"), :locals => {:category => "donrails"}
どうもrails2.1には対応していないのでざっくり削除.
というわけでなんとかなったのでrails2.2対応が次かな.