Permalink
Browse files

Implemented function for delete comments.

  • Loading branch information...
1 parent fe05e49 commit f350603ca6b7436af3739afb2e534b037879132c @jugyo committed Apr 12, 2009
Showing with 17 additions and 1 deletion.
  1. +9 −1 app.rb
  2. +3 −0 themes/default/entry/comments.haml
  3. +5 −0 themes/default/styles.sass
View
10 app.rb
@@ -117,7 +117,7 @@
if @logged_in
@entry = Entry.get(params[:id])
@entry.destroy
- redirect "/"
+ ''
end
end
@@ -156,6 +156,14 @@
redirect "/entry/#{params[:entry_id]}"
end
+post '/comment/delete/:id' do
+ if @logged_in
+ @comment = Comment.get(params[:id])
+ @comment.destroy
+ ''
+ end
+end
+
get '/login' do
if @logged_in
redirect '/'
@@ -9,6 +9,9 @@
&= comment.name
.comment_body
= h(comment.body).gsub("\n", "<br />\n")
+ .comment_footer
+ - if @logged_in
+ %a{:href=>"javascript:void(0)", :onclick=>"if (confirm('Are you shure?')) { jQuery.post('/comment/delete/#{comment.id}', null, function(){location.reload()}) }"} delete
#comment_form
%form{:action=>"/comment", :method=>'post'}
@@ -60,6 +60,11 @@ a
margin: 8px 0
border: dotted 1px silver
+.comment_body
+
+.comment_footer
+ text-align: right
+
h2.entry_title
color: gray
margin: 0

0 comments on commit f350603

Please sign in to comment.