Skip to content

Commit 9ca1a1e

Browse files
committed
Merge pull request coderwall#53 from seuros/timestamp
Timestamp WIP#155
2 parents 394e9ea + 3b2e081 commit 9ca1a1e

File tree

6 files changed

+26
-131
lines changed

6 files changed

+26
-131
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ gem 'sanitize'
132132
gem 'simple_form'
133133
gem 'tweet-button'
134134
gem 'mail_view'
135+
gem 'local_time'
135136

136137
# Mongo
137138
gem 'mongoid'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ GEM
340340
celluloid (>= 0.15.2)
341341
rb-fsevent (>= 0.9.3)
342342
rb-inotify (>= 0.9)
343+
local_time (1.0.0)
344+
coffee-rails
343345
loofah (2.0.0)
344346
nokogiri (>= 1.5.9)
345347
lumberjack (1.0.9)
@@ -745,6 +747,7 @@ DEPENDENCIES
745747
launchy
746748
letter_opener!
747749
linkedin
750+
local_time
748751
mail
749752
mail_view
750753
memcachier

app/assets/javascripts/protips.js.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#= require blur
66
#= require jquery.filedrop
77
#= require vendor/jquery.textselection
8+
#= require local_time
89

910
window.handle_redirect = (response)->
1011
window.location = response.to if (response.status == "redirect")

app/assets/stylesheets/protip.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ body.protip-single {
562562
color: #757575;
563563
background: #e6e6e6;
564564
text-align: center;
565-
padding: 0;
566565
height: 25px;
567566
line-height: 25px;
568567
@include border-radius(4px);
@@ -623,6 +622,7 @@ body.protip-single {
623622
//share-this-tip
624623

625624
.tip-header {
625+
position: relative;
626626
max-width: inherit;
627627
.tip-title {
628628
width: 75%;
@@ -635,7 +635,14 @@ body.protip-single {
635635
color: #333;
636636
}
637637
}
638-
//h1
638+
//TODO fix this
639+
.timestamp {
640+
position:absolute;
641+
right: 9px;
642+
bottom: -29px;
643+
font-size: 1.1em;
644+
color: #a2a2a2;
645+
}
639646
}
640647

641648
.views {
@@ -758,6 +765,7 @@ body.protip-single {
758765

759766
.tip-content {
760767
max-width: inherit;
768+
margin-top: 20px;
761769

762770
.links {
763771
float: right;

app/views/protips/_protip.html.haml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.inside.cf.x-protip-pane
2-
//.blur-screen
32
.tip-container.cf.x-protip-content.protip-single#x-protip{:class => mode}
43
%aside.tip-sidebar
54
.user-box
@@ -92,13 +91,17 @@
9291
- if is_admin?
9392
=link_to 'delete', delete_tag_protip_path(protip.public_id, CGI.escape(tag)), :method => :post, :class => "delete"
9493

94+
//Time stamp
95+
%div.timestamp.cf
96+
= local_time_ago(protip.created_at)
97+
9598
- if is_admin?
9699
%ul.admin-tag-links.cf
97100
%li=link_to 'flag', flag_protip_path(protip), :method => :post, :remote => true, :class => (protip.flagged? ? 'flagged' : "") + " flag"
98101
%li=link_to 'feature', feature_protip_path(protip), :method => :post, :remote => true, :class => (protip.featured? ? 'featured' : "") + " feature"
99102
%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?")
100103

101-
//.tip-body.tip-content
104+
%hr
102105
%div.tip-content
103106
=raw sanitize(protip.to_html)
104107

app/views/protips/show.html.haml

Lines changed: 6 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -20,130 +20,9 @@
2020
-content_for :mixpanel do
2121
=record_event("viewed protip", :featured => @protip.featured, :distinction => @protip.best_stat[0])
2222

23-
-if params[:old] == 'true'
24-
%article{:id => @protip.public_id}
25-
-unless signed_in?
26-
=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')
27-
%header.cf
28-
-if !signed_in?
29-
.side-conversion-alert.hide
30-
%p Where developers come to connect, share, build and be inspired.
31-
%a.convert-signup.track{:href => '/', 'data-action' => 'view homepage', 'data-from' => 'convert button on protip'} Join Coderwall
32-
=image_tag(users_image_path(@protip.user), :class => 'avatar')
33-
%ul.who-and-when
34-
%li
35-
%h2
36-
%a.track{:href => profile_path(@protip.user.username), 'data-action' => 'view user profile', 'data-from' => 'protip author name on top'}
37-
= @protip.user.display_name
38-
- if is_admin? or viewing_self? or @protip.total_views > 100
39-
%li.views
40-
= @protip.total_views
41-
Views
42-
=share_on_twitter(@protip)
43-
.tip-content
44-
-#.hide=text_area_tag :protip_markdown, escape_scripts(@protip.body)
45-
%h1.tip-title=sanitize(@protip.title)
46-
%ul#tags.tags.cf
47-
- @protip.topics.each_with_index do |tag, index|
48-
%li
49-
%a{:href => "/p/t/#{tag.parameterize}"}
50-
= tag
51-
- if is_admin?
52-
=link_to 'delete', delete_tag_protip_path(@protip.public_id, CGI.escape(tag)), :method => :post, :class => "delete"
53-
- if is_admin? && @protip.orphan?
54-
%li.orphan Orphan
55-
.tip-body
56-
#body=sanitize(formatted_protip(@protip))
57-
- if is_admin?
58-
%ul.admin-links
59-
%li
60-
=link_to '', flag_protip_path(@protip), :method => :post, :remote => true, :class => (@protip.flagged? ? 'flagged' : "") + " flag"
61-
%li
62-
=link_to '', queue_protip_path(@protip, :queue => 'hackernews'), :method => :post, :remote => true, :class => (@protip.queued_for?(:hackernews) ? 'queued' : "") + " queue"
63-
%li
64-
=link_to '', feature_protip_path(@protip), :method => :post, :remote => true, :class => (@protip.featured? ? 'featured' : "") + " feature"
65-
%li
66-
%p.reviewed
67-
=protip_reviewer(@protip)
68-
69-
-if is_admin? or (signed_in? && @protip.owned_by?(current_user))
70-
%a.add-tag{:href => edit_protip_path(@protip.public_id)} Edit Protip
71-
= upvote_link(@protip, "upvote")
72-
- authors_team = @job && @protip.author.belongs_to_team?(@job.team)
73-
74-
-if @protip.user.about.blank?
75-
%footer.about-footer.no-about.cf
76-
%ul.links.cf
77-
%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)')
78-
%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)')
79-
%li
80-
- follow = follow_or_following(@protip.user)
81-
=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)'
82-
-else
83-
%footer.about-footer.cf
84-
.about
85-
%h4==About #{@protip.user.short_name}
86-
%p
87-
=@protip.user.about
88-
-if @protip.user.team
89-
Member of team
90-
=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)
91-
%ul.links.cf
92-
%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)')
93-
%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)')
94-
%li
95-
- follow = follow_or_following(@protip.user)
96-
=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)'
97-
- if @job
98-
.work-for-wrap
99-
.works-for.cf
100-
.left
101-
%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}
102-
=image_tag(@job.team.avatar_url)
103-
.right
104-
%p
105-
- if authors_team
106-
= @protip.author.short_name
107-
works for
108-
%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}
109-
= @protip.user.team.name
110-
==– want to join them as a
111-
= succeed "?" do
112-
%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}
113-
=@job.title
114-
- else
115-
- adjective = ["is amazing", "is awesome", "has a great engineering team"].sample
116-
Calling all
117-
== #{@job.title.pluralize}.
118-
%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}
119-
= @job.team.name
120-
= adjective
121-
and is
122-
%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}
123-
hiring
124-
125-
-if !@next_protip.nil?
126-
-next_protip = Protip::SearchWrapper.new(@next_protip)
127-
128-
%a.main-link.track{:href => protip_or_link_path(next_protip), 'data-action' => 'next protip', 'data-from' => 'protip', 'data-properties' => {'mobile' => false}.to_json}
129-
%article.next-tip{:class => dom_class(next_protip), :id => next_protip.public_id}
130-
131-
%section.comments
132-
%h2.comments-header Comments
133-
%ul.comment-list
134-
= render @comments
135-
136-
= render 'comments/add_comment'
137-
138-
139-
- if !next_protip.nil? and mobile_device?
140-
%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}
141-
Next pro tip
142-
143-
-else
144-
#x-active-preview-pane
145-
-if !signed_in?
146-
.side-conversion-alert.hide
147-
%p Where developers come to connect, share, build and be inspired.
148-
%a.convert-signup.track{:href => '/', 'data-action' => 'view homepage', 'data-from' => 'convert button on protip'} Join Coderwall
149-
=render :partial => 'cacheable_protip', :locals => {:protip => @protip, :mode => 'fullpage', :include_comments => true, :job => @job}
23+
#x-active-preview-pane
24+
-unless signed_in?
25+
.side-conversion-alert.hide
26+
%p Where developers come to connect, share, build and be inspired.
27+
%a.convert-signup.track{:href => '/', 'data-action' => 'view homepage', 'data-from' => 'convert button on protip'} Join Coderwall
28+
=render :partial => 'cacheable_protip', :locals => {:protip => @protip, :mode => 'fullpage', :include_comments => true, :job => @job}

0 commit comments

Comments
 (0)