Skip to content

Commit

Permalink
Added timestamps to programs
Browse files Browse the repository at this point in the history
Display timestamps on the program page, and output program titles
with '.titleize'
  • Loading branch information
dominic committed Dec 29, 2011
1 parent d11de37 commit c4374a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 2 additions & 3 deletions app/assets/stylesheets/programs.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
}

.author {
a {
font-style: italic;
color: lighten($text-color, 20%);
a, & {
color: lighten($text-color, 40%);
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions app/helpers/programs_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
module ProgramsHelper
# def program_link program_name, program_slug, username
# "#{link_to(program_name, user_program_path(username, program_slug))} by #{link_to(username, user_path(username))}".html_safe
# end
def program_link program
"#{link_to(program.title, user_program_path(program.author_username, program))}".html_safe
"#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe
end

def author_link username
"#{link_to(username, user_path(username))}".html_safe
def author_link username, program = nil
output = ""
output += link_to(username, user_path(username))

if program
output += ", #{program.created_at.strftime('%m/%d/%y')}" unless program.created_at.nil?
end

output.html_safe
end
end
1 change: 1 addition & 0 deletions app/models/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Program
key :title, String
key :source_code, String
key :featured, Boolean
timestamps!

scope :by_username, lambda { |username| where(:author_username => username) }
scope :featured, where(:featured => true)
Expand Down
4 changes: 2 additions & 2 deletions app/views/programs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- @featured.each do |program|
%li
.title= program_link program
.author= author_link program.author_username
.author= author_link program.author_username, program

#all-programs.programs
.heading
Expand All @@ -22,4 +22,4 @@
- @programs.each do |program|
%li
.title= program_link program
.author= author_link program.author_username
.author= author_link program.author_username, program

0 comments on commit c4374a7

Please sign in to comment.