Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

view submission tooltips

  • Loading branch information...
commit 49d0eae88d94773ad16748e75ef857aa349c2281 1 parent 7d08687
@paulanthonywilson paulanthonywilson authored
View
1  Gemfile
@@ -32,6 +32,7 @@ group :test, :development do
gem 'shoulda'
gem 'factory_girl_rails'
gem 'capistrano'
+ gem 'thin'
end
gem 'jquery-rails'
View
7 Gemfile.lock
@@ -45,7 +45,9 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
+ daemons (1.1.8)
erubis (2.7.0)
+ eventmachine (0.12.10)
execjs (1.3.0)
multi_json (~> 1.0)
factory_girl (2.6.4)
@@ -125,6 +127,10 @@ GEM
test-unit (2.4.8)
therubyracer (0.9.10)
libv8 (~> 3.3.10)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -163,6 +169,7 @@ DEPENDENCIES
sqlite3
test-unit
therubyracer
+ thin
twitter_oauth (~> 0.4.3)
uglifier (>= 1.0.3)
unicorn
View
10 app/helpers/admin/ratings_helper.rb
@@ -10,7 +10,7 @@ def proposal_reviewer_id(proposal, reviewer)
def reviewer_comment(proposal, reviewer)
rating = proposal.reviewer_proposal(reviewer)
- comment = in_paragraphs(proposal.reviewer_proposal(reviewer).comment) if rating
+ comment = markdown(proposal.reviewer_proposal(reviewer).comment) if rating
reviewer_handle = content_tag("p", content_tag("strong", "#{reviewer.twitter}:"))
tooltip(proposal_reviewer_id(proposal, reviewer), "#{reviewer_handle}#{comment}")
end
@@ -18,12 +18,16 @@ def reviewer_comment(proposal, reviewer)
def proposal_td(proposal)
proposal_id = "proposal_title_#{proposal.id}"
content = content_tag("td", link_to(proposal.title, proposal,:id=>proposal_id), :class=>'title')
- tip = tooltip(proposal_id, in_paragraphs(proposal.description))
+ tip = tooltip(proposal_id, markdown(proposal.description))
"#{content}\n#{tip}".html_safe
end
def tooltip(id, content)
- javascript_tag(%|$('##{id}').tooltip({bodyHandler:function(){ return'#{content.gsub("'", "\\\\'")}';}, showURL:false})|)
+ javascript_tag(%|$('##{id}').tooltip({bodyHandler:function(){ return'#{strip_illegal_js(content)}';}, showURL:false})|)
+ end
+
+ def strip_illegal_js(text)
+ return text.gsub("'", "’").gsub(/[\n|\u2028]/, '')
end
end
View
7 app/helpers/proposals_helper.rb
@@ -18,8 +18,13 @@ def short(text, length=50)
end
def in_paragraphs(text)
+ markdown(text).html_safe
+ end
+
+ def markdown(text)
return "" if text.blank?
- Kramdown::Document.new(text).to_html.html_safe
+ Kramdown::Document.new(text).to_html
+
end
def proposals_class(proposal)
View
12 test/unit/helpers/admin/ratings_helper_test.rb
@@ -1,11 +1,15 @@
require 'test_helper'
class Admin::RatingsHelperTest < ActionView::TestCase
-
-
+
+
test "tooltip content is quote escaped" do
content = tooltip(1, "It's great")
- assert_match /'It\\'s great'/, content
+ assert_match /'It&rsquo;s great'/, content
+ end
+
+ test "tooltip content removes whitespace" do
+ content = tooltip(1, "Hello\nma\u2028tey")
+ assert_match /Hellomatey/, content
end
-
end
View
6 test/unit/helpers/proposals_helper_test.rb
@@ -30,10 +30,10 @@ def setup
end
- test "in_paragraphs puts each line in its own escaped html paragraph" do
- assert_equal "<p>I have met them at close of&gt;day</p><p>Coming with vivid faces</p><p>From counter or desk among grey</p><p>Eighteenth-century houses.</p>",
+ test "in_paragraphs converts to markdown" do
+ assert_equal "<p>I have met them at close of&gt;day</p>\n\n<p>Coming with vivid faces</p>\n\n<p>From counter or desk among grey</p>\n\n<p>Eighteenth-century houses.</p>\n",
in_paragraphs(
- "I have met them at close of>day\nComing with vivid faces\nFrom counter or desk among grey\nEighteenth-century houses.")
+ "I have met them at close of>day\n\nComing with vivid faces\n\nFrom counter or desk among grey\n\nEighteenth-century houses.")
end
test "in paragraphs returns empty if nil" do
Please sign in to comment.
Something went wrong with that request. Please try again.