OSC2007-niigata - mashup

4,152
-1

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,152
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
92
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

OSC2007-niigata - mashup

  1. 1. ↓Macbook pro
  2. 2. ↓Macbook pro Not
  3. 3. 1
  4. 4. Rails
  5. 5. Mashup
  6. 6. Mashup
  7. 7. Remix
  8. 8. Remix
  9. 9. Mashup
  10. 10. Mashup
  11. 11. Mashup
  12. 12. HTML
  13. 13. API
  14. 14. Web2.0
  15. 15. WebAPI
  16. 16. WebAPI
  17. 17. 3
  18. 18. RSS Amazon Web Service Google net
  19. 19. →MP3
  20. 20. Google Maps NIFTY Timeline API
  21. 21. API MVC M V
  22. 22. Controller
  23. 23. PHP, Perl, Ruby, Java....
  24. 24. PHP
  25. 25. Ruby on Rails
  26. 26. Web2.0
  27. 27. WebAPI ActiveResource
  28. 28. Rails2.0
  29. 29. Rails2.0
  30. 30. ActiveResource
  31. 31. Rails Rails
  32. 32. Mashup
  33. 33. OSC-Do blog
  34. 34. WebAPI
  35. 35. API
  36. 36. API
  37. 37. API URL
  38. 38. http://jws.jalan.net/APICommon/ OnsenSearch/V1/? key=**********&l_area=010802 &count=1&xml_ptn=1
  39. 39. XML
  40. 40. Rails
  41. 41. require 'net/http' require 'cgi' require 'rexml/document' class Onsen attr_accessor :address, :name, :id KEY = 'phe11375af71ba' URL = 'http://jws.jalan.net/APICommon/OnsenSearch/V1/?' def self.find(params) results = [] get(params).elements.each('Results/Onsen') do |el| results << Onsen.new(el.elements[quot;OnsenIDquot;].text, el.elements[quot;OnsenNamequot;].text, el.elements[quot;OnsenAddressquot;].text) end results end def self.url(params) params[:key] = KEY URI.parse(URL+((params.map { |key,value| quot;#{key}=#{CGI::escape(value.to_s)}quot;}).join('&'))) end def self.get(params) REXML::Document.new(Net::HTTP.get(url(params))) end def initialize(id, name, address) @id, @name, @address = id, name, address end end
  42. 42. API
  43. 43. Web
  44. 44. irb> puts Onsen.find(:count => 10, :pref => '170000').map{|o| o.name}.join(',') => , , , , , , , , , ( )
  45. 45. Google Map
  46. 46. Ruby
  47. 47. YM4R/GM
  48. 48. GoogleMaps API Rails
  49. 49. $ rails onsen -d sqlite3 $ cd onsen $ script/plugin install svn://rubyforge.org/var/svn/ym4r/Plugins/GM/trunk/ym4r_gm $ ./script/generate controller onsen index
  50. 50. Onsen lib/onsen.rb
  51. 51. class OnsenController < ApplicationController def index @map = GMap.new(quot;map_divquot;) @map.control_init :large_map => true, :map_type => true @map.center_zoom_init([37.60988,138.872681], 10) end end
  52. 52. <html> <head> <%= GMap.header %> <%= @map.to_html %> </head> <body> <%= @map.div(:width => 600, :height => 400) %> </body> </html>
  53. 53. Google Maps
  54. 54. API
  55. 55. Google Maps API
  56. 56. YM4R/GM
  57. 57. irb> nigata = Geocoding.get(‘ ’) irb> nigata.first.latlon => [37.912016, 139.061847]
  58. 58. Onsen
  59. 59. class Onsen def latlon Geocoding.get(@address).first.latlon end end
  60. 60. Google
  61. 61. class Onsen def latlon Geocoding.get(@address.gsub(/( | | ).{1,5} /,'¥¥1')).first.latlon end end
  62. 62. 2 API Mashup
  63. 63. class OnsenController < ApplicationController def index @map = GMap.new(quot;map_divquot;) @map.control_init(:large_map => true, :map_type => true) @map.center_zoom_init([37.60988,138.872681], 8) return Onsen.find(:count => 30, :pref => '170000').each do |o| begin marker = GMarker.new( o.latlon, :title => o.name, :info_window => render_to_string( :partial => 'point', :locals => { :onsen => o }) ) @map.overlay_init(marker) rescue end end end
  64. 64. HTML
  65. 65. <div><strong><%=h onsen.name %></strong></div> <div><%=h onsen.address %></div>
  66. 66. Flickr
  67. 67. WebAPI
  68. 68. Ruby
  69. 69. API
  70. 70. Yahoo Web
  71. 71. http://api.search.yahoo.co.jp/ ImageSearchService/V1/ imageSearch? appid=YahooDemo&results=1& query=
  72. 72. Onsen
  73. 73. class Onsen def photo Onsen.get({ :appid=>'onsen', :query=>@name.gsub(/ ¥(.*/,''), :results => 1}, quot;http://api.searc........rch?quot; ).elements['/ResultSet/Result/Thumbnail/ Url'].text end end
  74. 74. <div><strong><%=h onsen.name %></strong></div> <div><%=h onsen.address %></div> <div style=quot;height: 120pxquot;> <%= image_tag(onsen.photo) rescue 'No photo' %> </div>
  75. 75. acts_as_commentable
  76. 76. jpmobile
  77. 77. http://blog.masuidrive.jp/

×