work on comments

This commit is contained in:
albert
2010-10-20 19:24:53 -04:00
parent d7eafdaaf5
commit f8b1bd3142
15 changed files with 184 additions and 44 deletions

View File

@@ -0,0 +1,5 @@
class DtextController < ApplicationController
def preview
render :inline => "<h1>Preview</h1><%= format_text(params[:body]) %>"
end
end

View File

@@ -7,7 +7,7 @@ class SessionsController < ApplicationController
if User.authenticate(params[:name], params[:password])
@user = User.find_by_name(params[:name])
session[:user_id] = @user.id
redirect_to(params[:url] || posts_path, :notice => "You are now logged in.")
redirect_to(params[:url] || session[:previous_uri] || posts_path, :notice => "You are now logged in.")
else
redirect_to(new_session_path, :notice => "Password was incorrect.")
end

View File

@@ -1,19 +0,0 @@
<div class="comment-section" data-post-id="<%= post.id %>">
<div class="comment-list">
<%= render :partial => "comments/partials/show/comment", :collection => comments %>
</div>
<div class="comment-response">
<p><%= submit_tag "Post comment", :class => "expand-comment-response" %></p>
<div class="comment-preview"></div>
<%= form_tag(comments_path) do %>
<%= hidden_field "comment", "post_id", :value => post.id%>
<%= text_area "comment", "body", :size => "60x7" %><br>
<%= submit_tag "Post" %>
<%= submit_tag "Preview" %>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,6 @@
%div{:class => "comments-for-post", "data-post-id" => post.id}
%div{:class => "list-of-comments"}
= render :partial => "comments/partials/show/comment", :collection => comments
%div{:class => "new-comment"}
%p= link_to "Post comment", new_comment_path, :class => "expand-comment-response"
= render :partial => "comments/partials/new/form", :locals => {:post => post}

View File

@@ -0,0 +1,7 @@
%div{:class => "comment-preview dtext"}
= form_tag(comments_path) do
= hidden_field "comment", "post_id", :value => post.id
= text_area "comment", "body", :size => "60x7"
%br
= submit_tag "Post"
= submit_tag "Preview"

View File

@@ -1,22 +0,0 @@
<article data-comment-id="<%= comment.id %>">
<header>
<h1><%= link_to comment.creator_name, user_path(comment.creator_id) %></h1>
<time datetime="<%= comment.created_at %>"><%= time_ago_in_words(comment.created_at) %> ago</time>
</header>
<div>
<section>
<%= format_text(comment.body) %>
</section>
<footer>
<menu>
<li><span class="link">Quote</span></li>
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li>
<% end %>
<li><%= link_to "Vote up", comment_vote_path(comment.id, :is_positive => true), :method => :post %></li>
<li><%= link_to "Vote down", comment_vote_path(comment.id, :is_positive => false), :method => :post %></li>
</menu>
</footer>
</div>
</article>
<div class="clearfix"></div>

View File

@@ -0,0 +1,16 @@
%article{"data-comment-id" => comment.id}
%div{:class => "author"}
%h1= link_to comment.creator_name, user_path(comment.creator_id)
%time{:datetime => comment.created_at}
= time_ago_in_words(comment.created_at)
= " ago"
%div{:class => "content"}
%div= format_text(comment.body)
%menu
%li
%span{:class => "link"} Quote
- if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id
%li= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete
%li= link_to "Vote up", comment_vote_path(comment.id, :is_positive => true), :method => :post
%li= link_to "Vote down", comment_vote_path(comment.id, :is_positive => false), :method => :post
%div{:class => "clearfix"}

View File

@@ -5,7 +5,7 @@
</div>
<% end %>
<% form_for(post, :html => {:class => "simple_form"}) do |f| %>
<%= form_for(post, :html => {:class => "simple_form"}) do |f| %>
<%= f.hidden_field :old_tags, :value => post.tag_string %>
<div class="input">