Carlos Brando

Nome do Jogo

Colocando links para redes sociais no seu projeto Rails

Vi esta dica no blog do Ilya Grigorik.

O código: [source:ruby] <% current_uri = u(request.protocol << request.host_with_port << request.request_uri) title = u(@title)

bookmarklets = { :delicious => [‘del.icio.us’, ‘delicious.gif’ ,’http://del.icio.us/post?url=&title=’], :digg => [‘digg it’, ‘digg.gif’, ‘http://digg.com/submit?phase=2&url=&title=’], :spurl => [‘spurl’, ‘spurl.gif’, ‘http://www.spurl.net/spurl.php?title=&url=’],

:wists => [‘wists’, ‘wists.gif’, ‘http://wists.com/r.php?c=&r=&title=’],

:simpy => [‘simpy’, ‘simpy.gif’, ‘http://www.simpy.com/simpy/LinkAdd.do?href=&title=’],

:newsvine => [‘newsvine’, ‘newsvine.gif’, ‘http://www.newsvine.com/_tools/seed&save?u=&h=’],

:blinklist => [‘blinklist’, ‘blinklist.gif’, ‘http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=&Title=’], :furl => [‘furl’, ‘furl.gif’, ‘http://www.furl.net/storeIt.jsp?u=&t=’], :reddit => [‘reddit’, ‘reddit.gif’, ‘http://reddit.com/submit?url=&title=’],

:fark => [‘fark’,’fark.gif’, ‘http://cgi.fark.com/cgi/fark/edit.pl?new_url=&new_comment=&linktype=’],

:blogmarks => [‘blogmarks’, ‘blogmarks.gif’, ‘http://blogmarks.net/my/new.php?mini=1&simple=1&url=&title=’], :yahoo => [‘yahoo’, ‘yahoo.gif’, ‘http://myweb2.search.yahoo.com/myresults/bookmarklet?u=&t=’],

:smarking => [‘smarking’, ‘smarking.gif’, ‘http://smarking.com’],

:segnalo => [‘segnalo’, ‘segnalo.gif’, ‘http://segnalo.com/post.html.php?url=&title=’],

:magnolia => [‘magnolia’, ‘magnolia.gif’, ‘http://ma.gnolia.com/bookmarklet/add?url=&title=’] }

%>

<% bookmarklets.each_value { |bookmarklet| bookmarklet[2].gsub!(/{{url}}/, current_uri) bookmarklet[2].gsub!(/({{url_encoded_title}})|({{title}})/, title) -%> <%= bookmarklet[0] %> <%= bookmarklet[0] %>

<% } %>

[/source]

Para funcionar do jeito que está, basta ter uma variável @title com o título da sua página.

Para pegar os ícones e ver o artigo original, clique aqui.

Comments