Skip to content
This repository

fixing issue 7 using escapeHTML method #45

Merged
merged 1 commit into from over 2 years ago

2 participants

Juan Gallego Galisteo Raimond Garcia
Juan Gallego Galisteo

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

Juan Gallego Galisteo 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 December 02, 2011
Raimond Garcia voodoorai2000 closed this December 02, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 22, 2011
Juan Gallego Galisteo 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
This page is out of date. Refresh to see the latest.
10  app/helpers/share_helper.rb
@@ -6,19 +6,19 @@ def image_url(source)
6 6
     end
7 7
    abs_path
8 8
   end
9  
-
10  
-  def share_text(proposal)
11  
-    t(:share_text, :url => proposal_url(proposal))
  9
+  
  10
+  def share_text
  11
+    t(:share_text)
12 12
   end
13 13
 
14 14
   def share_on_facebook_link(proposal)
15  
-    %{<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>
  15
+    %{<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>
16 16
 }.html_safe
17 17
   end
18 18
 
19 19
   def share_on_twitter_link(proposal)
20 20
     %{<iframe allowtransparency="true" frameborder="0" scrolling="no"
21  
-        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"
  21
+        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"
22 22
         style="width:130px; height:50px;" name="twitter-share"></iframe>
23 23
 }.html_safe
24 24
   end
2  config/locales/es.yml
@@ -35,7 +35,7 @@
35 35
   proposals_by: "Propuestas presentadas por %{proposer}"
36 36
   closed: "El periodo de votación para esta propuesta finalizó el %{date}"
37 37
   congress_resolution_html: 'La Propuesta fue <span class="official_resolution">%{resolution}</span> en el Congreso.'
38  
-  share_text: "He votado a través del partido del internet la propuesta %{url}"
  38
+  share_text: "He votado a través del partido del internet la propuesta"
39 39
   official_link: 'Enlace oficial'
40 40
   votes: 'votos'
41 41
   views: 'visitas'
18  spec/helpers/share_helper_spec.rb
... ...
@@ -0,0 +1,18 @@
  1
+require File.dirname(__FILE__) + "/../spec_helper"
  2
+
  3
+describe ShareHelper do
  4
+  include ShareHelper
  5
+  
  6
+  it "should provide an iframe to share with facebook" do
  7
+    proposal = create_proposal
  8
+    share_on_facebook_link(proposal).should be_include(proposal_url(proposal))
  9
+  end
  10
+  
  11
+  it "should provide an iframe to share with twitter" do
  12
+    proposal = create_proposal
  13
+    link     = share_on_twitter_link(proposal)
  14
+    
  15
+    link.should be_include(share_text)    
  16
+    link.should be_include(proposal_url(proposal))
  17
+  end
  18
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.