OpenIdAuthenticationはruby-openid1.1.4にしか対応していません。ですが、gem1.0.1では1.1.4が正しく動作しないため、プラグインにパッチをあてて使うことにしました。

  1. ruby-openidをインストール(2.0.4)
    shell>>
    gem install ruby-openid
    <<--

  2. pluginのインストール
    shell>>
    $ ./script/plugin install http://svn.rubyonrails.org/rails/plugins/open_id_authentication/
    <<--

  3. パッチをあてる

  • パッチを入手ticket10604.diffとして保存

http://dev.rubyonrails.org/ticket/10604

  • プラグインのところに移動させておく
    shell>>

#{RAILS_ROOT}/vendor/plugins/open_id_authentication/ticket10604.diff
<<--

  • プラグインのルートに移動して、patchを当てる
    shell>>
    $ patch -p1 < ticket10604.diff
    patching file init.rb
    Hunk #1 FAILED at 1.
    1 out of 1 hunk FAILED -- saving rejects to file init.rb.rej
    patching file lib/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
    patching file lib/generators/open_id_authentication_tables/templates/migration.rb
    patching file lib/open_id_authentication.rb
    Hunk #5 succeeded at 69 with fuzz 1 (offset -2 lines).
    Hunk #6 succeeded at 88 (offset -2 lines).
    Hunk #7 succeeded at 152 (offset -2 lines).
    patching file lib/open_id_authentication/association.rb
    patching file lib/open_id_authentication/db_store.rb
    patching file lib/open_id_authentication/nonce.rb
    patching file lib/open_id_authentication/setting.rb
    patching file tasks/open_id_authentication_tasks.rake
    patching file test/normalize_test.rb
    patching file test/open_id_authentication_test.rb
    patching file test/status_test.rb
    <<--
  1. READMEにあるExampleの作業
  • テーブル作成
    shell>>
    rake open_id_authentication:db:create
    <<--

  • routesに下記を加える
    rails>>
    map.open_id_complete 'session', :controller => "sessions", :action => "create", :requirements => { :method => :get }
    map.resource :session
    <<--

  • SessionsController、vews/sessions/new.html.erbの作成
    ここでmatakeさんと同じようにはまったのですが、SessionConroller#open_id_authenticationをREADMEにあるresult.successful?のほうを使うとプラグインに手を入れずに使うことができます。(agilewebdevelopment.comのExampleを使うとNG)
    rails>>
    def open_id_authentication
    authenticate_with_open_id do |result, identity_url|
    if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)
    successful_login
    else
    failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})")
    end
    end
    end
    <<--

  1. ruby-openidのバージョン指定をはずす
    rails>>

#open_id_authentication/init.rb
begin

gem 'ruby-openid', '=1.1.4'

gem 'ruby-openid'
<<--

###参考

posted by satoko satoko on Wed 27 Feb 2008 at 16:41 with 0 comments

http://tinyurl.com/を見て気がついたのですが、paypalのほかにAmazon Honor Systemというのもあるようです。

手軽なマネタイズ方法としてつけることも検討してみよう

posted by satoko satoko on Tue 26 Feb 2008 at 07:39 with 0 comments

下記URLから入手できます。
http://svn.s21g.com/public/rails/plugins/tinyurl_helper/

###仕様
URLを渡すとTinyURLに変換してリンクを作ります。

###使い方

  • application_helper.rbでinclude
    rails>>
    module ApplicationHelper
    include TinyurlHelper
    end
    <<--
  • View内で
    rails>>
    <%= link_to_tinyurl "http://www.yahoo.co.jp" %>
    <<--

###作り方
0. 類似するプラグインを探してコーディングの検討をつける

  1. script/generateする
    shell>>
    script/generate plugin tinyurl_helper
    <<--
  2. 上で生成されたlib/tinyurl_helper.rbを編集
    rails>>
    require 'net/http'

module TinyurlHelper
def link_to_tinyurl(url, html_options = nil)
uri = 'http://tinyurl.com/api-create.php?url=' + url
uri = URI.parse(uri)
tiny_url = Net::HTTP.get_response(uri).body
options = {:title => url, :alt => url}
options = html_options.nil? ? options : options.merge(html_options)
link_to tiny_url, tiny_url, options
end
end
<<--
3. テストを書く(アプリテスト、プラグイン単体テスト両方通るように書くと吉)

rails>>

require 'test/unit'
require File.expand_path(File.dirname(FILE) + "/../lib/tinyurl_helper")

class TinyurlHelperTest < Test::Unit::TestCase
include TinyurlHelper

#dummy link_to
def link_to(name, options = {}, html_options = nil)
[name, html_options[:title]]
end

def test_link_to_tinyurl
url = 'http://www.yahoo.co.jp/'
tiny_url, title = link_to_tinyurl(url)
assert_equal 'http://tinyurl.com/910', tiny_url
assert_equal url, title
end

def test_link_to_tinyurl_with_title
url = 'http://www.yahoo.co.jp/'
tiny_url, title = link_to_tinyurl(url, {:title => 'title'})
assert_equal 'http://tinyurl.com/910', tiny_url
assert_equal 'title', title
end
end
<<--

  1. README, MIT-LICENSEを書く
  • READMEは名前と、概要・使い方を書く
  • MIT-LICENSEは名前だけ変更
  1. 公開用リポジトリにコミット
  2. pluginディレクトリに登録する

###Tips

  • プラグインはweb serverを再起動しないとリロードされない
  • helperを使えるようにする方法は2つ
  1. app/helper/application_helper.rbでinclude(上でやった方法)
  2. plugins/tinyurl_helper/init.rbでsendする
    rails>>
    ActionView::Base.send :include, TinyurlHelper
    <<--
posted by satoko satoko on Tue 26 Feb 2008 at 06:20 with 0 comments

今年の目標に、railsのプラグインを作るというのがあるのですが、時間ができたらと言わずに「さっさと/ささっと作れ」という助言をもらったのでささっとやってみました。まずはどいういうものかという初歩的なところから。
###Pluginディレクトリ
ここに多く集められています。
http://agilewebdevelopment.com/plugins

###様々な種類のプラグイン
プラグインはRailsの機能拡張するものなのですが、下記のように分類できます。

  • Helper系
  • Model/Controller系
  • acts_as_なんとかという名前が多い
    ex. acts_as_taggable
  • Generator系
  • その他
  • 上記のmix
    ex. acts_as_authenticated => model/controller拡張, generator
  • rake taskを作るもの
    ex. annotate_models

###作り方how-to

  • Generatorの作り方

http://blog.s21g.com/articles/215

  • pluginの作り方(情報が古い。rails変化早っ)

http://d.hatena.ne.jp/secondlife/20051101/1130850457

  • ロードパスについて

http://rakuto.blogspot.com/2006/06/rails-controllermodelview.html

###問題

  • プラグインのテスト、アプリのテスト両方のテストを通すようにtestを書くのが煩雑。
  • プラグインの更新を適用するのが面倒
    (gemのように簡単に最新にならないので、手動で削除、再インストールが必要)
posted by satoko satoko on Mon 25 Feb 2008 at 13:34 with 0 comments

今日、Skypeチャットルームで話されてたんだけど、「digg is really one-day fly spike」(Diggは一日だけの急上昇飛行)なんだそう。もしかしてはてぶそうなのかもですね。今まではなんとなくブックマークサービスとしてだけ見ていましたが、ユーザーの使い方がDiggぽいといえばDiggぽい。だのにブックマークサービスだから、議論とかがしにくい。

ユニークな見方をもらいました。

posted by satoko satoko on Tue 19 Feb 2008 at 10:55 with 0 comments

###シンプルなスクリーンに番号なしの4つのボタンという携帯
modu http://h.hatena.ne.jp/satoko87/9245599875404390893
携帯のエッセンスだけを残したのがModu。

ジャケットを変えるだけで、MP3プレイヤー・普通の携帯電話・GPSナビゲーションシステム等いろんな役目を果たしてくれるなんてステキ!

http://www.modumobile.com/
http://www.technologyreview.com/Infotech/20276/

とりあえず、modulemobileのサイトにアクセスしてみてください。紹介のflashでいろいろインスパイアされます。

そうそうイスラエルのstarupなんです。イスラエルってデバイス系のstarup多い気がします。

posted by satoko satoko on Fri 15 Feb 2008 at 07:05 with 0 comments

http://www.amazon.com/b?ie=UTF8&node=342429011
詳細は原文で確認してくださいね。news.ycombinatorで紹介されていました(他の課金サービスへのリンクもあります)。

###Amazon DevPayとは
http://www.amazon.com/b?ie=UTF8&node=342429011

Amazon DevPay is a simple-to-use billing and account management service that makes it easy for developers to get paid for applications they build on Amazon Web Services.

###状況

  • まだlimited beta
  • Amazon S3か、EC2を使ったアプリケーションでなければいけない(順次他のサービスも追加予定とのこと)

###お値段

  • No minimum fees and no setup charges
  • 3.0% of the total amount billed
  • $0.30 per bill generated
  • 顧客からお金を集められなかった分については、課金しません
  • Net Liabilityという制度もあり(S3/EC2の支払い金額を合わせてマイナスにならないように補填する制度のようです)

###制限

  • USでビジネスを行えること。USの銀行口座を使うこと
    (ここ不明瞭なので原文を参照ください)

    Sellers of Amazon DevPay applications must be able to do business in the United States. Funds earned through the sale of Amazon DevPay applications can only be withdrawn to U.S. bank accounts.

posted by satoko satoko on Fri 15 Feb 2008 at 06:27 with 0 comments