Skip to content

Commit c4374a7

Browse files
committed
Added timestamps to programs
Display timestamps on the program page, and output program titles with '.titleize'
1 parent d11de37 commit c4374a7

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

app/assets/stylesheets/programs.css.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
}
3939

4040
.author {
41-
a {
42-
font-style: italic;
43-
color: lighten($text-color, 20%);
41+
a, & {
42+
color: lighten($text-color, 40%);
4443
}
4544
}
4645
}

app/helpers/programs_helper.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module ProgramsHelper
2-
# def program_link program_name, program_slug, username
3-
# "#{link_to(program_name, user_program_path(username, program_slug))} by #{link_to(username, user_path(username))}".html_safe
4-
# end
52
def program_link program
6-
"#{link_to(program.title, user_program_path(program.author_username, program))}".html_safe
3+
"#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe
74
end
85

9-
def author_link username
10-
"#{link_to(username, user_path(username))}".html_safe
6+
def author_link username, program = nil
7+
output = ""
8+
output += link_to(username, user_path(username))
9+
10+
if program
11+
output += ", #{program.created_at.strftime('%m/%d/%y')}" unless program.created_at.nil?
12+
end
13+
14+
output.html_safe
1115
end
1216
end

app/models/program.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Program
66
key :title, String
77
key :source_code, String
88
key :featured, Boolean
9+
timestamps!
910

1011
scope :by_username, lambda { |username| where(:author_username => username) }
1112
scope :featured, where(:featured => true)

app/views/programs/index.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- @featured.each do |program|
1212
%li
1313
.title= program_link program
14-
.author= author_link program.author_username
14+
.author= author_link program.author_username, program
1515

1616
#all-programs.programs
1717
.heading
@@ -22,4 +22,4 @@
2222
- @programs.each do |program|
2323
%li
2424
.title= program_link program
25-
.author= author_link program.author_username
25+
.author= author_link program.author_username, program

0 commit comments

Comments
 (0)