add jrails, work on comments

This commit is contained in:
albert
2010-10-21 18:56:00 -04:00
parent f8b1bd3142
commit a9da0f1059
38 changed files with 20481 additions and 7 deletions

View File

@@ -24,6 +24,8 @@ class CommentsController < ApplicationController
flash[:notice] = "Comment posted"
redirect_to posts_path(@comment.post)
end
format.js
end
end
end

View File

@@ -44,11 +44,19 @@ class Post < ActiveRecord::Base
end
def medium_file_path
"#{Rails.root}/public/data/medium/#{file_path_prefix}#{md5}.jpg"
if has_medium?
"#{Rails.root}/public/data/medium/#{file_path_prefix}#{md5}.jpg"
else
file_path
end
end
def large_file_path
"#{Rails.root}/public/data/large/#{file_path_prefix}#{md5}.jpg"
if has_large?
"#{Rails.root}/public/data/large/#{file_path_prefix}#{md5}.jpg"
else
file_path
end
end
def preview_file_path

View File

@@ -0,0 +1 @@
page.insert_html(:bottom, "div.comments-for-post[data-post-id=#{@comment.post_id}] div.list-of-comments", :partial => "comments/partials/show/comment", :locals => {:comment => @comment})

View File

@@ -1,2 +1,7 @@
- @posts.each do |post|
= @post.id
%div{:class => "comments"}
%div{:class => "index"}
- @posts.each do |post|
%div{:class => "preview"}
= image_tag(post.medium_file_url)
= render :partial => "comments/partials/index/list", :locals => {:post => post, :comments => post.comments}
%div{:class => "clearfix"}

View File

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

View File

@@ -8,7 +8,7 @@
%div= format_text(comment.body)
%menu
%li
%span{:class => "link"} Quote
%span{:class => "link"} Reply
- 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

View File

@@ -41,6 +41,11 @@
</div>
<% end %>
<div class="input">
<%= f.label :parent_id, "Parent" %>
<%= f.text_field :parent_id, :size => 5 %>
</div>
<div class="input">
<%= f.label :source %>
<%= f.text_field :source %>