Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Desenvolvendo Aplicativos Sociais com Rails 3

5,111 views

Published on

Palestra realizada durante o RubyConf Brasil 2010.

Published in: Technology
  • Be the first to comment

Desenvolvendo Aplicativos Sociais com Rails 3

  1. 1. Desenvolvendo Aplicativos Sociais com Rails 3 Carlos Brando quarta-feira, 27 de outubro de 2010
  2. 2. quarta-feira, 27 de outubro de 2010
  3. 3. <?xml version="1.0" encoding="UTF-8" ?> <Module>  <ModulePrefs title="Standard gadget structure">   <Require feature="opensocial-0.8"/>  </ModulePrefs>  <Content type="html">  <![CDATA[       Hello, RubyConf!  ]]>  </Content> </Module> quarta-feira, 27 de outubro de 2010
  4. 4. <?xml version="1.0" encoding="UTF-8" ?> <Module>  <ModulePrefs title="Standard gadget structure">   <Require feature="opensocial-0.8"/>  </ModulePrefs>  <Content type="html">  <![CDATA[       Hello, RubyConf!  ]]>  </Content> </Module> quarta-feira, 27 de outubro de 2010
  5. 5. <?xml version="1.0" encoding="UTF-8" ?> <Module>  <ModulePrefs title="Standard gadget structure">   <Require feature="opensocial-0.8"/>  </ModulePrefs>  <Content type="html">  <![CDATA[       Hello, RubyConf!  ]]>  </Content> </Module> quarta-feira, 27 de outubro de 2010
  6. 6. <?xml version="1.0" encoding="UTF-8" ?> <Module>  <ModulePrefs title="Standard gadget structure">   <Require feature="opensocial-0.8"/>  </ModulePrefs>  <Content type="html">  <![CDATA[       Hello, RubyConf!  ]]>  </Content> </Module> quarta-feira, 27 de outubro de 2010
  7. 7. <?xml version="1.0" encoding="UTF-8" ?> <Module>  <ModulePrefs title="Standard gadget structure">   <Require feature="opensocial-0.8"/>  </ModulePrefs>  <Content type="html">  <![CDATA[       Hello, RubyConf!  ]]>  </Content> </Module> quarta-feira, 27 de outubro de 2010
  8. 8. <?xml version="1.0" encoding="UTF-8" ?> <Module>  <ModulePrefs title="Standard gadget structure">   <Require feature="opensocial-0.8"/>  </ModulePrefs>  <Content type="html">  <![CDATA[       Hello, RubyConf!  ]]>  </Content> </Module> quarta-feira, 27 de outubro de 2010
  9. 9. quarta-feira, 27 de outubro de 2010
  10. 10. Profiles quarta-feira, 27 de outubro de 2010
  11. 11. JS var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.send(fetchPersonHandler); function fetchPersonHandler(data) { var owner = data.get('owner').getData(); alert(owner.getDisplayName()); }; quarta-feira, 27 de outubro de 2010
  12. 12. REST require 'oauth' require 'json' uri = URI.parse "http://sandbox.orkut.com/social/rest/people/#{orkut_uid}/@self?xoauth_requestor_id=#{orkut_uid}" http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.request_uri) consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET) req.oauth!(http, consumer, nil, :scheme => 'query_string') resp = http.get(req.path) JSON.parse(resp.body) quarta-feira, 27 de outubro de 2010
  13. 13. Friends quarta-feira, 27 de outubro de 2010
  14. 14. JS var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); var viewerFriends = opensocial.newIdSpec({ "userId" : "VIEWER", "groupId" : "FRIENDS" }); req.add(req.newFetchPeopleRequest(viewerFriends, {}), 'viewerFriends'); req.send(onLoadFriends); quarta-feira, 27 de outubro de 2010
  15. 15. REST http://sandbox.orkut.com/social/rest/people/#{orkut_uid}/@all?xoauth_requestor_id=#{orkut_uid}&count=9999 quarta-feira, 27 de outubro de 2010
  16. 16. Activities quarta-feira, 27 de outubro de 2010
  17. 17. JS function sendMessage(messageTitle, messageBody, friend) { var params = []; params[opensocial.Message.Field.TITLE] = messageTitle; params[opensocial.Message.Field.TYPE] = opensocial.Message.Type.EMAIL; var message = opensocial.newMessage(messageBody, params); opensocial.requestSendMessage(friend, message, function() {}); } quarta-feira, 27 de outubro de 2010
  18. 18. REST quarta-feira, 27 de outubro de 2010
  19. 19. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  20. 20. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  21. 21. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  22. 22. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  23. 23. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  24. 24. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  25. 25. function loadInitialData() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("OWNER"), "owner"); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(function(dataResponse) { var owner = dataResponse.get('owner').getData(); var viewer = dataResponse.get('viewer').getData(); OWNER_ID = owner.getId(); VIEWER_ID = viewer.getId(); HOST_WITH_PORT = $('#host_with_port').val(); sendRequest('/speakers', {}, '#speakers'); }); } gadgets.util.registerOnLoadHandler(loadInitialData); quarta-feira, 27 de outubro de 2010
  26. 26. function sendRequest(path, options, element) { var querystring = '?owner_id=' + OWNER_ID + '&viewer_id=' + VIEWER_ID; if (options) { $.each(options, function(index, val) { querystring = querystring + '&' + index + '=' + val; }); }; var url = HOST_WITH_PORT + '/opensocial' + path + querystring; var params = {}; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; makeCachedRequest(encodeURI(url), function(result) { $(element).html(result.text); gadgets.window.adjustHeight(); }, params, 0); } quarta-feira, 27 de outubro de 2010
  27. 27. function sendRequest(path, options, element) { var querystring = '?owner_id=' + OWNER_ID + '&viewer_id=' + VIEWER_ID; if (options) { $.each(options, function(index, val) { querystring = querystring + '&' + index + '=' + val; }); }; var url = HOST_WITH_PORT + '/opensocial' + path + querystring; var params = {}; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; makeCachedRequest(encodeURI(url), function(result) { $(element).html(result.text); gadgets.window.adjustHeight(); }, params, 0); } quarta-feira, 27 de outubro de 2010
  28. 28. function sendRequest(path, options, element) { var querystring = '?owner_id=' + OWNER_ID + '&viewer_id=' + VIEWER_ID; if (options) { $.each(options, function(index, val) { querystring = querystring + '&' + index + '=' + val; }); }; var url = HOST_WITH_PORT + '/opensocial' + path + querystring; var params = {}; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; makeCachedRequest(encodeURI(url), function(result) { $(element).html(result.text); gadgets.window.adjustHeight(); }, params, 0); } quarta-feira, 27 de outubro de 2010
  29. 29. function sendRequest(path, options, element) { var querystring = '?owner_id=' + OWNER_ID + '&viewer_id=' + VIEWER_ID; if (options) { $.each(options, function(index, val) { querystring = querystring + '&' + index + '=' + val; }); }; var url = HOST_WITH_PORT + '/opensocial' + path + querystring; var params = {}; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; makeCachedRequest(encodeURI(url), function(result) { $(element).html(result.text); gadgets.window.adjustHeight(); }, params, 0); } quarta-feira, 27 de outubro de 2010
  30. 30. function sendRequest(path, options, element) { var querystring = '?owner_id=' + OWNER_ID + '&viewer_id=' + VIEWER_ID; if (options) { $.each(options, function(index, val) { querystring = querystring + '&' + index + '=' + val; }); }; var url = HOST_WITH_PORT + '/opensocial' + path + querystring; var params = {}; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; makeCachedRequest(encodeURI(url), function(result) { $(element).html(result.text); gadgets.window.adjustHeight(); }, params, 0); } quarta-feira, 27 de outubro de 2010
  31. 31. function sendRequest(path, options, element) { var querystring = '?owner_id=' + OWNER_ID + '&viewer_id=' + VIEWER_ID; if (options) { $.each(options, function(index, val) { querystring = querystring + '&' + index + '=' + val; }); }; var url = HOST_WITH_PORT + '/opensocial' + path + querystring; var params = {}; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; makeCachedRequest(encodeURI(url), function(result) { $(element).html(result.text); gadgets.window.adjustHeight(); }, params, 0); } quarta-feira, 27 de outubro de 2010
  32. 32. @carlosbrando www.nomedojogo.com quarta-feira, 27 de outubro de 2010

×