Skip to content

Commit 6b770ef

Browse files
committed
More forum styling.
1 parent 6d8762a commit 6b770ef

5 files changed

Lines changed: 55 additions & 36 deletions

File tree

Rakefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ namespace :db do
4141
#make an admin user
4242
require 'models/hacker'
4343
admin = Hacker.create({
44-
:username => "admin",
45-
:email => "admin@example.com",
44+
:username => "steve",
45+
:email => "steve@steveklabnik.com",
4646
:password => "password",
4747
:password_confirmation => "password",
4848
:admin => true
@@ -90,13 +90,15 @@ Esse insolens mnesarchum eam id, nec ad detracto disputando. Nec malorum postula
9090
:title => "HALP ME!",
9191
:body => "I just don't understand!",
9292
:forum => "learning_ruby",
93-
:author => "somebody"
93+
:author => "somebody",
94+
:author_email => "somebody@example.com"
9495
})
9596

9697
#and a reply:
9798
halp.replies << Reply.new({
9899
:body => "I'd love to help you!",
99-
:author => "admin"
100+
:author => "steve",
101+
:author_email => "steve@steveklabnik.com"
100102
})
101103

102104
halp.save

controllers/forums.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
post "/forums/reply/to/:forum/:discussion" do
6262
@discussion = Discussion.first(:forum => params[:forum], :slug => params[:discussion])
6363
params[:reply][:author] = current_user.username
64+
params[:reply][:author_email] = current_user.email
6465
@discussion.replies << Reply.new(params[:reply])
6566
@discussion.save
6667

models/reply.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Reply
88

99
#the person who wrote it
1010
key :author, String
11+
key :author_email, String
1112

1213
#we need to make sure we have an author
1314
validate_on_create :author_check

views/discussions/show.haml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
%p{:style => "float:left;padding-right:1em"}
2-
%img{:src => gravatar_url_for(@discussion.author)}
2+
%img{:src => gravatar_url_for(@discussion.author)}
33
%h1= @discussion.title
44
%p{:style => "padding-bottom:1em"} By <a href="/hackers/#{@discussion.author}">#{@discussion.author}</a>
55

66
%p= @discussion.body
77

8-
%ul
9-
- @discussion.replies.each do |reply|
10-
%li #{reply.author} says: #{reply.body}
8+
%hr
9+
10+
- @discussion.replies.each do |reply|
11+
.comment{:style => "clear:both"}
12+
%div{:class => "left"}
13+
%a{:href => "/hackers/#{reply.author}"}
14+
%img{:src => gravatar_url_for(reply.author_email), :alt => "#{reply.author.downcase}_gravatar", :class => "comment_gravatar"}
15+
%div{:style => "width:500px"}
16+
%p
17+
<a href="/hackers/#{reply.author}">#{reply.author}</a> says:
18+
%p
19+
= reply.body
20+
21+
%hr
1122

1223
- unless current_user.nil?
13-
%a{ :href => "/forums/reply/to/#{@discussion.forum}/#{@discussion.slug}"} Reply
24+
%a{ :href => "/forums/reply/to/#{@discussion.forum}/#{@discussion.slug}"} Reply
25+
%br
26+
%br
1427
%a{ :href => "/forums/#{@discussion.forum}" } Back to Discussions

views/posts/show.haml

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
.post
2-
%h1= @post.title
3-
- markdown = RDiscount.new(@post.body, :smart, :filter_html)
4-
%div!= markdown.to_html
5-
%hr
6-
- @post.comments.each do |comment|
7-
.comment{:style => "clear:both"}
8-
%div{:class => "left"}
9-
%a{:href => "/hackers/#{comment.author}"}
10-
%img{:src => gravatar_url_for(comment.author_email), :alt => "#{comment.author.downcase}_gravatar", :class => "comment_gravatar"}
11-
%div{:style => "width:500px"}
12-
%p
13-
<a href="/hackers/#{comment.author}">#{comment.author}</a> says:
14-
%p
15-
= comment.body
16-
- if logged_in?
17-
%hr
18-
%form{:action => "/comments", :method => "POST"}
19-
%input{:type => "hidden", :id => "post_id", :name => "post_id", :value => @post.id}
20-
%label{:for => "comment_body"} Submit your opinion:
21-
%br
22-
%textarea{:id => "comment_body", :name => "comment[body]", :cols => 70, :rows => 5}
23-
%br
24-
%input{:type => "submit", :value => "Submit"}
25-
- else
26-
%p <a href="/login">Log in</a> to add your own commentary.
27-
%hr
28-
%a{:href => "/blog"}Back to blog
2+
%h1= @post.title
3+
- markdown = RDiscount.new(@post.body, :smart, :filter_html)
4+
%div!= markdown.to_html
5+
%hr
6+
%br
7+
- @post.comments.each do |comment|
8+
.comment{:style => "clear:both"}
9+
%div{:class => "left"}
10+
%a{:href => "/hackers/#{comment.author}"}
11+
%img{:src => gravatar_url_for(comment.author_email), :alt => "#{comment.author.downcase}_gravatar", :class => "comment_gravatar"}
12+
%div{:style => "width:500px"}
13+
%p
14+
<a href="/hackers/#{comment.author}">#{comment.author}</a> says:
15+
%p
16+
= comment.body
17+
%br
18+
- if logged_in?
19+
%hr
20+
%form{:action => "/comments", :method => "POST"}
21+
%input{:type => "hidden", :id => "post_id", :name => "post_id", :value => @post.id}
22+
%label{:for => "comment_body"} Submit your opinion:
23+
%br
24+
%textarea{:id => "comment_body", :name => "comment[body]", :cols => 70, :rows => 5}
25+
%br
26+
%input{:type => "submit", :value => "Submit"}
27+
- else
28+
%p <a href="/login">Log in</a> to add your own commentary.
29+
%hr
30+
%a{:href => "/blog"}Back to blog
2931

0 commit comments

Comments
 (0)