• 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

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

  1. ruby-openidをインストール(2.0.4)

       1  gem install ruby-openid
    

  2. pluginのインストール

       1  $ ./script/plugin install http://svn.rubyonrails.org/rails/plugins/open_id_authentication/
    

  3. パッチをあてる

    • パッチを入手ticket10604.diffとして保存
      http://dev.rubyonrails.org/ticket/10604

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

         1   #{RAILS_ROOT}/vendor/plugins/open_id_authentication/ticket10604.diff
      

    • プラグインのルートに移動して、patchを当てる

         1  $ patch -p1 < ticket10604.diff
         2  patching file init.rb
         3  Hunk #1 FAILED at 1.
         4  1 out of 1 hunk FAILED -- saving rejects to file init.rb.rej
         5  patching file lib/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
         6  patching file lib/generators/open_id_authentication_tables/templates/migration.rb
         7  patching file lib/open_id_authentication.rb
         8  Hunk #5 succeeded at 69 with fuzz 1 (offset -2 lines).
         9  Hunk #6 succeeded at 88 (offset -2 lines).
        10  Hunk #7 succeeded at 152 (offset -2 lines).
        11  patching file lib/open_id_authentication/association.rb
        12  patching file lib/open_id_authentication/db_store.rb
        13  patching file lib/open_id_authentication/nonce.rb
        14  patching file lib/open_id_authentication/setting.rb
        15  patching file tasks/open_id_authentication_tasks.rake
        16  patching file test/normalize_test.rb
        17  patching file test/open_id_authentication_test.rb
        18  patching file test/status_test.rb
      

  4. READMEにあるExampleの作業

    • テーブル作成

         1   rake open_id_authentication:db:create 
      

    • routesに下記を加える

         1    map.open_id_complete 'session', :controller => "sessions", :action => "create", :requirements => { :method => :get }
         2    map.resource :session
      

    • SessionsController、vews/sessions/new.html.erbの作成
      ここでmatakeさんと同じようにはまったのですが、SessionConroller#open_id_authenticationをREADMEにあるresult.successful?のほうを使うとプラグインに手を入れずに使うことができます。(agilewebdevelopment.comのExampleを使うとNG)

         1      def open_id_authentication
         2        authenticate_with_open_id do |result, identity_url|
         3          if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)
         4            successful_login
         5          else
         6            failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})")
         7          end
         8        end
         9      end
      

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

       1  #open_id_authentication/init.rb
       2  begin
       3  #  gem 'ruby-openid', '=1.1.4'
       4    gem 'ruby-openid'
    

参考

posted by Png satoko on Wed 27 Feb 2008 at 16:40

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

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

posted by Png satoko on Tue 26 Feb 2008 at 07:38

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

仕様

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

使い方

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

作り方

  1. 類似するプラグインを探してコーディングの検討をつける
  2. script/generateする
       1  script/generate plugin tinyurl_helper
    
  3. 上で生成されたlib/tinyurl_helper.rbを編集
       1  require 'net/http'
       2  
       3  module TinyurlHelper
       4    def link_to_tinyurl(url, html_options = nil)
       5      uri = 'http://tinyurl.com/api-create.php?url=' + url
       6      uri = URI.parse(uri)
       7      tiny_url = Net::HTTP.get_response(uri).body
       8      options = {:title => url, :alt => url}
       9      options = html_options.nil? ? options : options.merge(html_options)
      10      link_to tiny_url, tiny_url, options
      11    end
      12  end
    
  4. テストを書く(アプリテスト、プラグイン単体テスト両方通るように書くと吉)

       1  -
       2  require 'test/unit'
       3  require File.expand_path(File.dirname(__FILE__) + "/../lib/tinyurl_helper")
       4  
       5  class TinyurlHelperTest < Test::Unit::TestCase
       6    include TinyurlHelper
       7  
       8    #dummy link_to
       9    def link_to(name, options = {}, html_options = nil)
      10      [name, html_options[:title]]
      11    end
      12  
      13    def test_link_to_tinyurl
      14      url = 'http://www.yahoo.co.jp/'
      15      tiny_url, title = link_to_tinyurl(url)
      16      assert_equal 'http://tinyurl.com/910', tiny_url
      17      assert_equal url, title
      18    end
      19  
      20    def test_link_to_tinyurl_with_title
      21      url = 'http://www.yahoo.co.jp/'
      22      tiny_url, title = link_to_tinyurl(url, {:title => 'title'})
      23      assert_equal 'http://tinyurl.com/910', tiny_url
      24      assert_equal 'title', title
      25    end
      26  end
    

  5. README, MIT-LICENSEを書く

    • READMEは名前と、概要・使い方を書く
    • MIT-LICENSEは名前だけ変更
  6. 公開用リポジトリにコミット

  7. pluginディレクトリに登録する

Tips

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

今年の目標に、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

問題

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

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

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

posted by Png satoko on Tue 19 Feb 2008 at 11:04

シンプルなスクリーンに番号なしの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 Png satoko on Fri 15 Feb 2008 at 06:53

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 Png satoko on Fri 15 Feb 2008 at 06:12