Revisions
-
十行 revised this gist
Apr 26, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,8 @@ # shorten url using bit.ly if text is over 140 Earthquake.init do config[:bitly] ||= {} config[:bitly][:username] ||= 'earthquakegem' config[:bitly][:api_key] ||= 'R_22e702353baf49751d053660e4c71a30' config[:bitly][:domain] ||= 'j.mp' input_filter do |text| -
十行 revised this gist
Apr 7, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ config[:bitly][:domain] ||= 'j.mp' input_filter do |text| if text =~ /^:(update|reply|retweet|message)/ && text.size > 140 puts "shortening urls...".c(:info) text.gsub(URI.regexp(['http','https'])) do |url| query = "domain=#{config[:bitly][:domain]}&longUrl=#{URI.encode(url)}&login=#{config[:bitly][:username]}&apiKey=#{config[:bitly][:api_key]}" -
十行 revised this gist
Apr 7, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ # earthquake.gem plugin # shorten url using bit.ly if text is over 140 Earthquake.init do config[:bitly] ||= {} config[:bitly][:username] ||= '' config[:bitly][:api_key] ||= '' config[:bitly][:domain] ||= 'j.mp' input_filter do |text| if text =~ /^(:update|:reply)/ && text.size > 140 puts "shortening urls...".c(:info) text.gsub(URI.regexp(['http','https'])) do |url| query = "domain=#{config[:bitly][:domain]}&longUrl=#{URI.encode(url)}&login=#{config[:bitly][:username]}&apiKey=#{config[:bitly][:api_key]}" result = JSON.parse(Net::HTTP.get("api.bit.ly", "/v3/shorten?#{query}")) @@ -22,4 +22,4 @@ text end end end -
ryumu revised this gist
Apr 6, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ config[:bitly][:domain] ||= 'j.mp' input_filter do |text| if text =~ %r|^:update| text.gsub(URI.regexp(['http','https'])) do |url| query = "domain=#{config[:bitly][:domain]}&longUrl=#{URI.encode(url)}&login=#{config[:bitly][:username]}&apiKey=#{config[:bitly][:api_key]}" result = JSON.parse(Net::HTTP.get("api.bit.ly", "/v3/shorten?#{query}")) -
ryumu created this gist
Apr 6, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # earthquake.gem plugin # shorten url using bit.ly Earthquake.init do config[:bitly] ||= {} config[:bitly][:username] ||= '' config[:bitly][:api_key] ||= '' config[:bitly][:domain] ||= 'j.mp' input_filter do |text| if text =~ %r|^:| text.gsub(URI.regexp(['http','https'])) do |url| query = "domain=#{config[:bitly][:domain]}&longUrl=#{URI.encode(url)}&login=#{config[:bitly][:username]}&apiKey=#{config[:bitly][:api_key]}" result = JSON.parse(Net::HTTP.get("api.bit.ly", "/v3/shorten?#{query}")) if result['status_code'] == 200 result['data']['url'] else url end end else text end end end