work on comments
This commit is contained in:
5
app/controllers/dtext_controller.rb
Normal file
5
app/controllers/dtext_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class DtextController < ApplicationController
|
||||
def preview
|
||||
render :inline => "<h1>Preview</h1><%= format_text(params[:body]) %>"
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
6
app/views/comments/partials/index/_list.html.haml
Normal file
6
app/views/comments/partials/index/_list.html.haml
Normal 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}
|
||||
7
app/views/comments/partials/new/_form.html.haml
Normal file
7
app/views/comments/partials/new/_form.html.haml
Normal 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"
|
||||
@@ -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>
|
||||
16
app/views/comments/partials/show/_comment.html.haml
Normal file
16
app/views/comments/partials/show/_comment.html.haml
Normal 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"}
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user