Skip to content

Commit

Permalink
Tweaked some sharing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis committed Mar 17, 2012
1 parent 2302813 commit 4cb4095
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/solutions.js.coffee
Expand Up @@ -17,3 +17,6 @@ $ ->
self.text("Reported")
$.ajax url: link, complete: (xhr, text) ->
self.delay(300).fadeOut(500)

$("#solution-share-link").click ->
$("#solution-share-link").select()
18 changes: 18 additions & 0 deletions app/assets/stylesheets/application.css.scss
Expand Up @@ -497,6 +497,9 @@ div.links {
margin: 0px;
}

#solution-share-link {
width: 330px; }

div.ad p {
background: #eee;
margin: 1em 0.5em -.25em !important;
Expand All @@ -511,3 +514,18 @@ img.gravatar {
border: 1px solid #666; }
.profile-avatar img {
margin-top: 4px }

a.twitter {
padding: 10px 0 10px 36px;
margin: 20px 0 5px;
height: 40px;
background: url(/assets/auth/twitter_32.png) no-repeat 0px 2px; }

#share {
h2 {
margin-top: 1.2em; }
h2.twitter {
margin-top: 1.4em; }
.links {
margin-top: 4em; }
}
8 changes: 4 additions & 4 deletions app/helpers/solutions_helper.rb
@@ -1,10 +1,10 @@
module SolutionsHelper

def twitter_link(problem, gist)
text = URI.escape("Check out my solution to #{problem.title} on #rubeque #{gist}")
def twitter_link(problem, paste)
url = "http://rubeque.com/problems/#{problem.id}"
text = URI.escape("Check out my solution to '#{problem.title}' (#{url}) on #rubeque: #{paste}")
link = "http://twitter.com/share?"
link += "text=#{text}"
link += "&url=#{URI.escape("http://rubeque.com/problems/#{problem.id}")}"
link_to "Tweet your solution on Twitter", link
link_to "Edit your tweet on Twitter", link, class: "twitter"
end
end
22 changes: 13 additions & 9 deletions app/views/solutions/share.html.erb
@@ -1,12 +1,16 @@
<h1>Boast a Little</h1>
<h1>Go Ahead And Boast A Little</h1>

<h2>Direct Link to Share</h2>
<p class="refheap">
<%= @paste %>
</p>
<div id="share">
<h2>Direct Link to Share</h2>
<p class="refheap">
<%= text_field_tag "share_link", @paste, id: "solution-share-link" %>
</p>

<h2>Share on Twitter</h2>
<p>Click below to visit Twitter.com where you'll be able to edit tweet and post your solution.</p>
<p><%= twitter_link(@problem, @paste) %></p><br/>
<h2 class="twitter">Share on Twitter</h2>
<p>You'll be able to edit your tweet before it's posted. Click the link below to go to Twitter.</p>
<p><%= twitter_link(@problem, @paste) %></p>

<%= link_to "Back to Problem", problem_path(@problem) %>
<div class="links">
<%= link_to "Back to Problem", problem_path(@problem) %>
</div>
</div>

0 comments on commit 4cb4095

Please sign in to comment.