Skip to content

Timestamp WIP#155 #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ gem 'sanitize'
gem 'simple_form'
gem 'tweet-button'
gem 'mail_view'
gem 'local_time'

# Mongo
gem 'mongoid'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -745,6 +747,7 @@ DEPENDENCIES
launchy
letter_opener!
linkedin
local_time
mail
mail_view
memcachier
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/protips.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 10 additions & 2 deletions app/assets/stylesheets/protip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -623,6 +622,7 @@ body.protip-single {
//share-this-tip

.tip-header {
position: relative;
max-width: inherit;
.tip-title {
width: 75%;
Expand All @@ -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 {
Expand Down Expand Up @@ -758,6 +765,7 @@ body.protip-single {

.tip-content {
max-width: inherit;
margin-top: 20px;

.links {
float: right;
Expand Down
7 changes: 5 additions & 2 deletions app/views/protips/_protip.html.haml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down
133 changes: 6 additions & 127 deletions app/views/protips/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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}