make_commentable 0.0.8.1 → 0.0.8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/generators/comment/comment_generator.rb +14 -1
- data/generators/comment/templates/comments_controller.rb +0 -0
- data/generators/comment/templates/javascripts/comments.js +14 -0
- data/generators/comment/templates/views/_comment.html.haml +13 -0
- data/generators/comment/templates/views/_comment_form.html.haml +8 -0
- data/lib/make_commentable/version.rb +1 -1
- metadata +6 -4
- data/README.rdoc +0 -1
|
@@ -4,7 +4,7 @@ class CommentGenerator < Rails::Generators::Base
|
|
|
4
4
|
include Rails::Generators::Migration
|
|
5
5
|
|
|
6
6
|
def self.source_root
|
|
7
|
-
@
|
|
7
|
+
@make_commentable_source_root ||= File.expand_path("../templates", __FILE__)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def self.next_migration_number(path)
|
|
@@ -15,4 +15,17 @@ class CommentGenerator < Rails::Generators::Base
|
|
|
15
15
|
template "comment.rb", "app/models/comment.rb"
|
|
16
16
|
migration_template "create_comments.rb", "db/migrate/create_comments.rb"
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
def create_controller_file
|
|
20
|
+
template "comments_controler.rb", "app/controllers/comments_controller.rb"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_views
|
|
24
|
+
template "views/_comment.html.haml", "app/views/_comment.html.haml"
|
|
25
|
+
template "views/_comment_form.html.haml", "app/views/_comment_form.html.haml"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create_javascripts
|
|
29
|
+
template "javascripts/comments.js", "app/assets/javascripts/comments/comments.js"
|
|
30
|
+
end
|
|
18
31
|
end
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
$(document).ready(function(){
|
|
2
|
+
$(".comment_link").click(function(event) {
|
|
3
|
+
var initial_form = $("#answer_form");
|
|
4
|
+
var new_form = initial_form.clone();
|
|
5
|
+
initial_form.remove();
|
|
6
|
+
|
|
7
|
+
var comment_body = $(this).closest('.comment_body');
|
|
8
|
+
var answer = comment_body.children('.answer').first();
|
|
9
|
+
answer.append(new_form);
|
|
10
|
+
|
|
11
|
+
$("#comment_parent_id").attr('value',comment_body.attr('id'));
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
- if comment.content
|
|
2
|
+
.comment_body{ :id => comment.id, :style => "width: 250px;padding: 0px 0px 0px 20px;" }
|
|
3
|
+
.comment-content
|
|
4
|
+
.comment-info
|
|
5
|
+
%span.user= comment.user.display_name
|
|
6
|
+
-#%span.date= Russian::strftime(comment.updated_at, "%d %B") if comment.updated_at
|
|
7
|
+
%strong= comment.content
|
|
8
|
+
= link_to('Ответить', '#', :class => 'comment_link')
|
|
9
|
+
.answer
|
|
10
|
+
%br
|
|
11
|
+
- comments = comment.children
|
|
12
|
+
- if comments.any?
|
|
13
|
+
= render :partial => 'comments/comment', :collection => comments
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
.comment-form{ :id => :answer_form, :style => "display:hidden;" }
|
|
2
|
+
= simple_form_for [@company, @comment], :html => { :class => '' } do |f|
|
|
3
|
+
= f.input :parent_id, :as => :hidden
|
|
4
|
+
%div
|
|
5
|
+
= f.input :content, :required => false, :as => :text, :input_html => {:rows => 3}, :label => "#{I18n.t("comments.content")}:"
|
|
6
|
+
.comment-submit
|
|
7
|
+
= f.button :submit, I18n.t('comments.send_to')
|
|
8
|
+
%br/
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: make_commentable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.8.1
|
|
4
|
+
version: 0.0.8.1.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -63,17 +63,19 @@ description: add comments implementation for Active Record
|
|
|
63
63
|
email: zozz2008@gmail.com
|
|
64
64
|
executables: []
|
|
65
65
|
extensions: []
|
|
66
|
-
extra_rdoc_files:
|
|
67
|
-
- README.rdoc
|
|
66
|
+
extra_rdoc_files: []
|
|
68
67
|
files:
|
|
69
68
|
- lib/make_commentable.rb
|
|
70
69
|
- lib/make_commentable/version.rb
|
|
71
70
|
- lib/make_commentable/commentable_methods.rb
|
|
71
|
+
- generators/comment/templates/javascripts/comments.js
|
|
72
72
|
- generators/comment/templates/create_comments.rb
|
|
73
73
|
- generators/comment/templates/comment.rb
|
|
74
|
+
- generators/comment/templates/comments_controller.rb
|
|
75
|
+
- generators/comment/templates/views/_comment_form.html.haml
|
|
76
|
+
- generators/comment/templates/views/_comment.html.haml
|
|
74
77
|
- generators/comment/comment_generator.rb
|
|
75
78
|
- LICENSE
|
|
76
|
-
- README.rdoc
|
|
77
79
|
homepage: https://rubygems.org/gems/make_commentable
|
|
78
80
|
licenses: []
|
|
79
81
|
post_install_message:
|
data/README.rdoc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
make_commentable gem
|