diff --git a/Gemfile b/Gemfile index 0d99b200..c480ee1a 100644 --- a/Gemfile +++ b/Gemfile @@ -132,6 +132,7 @@ gem 'sanitize' gem 'simple_form' gem 'tweet-button' gem 'mail_view' +gem 'local_time' # Mongo gem 'mongoid' diff --git a/Gemfile.lock b/Gemfile.lock index 5db75257..3066c30c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -340,6 +340,8 @@ GEM celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) + local_time (1.0.0) + coffee-rails loofah (2.0.0) nokogiri (>= 1.5.9) lumberjack (1.0.9) @@ -745,6 +747,7 @@ DEPENDENCIES launchy letter_opener! linkedin + local_time mail mail_view memcachier diff --git a/app/assets/javascripts/protips.js.coffee b/app/assets/javascripts/protips.js.coffee index bed8c0fd..10e8dcec 100644 --- a/app/assets/javascripts/protips.js.coffee +++ b/app/assets/javascripts/protips.js.coffee @@ -5,6 +5,7 @@ #= require blur #= require jquery.filedrop #= require vendor/jquery.textselection +#= require local_time window.handle_redirect = (response)-> window.location = response.to if (response.status == "redirect") diff --git a/app/assets/stylesheets/protip.scss b/app/assets/stylesheets/protip.scss index 444c5637..2d37ea57 100644 --- a/app/assets/stylesheets/protip.scss +++ b/app/assets/stylesheets/protip.scss @@ -562,7 +562,6 @@ body.protip-single { color: #757575; background: #e6e6e6; text-align: center; - padding: 0; height: 25px; line-height: 25px; @include border-radius(4px); @@ -623,6 +622,7 @@ body.protip-single { //share-this-tip .tip-header { + position: relative; max-width: inherit; .tip-title { width: 75%; @@ -635,7 +635,14 @@ body.protip-single { color: #333; } } - //h1 + //TODO fix this + .timestamp { + position:absolute; + right: 9px; + bottom: -29px; + font-size: 1.1em; + color: #a2a2a2; + } } .views { @@ -758,6 +765,7 @@ body.protip-single { .tip-content { max-width: inherit; + margin-top: 20px; .links { float: right; diff --git a/app/views/protips/_protip.html.haml b/app/views/protips/_protip.html.haml index 87739bd2..4a3b839f 100644 --- a/app/views/protips/_protip.html.haml +++ b/app/views/protips/_protip.html.haml @@ -1,5 +1,4 @@ .inside.cf.x-protip-pane - //.blur-screen .tip-container.cf.x-protip-content.protip-single#x-protip{:class => mode} %aside.tip-sidebar .user-box @@ -92,13 +91,17 @@ - if is_admin? =link_to 'delete', delete_tag_protip_path(protip.public_id, CGI.escape(tag)), :method => :post, :class => "delete" + //Time stamp + %div.timestamp.cf + = local_time_ago(protip.created_at) + - if is_admin? %ul.admin-tag-links.cf %li=link_to 'flag', flag_protip_path(protip), :method => :post, :remote => true, :class => (protip.flagged? ? 'flagged' : "") + " flag" %li=link_to 'feature', feature_protip_path(protip), :method => :post, :remote => true, :class => (protip.featured? ? 'featured' : "") + " feature" %li=link_to('delete', protip_path(protip.public_id), :method => :delete, :class => 'delete-tip del', :rel => 'nofollow', :title => 'remove protip', :confirm => "Are you sure you permanently want to remove this pro tip?") - //.tip-body.tip-content + %hr %div.tip-content =raw sanitize(protip.to_html) diff --git a/app/views/protips/show.html.haml b/app/views/protips/show.html.haml index 347f56d6..73298a69 100644 --- a/app/views/protips/show.html.haml +++ b/app/views/protips/show.html.haml @@ -20,130 +20,9 @@ -content_for :mixpanel do =record_event("viewed protip", :featured => @protip.featured, :distinction => @protip.best_stat[0]) --if params[:old] == 'true' - %article{:id => @protip.public_id} - -unless signed_in? - =link_to('upvote', upvote_protip_path(@protip.public_id), :remote => true, :method => :post, :rel => "nofollow", :class => 'track slide-signup', 'data-action' => 'upvote protip', 'data-from' => 'protip ribbon') - %header.cf - -if !signed_in? - .side-conversion-alert.hide - %p Where developers come to connect, share, build and be inspired. - %a.convert-signup.track{:href => '/', 'data-action' => 'view homepage', 'data-from' => 'convert button on protip'} Join Coderwall - =image_tag(users_image_path(@protip.user), :class => 'avatar') - %ul.who-and-when - %li - %h2 - %a.track{:href => profile_path(@protip.user.username), 'data-action' => 'view user profile', 'data-from' => 'protip author name on top'} - = @protip.user.display_name - - if is_admin? or viewing_self? or @protip.total_views > 100 - %li.views - = @protip.total_views - Views - =share_on_twitter(@protip) - .tip-content - -#.hide=text_area_tag :protip_markdown, escape_scripts(@protip.body) - %h1.tip-title=sanitize(@protip.title) - %ul#tags.tags.cf - - @protip.topics.each_with_index do |tag, index| - %li - %a{:href => "/p/t/#{tag.parameterize}"} - = tag - - if is_admin? - =link_to 'delete', delete_tag_protip_path(@protip.public_id, CGI.escape(tag)), :method => :post, :class => "delete" - - if is_admin? && @protip.orphan? - %li.orphan Orphan - .tip-body - #body=sanitize(formatted_protip(@protip)) - - if is_admin? - %ul.admin-links - %li - =link_to '', flag_protip_path(@protip), :method => :post, :remote => true, :class => (@protip.flagged? ? 'flagged' : "") + " flag" - %li - =link_to '', queue_protip_path(@protip, :queue => 'hackernews'), :method => :post, :remote => true, :class => (@protip.queued_for?(:hackernews) ? 'queued' : "") + " queue" - %li - =link_to '', feature_protip_path(@protip), :method => :post, :remote => true, :class => (@protip.featured? ? 'featured' : "") + " feature" - %li - %p.reviewed - =protip_reviewer(@protip) - - -if is_admin? or (signed_in? && @protip.owned_by?(current_user)) - %a.add-tag{:href => edit_protip_path(@protip.public_id)} Edit Protip - = upvote_link(@protip, "upvote") - - authors_team = @job && @protip.author.belongs_to_team?(@job.team) - - -if @protip.user.about.blank? - %footer.about-footer.no-about.cf - %ul.links.cf - %li=link_to('View profile', profile_path(@protip.user.username), :class => 'view-profile track', 'data-action' => 'view user profile', 'data-from' => 'protip about (view profile)') - %li=link_to('View pro tips', user_protips_path(@protip.user.username), :class => 'view-protips track', 'data-action' => 'view user protips', 'data-from' => 'protip about (view pro tips)') - %li - - follow = follow_or_following(@protip.user) - =link_to "#{follow} #{@protip.user.short_name}", follow == "follow" ? follow_user_path(@protip.user.username) : '', :method => :post, :remote => true, :class => "#{follow}-user track", 'data-action' => 'follow user', 'data-from' => 'protip about (follow xxx)' - -else - %footer.about-footer.cf - .about - %h4==About #{@protip.user.short_name} - %p - =@protip.user.about - -if @protip.user.team - Member of team - =link_to(@protip.user.team.name, friendly_team_path(@protip.user.team), :class => "track", 'data-action' => 'view team', 'data-from' => 'protip job (member of team xxx)', 'data-properties' => {"author's team" => authors_team}.to_json) - %ul.links.cf - %li=link_to('View profile', profile_path(@protip.user.username), :class => 'view-profile track', 'data-action' => 'view user profile', 'data-from' => 'protip about (view profile)') - %li=link_to('View pro tips', user_protips_path(@protip.user.username), :class => 'view-protips track', 'data-action' => 'view user protips', 'data-from' => 'protip about (view pro tips)') - %li - - follow = follow_or_following(@protip.user) - =link_to "#{follow} #{@protip.user.short_name}", follow == "follow" ? follow_user_path(@protip.user.username) : '', :method => :post, :remote => true, :class => "#{follow}-user track", 'data-action' => 'follow user', 'data-from' => 'protip about (follow xxx)' - - if @job - .work-for-wrap - .works-for.cf - .left - %a.team-ava.track{:href => team_job_path(@job.team), 'data-action' => 'view team jobs', 'data-from' => 'job on protip (team avatar)', 'data-properties' => {"author's team" => authors_team}.to_json} - =image_tag(@job.team.avatar_url) - .right - %p - - if authors_team - = @protip.author.short_name - works for - %a.team.track{:href => team_job_path(@protip.author.team), 'data-action' => 'view team jobs', 'data-from' => 'job on protip (team name)', 'data-properties' => {"author's team" => authors_team}.to_json} - = @protip.user.team.name - ==– want to join them as a - = succeed "?" do - %a.position.track{:href => team_job_path(@protip.user.team), 'data-action' => 'view team jobs', 'data-from' => 'job on protip (job title)', 'data-properties' => {"author's team" => authors_team}.to_json} - =@job.title - - else - - adjective = ["is amazing", "is awesome", "has a great engineering team"].sample - Calling all - == #{@job.title.pluralize}. - %a.team.track{:href => team_job_path(@job.team), 'data-action' => 'view team jobs', 'data-from' => 'job on protip (team name)', 'data-properties' => {"author's team" => authors_team, 'adjective' => adjective}.to_json} - = @job.team.name - = adjective - and is - %a.position.track{:href => team_job_path(@job.team), 'data-action' => 'view team jobs', 'data-from' => 'job on protip (hiring)', 'data-properties' => {"author's team" => authors_team, 'adjective' => adjective}.to_json} - hiring - - -if !@next_protip.nil? - -next_protip = Protip::SearchWrapper.new(@next_protip) - - %a.main-link.track{:href => protip_or_link_path(next_protip), 'data-action' => 'next protip', 'data-from' => 'protip', 'data-properties' => {'mobile' => false}.to_json} - %article.next-tip{:class => dom_class(next_protip), :id => next_protip.public_id} - - %section.comments - %h2.comments-header Comments - %ul.comment-list - = render @comments - - = render 'comments/add_comment' - - - - if !next_protip.nil? and mobile_device? - %a.next-tip-mob.track{:href => protip_or_link_path(next_protip), 'data-action' => 'next protip', 'data-from' => 'protip', 'data-properties' => {'mobile' => true}.to_json} - Next pro tip - --else - #x-active-preview-pane - -if !signed_in? - .side-conversion-alert.hide - %p Where developers come to connect, share, build and be inspired. - %a.convert-signup.track{:href => '/', 'data-action' => 'view homepage', 'data-from' => 'convert button on protip'} Join Coderwall - =render :partial => 'cacheable_protip', :locals => {:protip => @protip, :mode => 'fullpage', :include_comments => true, :job => @job} +#x-active-preview-pane + -unless signed_in? + .side-conversion-alert.hide + %p Where developers come to connect, share, build and be inspired. + %a.convert-signup.track{:href => '/', 'data-action' => 'view homepage', 'data-from' => 'convert button on protip'} Join Coderwall + =render :partial => 'cacheable_protip', :locals => {:protip => @protip, :mode => 'fullpage', :include_comments => true, :job => @job}