software is not everything in life – championships in faltauno.com “Copa CUTI” 1

Posted by Martin Cabrera on July 07, 2009

logo

Hello everyone … in moove-iT we develop and management faltauno.com.
It is a social network specializes in organizing matches, managing a team and administer and manage a championship.

On August 1 begins the first championship was organized by faltauno.com “Copa CUTI” (www.cuti.org.uy).
This championship brings together all the software companies of uruguay.

We invite everyone to visit and see what are the best !

[Post to Twitter] Tweet This Post 

Using Facebooker to make a Rails site with Facebook Connect (Part 3) 3

Posted by Augusto Guido on May 25, 2009

Welcome to part 3 of the facebooker trilogy

I’m kind of tyred of writing the same title over and over again and changing just the last number, problem is there are so many things we can do with this stuff we could write tons of this. I could put in the title what we will talk about specifically in this post, but the idea is to follow this post/tutorials in order. This will probably be the last part of this set of posts, the following ones will refer in it’s specifically to what will be done.

So far we explained how to configure facebooker, sign up, invite friends and bit of the theory. So today we’ll publish something in the users dashboard, so him and all his friends can see it his wall. So go to
developers.facebook.com/tools.php and select “Feed Template Console”, select the application you want and click next.

Give me a minute to explain you what we are doing.

We are going to register our feeds in facebook, and then we are going to call them by a number they will give us.
You can do this using facebooker, or you can register them in the link I gave you above. I think that using the facebook tools is way easier and also facebooker may be a bit out of date regarding this area due to all the legal and business changes in facebook. Also not event facebook has yet clear what they want: “At this time, the policy on automatically publishing one line stories has not been finalized”.

Anyway, complete the step guide for feeds in facebook and keep the number of the template you created. BTW while completing it you will find this kind of stuff “{*actor*}” without quotes. These are tokens that allow to put variable stuff (like names, links, etc.), you can read about them while creating the templates since they are well explained over there.

Now, you have the story. You need the users approval to publish it, so what facebook does is shows the story to the user and gives him otions to skip or publish. If we are in luck the users hits “publish”.

So we now obviously want to show it to the user so he can choose. Here’s the code

FB.ensureInit(function() {
var body_general = "Join them in my facebook connect site"
var template_data =
{
"actor":  "<%= @_logged_user.name %>",
"friends":"<%= @event.users.collect{|u| u.name_or_alias}.join(', ') %>",
"event":  "<%= @event.description %>",
"place":  "<%= @event.place %>",
"time" :  "<%= @event.start.strftime('%m/%d/%Y %I:%M %p') %>"
};
var user_message_prompt = "<%= @match.comment %>";
FB.Connect.showFeedDialog('the_number_of_your_template', template_data, [], body_general, null, FB.RequireConnect.require, FB.RequireConnect.promptConnect, user_message_prompt);
});

In the template data you have to complete the tokens you created when publishing your story. You can everything pretty well explained in this couple of links:

http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Connect.ShowFeedDialog
http://wiki.developers.facebook.com/index.php/Feed.publishUserAction
http://wiki.developers.facebook.com/index.php/Publishing_Feed_Stories_to_Facebook

Pay attention to the “FB.ensureInit(function(){”, I don’t know why I couldn’t find anywhere in facebook that mention this should be there. If you don’t add this nothing will happen, maybe it’s obvios for some people, but it wasn’t for me. I’m sory I can’t remember where I find this, but you can read here what it does.

Well, that’s kind of the big picture of what you have to do to publish stories, remember this isn’t supposed to be a complete tutorial of everything you can do, just a guide based on my personal experience to get started.

Your facebook connect site should be quite complete now that you can signup, invite your friends and write stuff that will appear directly in facebook. Not to mention if you have used all the other resources facebook give us and facebooker facilitate us.

Thanks for reading!

[Post to Twitter] Tweet This Post 

Using Facebooker to make a Rails site with Facebook Connect (Part 2)

Posted by Augusto Guido on April 29, 2009

Hey, thanks for coming back for part 2. I know it took some time to start writing this second part, it’s just that facebook keeps getting better and keeps taking my time away (don’t tell Conrado).

If I remember correctly in Part 1 we ended up with facebooker installed, configured and running. We even added the facebook connect button and explained how to use some of the great facebooker helpers. As promised in my last post we are going to explain a bit how the magic happens with XFBML, invite friends and publish feed items.

XFBML

Facebook uses XFBML as a way for you to incorporate FBML (Facebook Markup Language, an extension to HTML) into an HTML page on a Facebook Connect site or an iframe application. read more here.

This is a typical XFBML tag, it brings up the profile picture of the user with the uid=”12345″.

<fb:profile-pic uid="12345" facebook-logo="true" linked="false" width="300" height="400"></fb:profile-pic>

What’s happening here? Facebook is turning this into a typicall HTML <img> tag. They do this using a Javascript cross-domain communications library. You can read more here if you are interested. This is all done for you when using Facebooker.

Boring right? Let’s invite some friends to our connect site to keep things more interesting.

Inviting Friends

If you went through the facebooker helpers you are probably thinking about using fb_multi_friend_selector to select friends. Well you are right! We’ll be using that helper, but we will need it inside another helper that is fb_request_form. There’s also another helper that could help us that is fb_multi_friend_request, which is basically the first two together, but we are going to use the first option. Here’s the resulting code:

<% fb_serverfbml do %>
<script type="text/fbml">
<fb:fbml>
<% content_for("invite_user") do %>
<%= "Check out my brand new FB Connect site.  Lots of good stuff in there! #{fb_req_choice('Check it out!', login_users_url)}" %>
<% end %>
<% fb_request_form("GetUnbored","invite_user", login_users_url) do %>
<%= fb_multi_friend_selector("Invite your friends to check out this site", :showborder => true,
:exclude_ids => facebook_session.user.friends_with_this_app.map(&:id).join(","), :condensed => false) %>
<% end %>
</fb:fbml>
</script>
<% end %>

I don’t want to explain something that’s already out there in many places, I will just describe a bit what’s going on. We put things inside a fb_serverfbml, because we are in a facebook connect site and need users interaction with facebook directly (that is when selecting their friends). The content_for(”invite_user”) is the content that will be show in the fb_request_form. The fb_request_form is a facebook form used when we need to submit information to facebook.

And the fb_multi_friend_selector is the nice facebook like friend selector. You can choose condensed => true to show an ugly smaller one. The exclude_ids => facebook_session.user.friends_with_this_app.map(&:id).join(”,”) is pretty great, it makes the friend selector not to show the friends who are already using our facebook connect site.

Anyway, you can get much more things done, here are some of the facebooker helpers to do anything you like with them ;) . And of course the facebook developers wiki is a great place for starting and becoming a guru. I will add in other post the publishing feeds part.

Enjoy!

[Post to Twitter] Tweet This Post 

Trick to improve performance in rails, less requests with static resources

Posted by Pablo Ifran on April 08, 2009

Reducing the number of request made to the server improves the performance of a web application in about 80%.

There are many techniques that allow us to reduce the amount of requests that are made on a page, among them are: the sprites, put the stylesheets on top of the page, javascripts compress, among others.

But what’s offered by Rails to improve the performance of our web application?

It offers a great plugin called bundle_fu (http://code.google.com/p/bundle-fu/)
It allows us with a single request obtain all the javascripts and with another request all the stylesheets  (it also offers the possibility of compress javascripts).
Using this plugin is really easy but it’s very powerfull

<% bundle do -%>
  <%= javascript_include_tag :default -%>
  <%= javascript_include_tag "javascript1" -%>
  <%= javascript_include_tag "javascript2" -%>
  <%= javascript_include_tag "javascript3" -%>
  <%= stylesheet_link_tag "style1" -%>
  <%= stylesheet_link_tag "style2" -%>
  <%= stylesheet_link_tag "style3" -%>
  ...
<% end %>

All these javascripts and stylesheets are converted in only two files when the request is processed.

[Post to Twitter] Tweet This Post 

moove-iT@locosxrails

Posted by Martin Cabrera on April 07, 2009

Locos x Rails is the first conference in the Southern Cone dedicated to the ground-breaking Ruby on Rails framework. Locos por Rails Conference 2009 will be held on April 3rd and 4th in Buenos Aires, Argentina. South America’s most popular travel destination is the perfect backdrop for two days of local and international presentations, networking, and fun.

Part of the moove-iT development team attended to this event. Bellow you will find some nice pictures!

See more photos on facebook group and keep the thread news at locosxrails twitter.

[Post to Twitter] Tweet This Post 

Using Facebooker to make a Rails site with Facebook Connect (Part 1) 14

Posted by Augusto Guido on April 06, 2009

I think that from the title you can pretty much guess what this post will be about, specially if you are familiar with these magic words: Rails, Facebooker, Facebook Connect. Ok they are not that magic, but you can do lots of fun stuff with them. In case you don’t live in the facebook planet I will briefly explain them, since there is a lot of info out there about them I wont get into detail. I won’t explain Rails for obvios reaons.

Facebook Connect

It’s something (who knows what and who cares anyway?) from Facebook that allows you to use your facebook login to login into other web sites.

Facebooker

It’s a gem for Ruby, and also a plugin for Rails that converts the results from the facebook API into ruby objects so you can interact with the API using just ruby.

Let the magic begin…

We want to have a site that handles users like we would normally do, except we won’t handle nor model them. We will get them from facebook. The first thing we want to do is join the developers group in facebook, go to http://www.facebook.com/developers/ and create a new application. You will then have to configure some couple of things, the main one is “Connect URL” in which you should put the url of your site like: “http://my_new_fb_app.com/”. Do not forgett the last slash, it won’t work if it’s not there (and you can spend hours trying to figure out what’s wrong). You have many other setting but we won’t get to them here.

As an advice, you may want to create two apps so that you can have one for development and one for production. the development one for example can point to http://localhost:3000/

Other thing you may see is that facebook gives you some strange numbers after you create your app, now is when we start with facebooker. Follow this tutorial until point 5, we won’t care too much for the other stuff, but you can read it. I want you to know how to install facebooker (and to actually do it),  and then generate and complete the facebooker.yml file.

Now what?

After you have that completed the first thing we wan’t is to show this little pretty blue button  facebook connect. This is the login button, and when you click it a pop up from facebook asking your password and email should appear. So, let’s make that happen.

Add this to your application controller

before_filter :set_facebook_session
helper_method :facebook_session

Add the followng lines to one of your views (typically a login page)

<%= fb_connect_javascript_tag %>
<%= init_fb_connect "XFBML"%>
<%= fb_login_and_redirect(facebook_login_users_path) %>

Now you should be seeing the button after you refresh. The facebook_login_users_path is the url you want to redirect your users after they login. As usual in Rails facebook_login is the action and users the controller.

After the user logges in you will have a facebook_session variable abailable to do almost whatever you want. For example you can:

facebook_session.user, this will return you the facebook user and all of it’s methods. Everything you can do with it it’s here http://facebooker.rubyforge.org/classes/Facebooker/User.html. The typicall things you may want are facebook_session.user.first_name, facebook_session.user.last_name, facebook_session.user.first_name.id (this will return an id facebook provides. You can access with it the user any other time).

Other interesting thins you can do is facebook_session.friends to get all the user friends or  facebook_session.user.friends_with_this_app will return all the users that use this application and are already your friends in facebook.

Well, that’s it for now. In part 2 we will discuss a bit about XFBML (facebook markup language) and show you how to invite friends to your app, show stories in their dashboard, etc. Also a little example of using javascript to call the Facebook API.

[Post to Twitter] Tweet This Post 

Improving the ruby Array class without degrade performance

Posted by Pablo Ifran on April 06, 2009

Improving the ruby Array class

Many times, when you are iterating over an array you want to know the last or the first element to do something. Unfortunately ruby don’t provide any method to help you doing this task.
So, if you want a trick to do this, you can add this few lines in a rails project inside an initalizer.

Put this code in initializers/array.rb

class Array

  #     array.each_with_first {|item, first| block }   ->   array
  #
  #
  # Call a block ones per element, passing
  # the element and the first element of the array as parameters.
  #
  #    a = [ "a", "b", "c" ]
  #    a.each_with_first {|x, f| print "#{x} -- #{f} | " }
  #
  # produces:
  #
  #    a -- a | b -- a | c -- a |
  #
  def each_with_first(&block)
    first = self.first

    self.each do |element|
      yield element, first
    end
  end

  #     array.each_with_last {|item, last| block }   ->   array
  #
  #
  # Call a block ones per element, passing
  # the element and the last element of the array as parameters.
  #
  #    a = [ "a", "b", "c" ]
  #    a.each_with_last {|x, f| print "#{x} -- #{f} | " }
  #
  # produces:
  #
  #    a -- c | b -- c | c -- c |
  #
  def each_with_last(&block)
    last = self.last

    self.each do |element|
      yield element, last
    end
  end

  #     array.each_with_first_and_last {|item, first, last| block }   ->   array
  #
  #
  # Call a block ones per element, passing
  # the element, the first and the last element of the array as parameters.
  #
  #    a = [ "a", "b", "c" ]
  #    a.each_with_last {|x, f, l| print "#{x} -- #{f} -- #{l} | " }
  #
  # produces:
  #
  #    a -- a -- c | b -- a -- c | c -- a -- c |
  #
  def each_with_first_and_last(&block)
    first = self.first
    last = self.last

    self.each do |element|
      yield element, first, last
    end
  end

end

[Post to Twitter] Tweet This Post 


Tweet This Post links powered by Tweet This v1.3.9, a WordPress plugin for Twitter.