Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fixing issue 7 using escapeHTML method #45

Merged
merged 1 commit into from

2 participants

Juan Gallego IV Raimond Garcia
Juan Gallego IV

the twitter widget adds an url so I removed the url from ShareHelper#share_text to remove the duplicity
added some tests

Juan Gallego IV nickel fixing issue 7 using escapeHTML method
the twitter widget adds an url so I removed the url from ShareHelper#share_text to remove the duplicity
added some tests
c44fb2c
Raimond Garcia voodoorai2000 merged commit f86daab into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 22, 2011
  1. Juan Gallego IV

    fixing issue 7 using escapeHTML method

    nickel authored
    the twitter widget adds an url so I removed the url from ShareHelper#share_text to remove the duplicity
    added some tests
This page is out of date. Refresh to see the latest.
10 app/helpers/share_helper.rb
View
@@ -6,19 +6,19 @@ def image_url(source)
end
abs_path
end
-
- def share_text(proposal)
- t(:share_text, :url => proposal_url(proposal))
+
+ def share_text
+ t(:share_text)
end
def share_on_facebook_link(proposal)
- %{<iframe src="http://www.facebook.com/plugins/like.php?href=#{CGI.escape(proposal_url(proposal))}&locale=es_ES&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=recommend&amp;font=arial&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true" name="fb-share"></iframe>
+ %{<iframe src="http://www.facebook.com/plugins/like.php?href=#{CGI.escapeHTML(proposal_url(proposal))}&locale=es_ES&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=recommend&amp;font=arial&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true" name="fb-share"></iframe>
}.html_safe
end
def share_on_twitter_link(proposal)
%{<iframe allowtransparency="true" frameborder="0" scrolling="no"
- src="http://platform.twitter.com/widgets/tweet_button.html?url=#{CGI.escape(proposal_url(proposal))}&via=#{CGI.escape("pdi: El Partido de Internet")}&text=#{CGI.escape(share_text(proposal))}&lang=es&count=horizontal"
+ src="http://platform.twitter.com/widgets/tweet_button.html?url=#{CGI.escapeHTML(proposal_url(proposal))}&via=#{CGI.escapeHTML("pdi: El Partido de Internet")}&text=#{CGI.escapeHTML(share_text)}&lang=es&count=horizontal"
style="width:130px; height:50px;" name="twitter-share"></iframe>
}.html_safe
end
2  config/locales/es.yml
View
@@ -35,7 +35,7 @@
proposals_by: "Propuestas presentadas por %{proposer}"
closed: "El periodo de votación para esta propuesta finalizó el %{date}"
congress_resolution_html: 'La Propuesta fue <span class="official_resolution">%{resolution}</span> en el Congreso.'
- share_text: "He votado a través del partido del internet la propuesta %{url}"
+ share_text: "He votado a través del partido del internet la propuesta"
official_link: 'Enlace oficial'
votes: 'votos'
views: 'visitas'
18 spec/helpers/share_helper_spec.rb
View
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe ShareHelper do
+ include ShareHelper
+
+ it "should provide an iframe to share with facebook" do
+ proposal = create_proposal
+ share_on_facebook_link(proposal).should be_include(proposal_url(proposal))
+ end
+
+ it "should provide an iframe to share with twitter" do
+ proposal = create_proposal
+ link = share_on_twitter_link(proposal)
+
+ link.should be_include(share_text)
+ link.should be_include(proposal_url(proposal))
+ end
+end
Something went wrong with that request. Please try again.