go_comments 0.1.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +36 -0
- data/app/assets/config/go_comments_manifest.js +0 -0
- data/app/assets/javascripts/comment/comments.js +2 -0
- data/app/assets/stylesheets/comment/comments.css +4 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/comment/comments_controller.rb +47 -0
- data/app/helpers/comment/comments_helper.rb +2 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/comment.rb +5 -0
- data/app/models/comment/comment.rb +5 -0
- data/app/views/comment/comments/_comment.html.erb +33 -0
- data/app/views/comment/comments/_comments.html.erb +10 -0
- data/app/views/comment/comments/_form.html.erb +21 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20171122232821_create_comment_comments.rb +19 -0
- data/lib/go_comments.rb +5 -0
- data/lib/go_comments/engine.rb +17 -0
- data/lib/go_comments/version.rb +3 -0
- data/lib/tasks/go_comments_tasks.rake +4 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 35f6c1c99e8ff157ef69f4e0b983a156c8f14603
|
4
|
+
data.tar.gz: afdf49335ee3441566b5321b836704fbcf20e109
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de1cf088f456a3788d4102d61ae1f62027466df56ac9727a019f84648d5af86454b5b18b2790c82f6bf9b9debd20ca8154fb3ac7abf03829dcdbcc9c584efe92
|
7
|
+
data.tar.gz: 45239ff3ba26df2940a06bd23c152035e6c931b4c6977dd49bf2fd8ab3edf5805f5a01e283b509f7bc143c7dc5c79ef28fd8d098f0c44c27b005fd2d33215a74
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 João Carlos Ottobboni
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# GoComments
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'go_comments'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install go_comments
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'GoComments'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
File without changes
|
@@ -0,0 +1,80 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #fff;
|
3
|
+
color: #333;
|
4
|
+
margin: 33px;
|
5
|
+
}
|
6
|
+
|
7
|
+
body, p, ol, ul, td {
|
8
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
9
|
+
font-size: 13px;
|
10
|
+
line-height: 18px;
|
11
|
+
}
|
12
|
+
|
13
|
+
pre {
|
14
|
+
background-color: #eee;
|
15
|
+
padding: 10px;
|
16
|
+
font-size: 11px;
|
17
|
+
}
|
18
|
+
|
19
|
+
a {
|
20
|
+
color: #000;
|
21
|
+
}
|
22
|
+
|
23
|
+
a:visited {
|
24
|
+
color: #666;
|
25
|
+
}
|
26
|
+
|
27
|
+
a:hover {
|
28
|
+
color: #fff;
|
29
|
+
background-color: #000;
|
30
|
+
}
|
31
|
+
|
32
|
+
th {
|
33
|
+
padding-bottom: 5px;
|
34
|
+
}
|
35
|
+
|
36
|
+
td {
|
37
|
+
padding: 0 5px 7px;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.field,
|
41
|
+
div.actions {
|
42
|
+
margin-bottom: 10px;
|
43
|
+
}
|
44
|
+
|
45
|
+
#notice {
|
46
|
+
color: green;
|
47
|
+
}
|
48
|
+
|
49
|
+
.field_with_errors {
|
50
|
+
padding: 2px;
|
51
|
+
background-color: red;
|
52
|
+
display: table;
|
53
|
+
}
|
54
|
+
|
55
|
+
#error_explanation {
|
56
|
+
width: 450px;
|
57
|
+
border: 2px solid red;
|
58
|
+
padding: 7px 7px 0;
|
59
|
+
margin-bottom: 20px;
|
60
|
+
background-color: #f0f0f0;
|
61
|
+
}
|
62
|
+
|
63
|
+
#error_explanation h2 {
|
64
|
+
text-align: left;
|
65
|
+
font-weight: bold;
|
66
|
+
padding: 5px 5px 5px 15px;
|
67
|
+
font-size: 12px;
|
68
|
+
margin: -7px -7px 0;
|
69
|
+
background-color: #c00;
|
70
|
+
color: #fff;
|
71
|
+
}
|
72
|
+
|
73
|
+
#error_explanation ul li {
|
74
|
+
font-size: 12px;
|
75
|
+
list-style: square;
|
76
|
+
}
|
77
|
+
|
78
|
+
label {
|
79
|
+
display: block;
|
80
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Comment
|
2
|
+
class CommentsController < ApplicationController
|
3
|
+
before_action :set_comment, only: [:edit, :update, :destroy]
|
4
|
+
|
5
|
+
# GET /comments
|
6
|
+
def index
|
7
|
+
@comments = Comment.order('id asc').page(params[:page])
|
8
|
+
end
|
9
|
+
|
10
|
+
# POST /comments
|
11
|
+
def create
|
12
|
+
@comment = Comment.new(comment_params)
|
13
|
+
@comment.user_id = current_user.id
|
14
|
+
@comment.save
|
15
|
+
end
|
16
|
+
|
17
|
+
# PATCH/PUT /comments/1
|
18
|
+
def update
|
19
|
+
@success = @comment.update(comment_params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def reply
|
23
|
+
@parent = Comment.find(params[:id])
|
24
|
+
@comment = Comment.new(parent_id: @parent.id, commentable: @parent.commentable)
|
25
|
+
end
|
26
|
+
|
27
|
+
# DELETE /comments/1
|
28
|
+
def destroy
|
29
|
+
if @comment.user_id != current_user.id
|
30
|
+
raise ActiveRecord::RecordNotFound
|
31
|
+
end
|
32
|
+
|
33
|
+
@comment.destroy
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
# Use callbacks to share common setup or constraints between actions.
|
38
|
+
def set_comment
|
39
|
+
@comment = Comment.find(params[:id])
|
40
|
+
end
|
41
|
+
|
42
|
+
# Only allow a trusted parameter "white list" through.
|
43
|
+
def comment_params
|
44
|
+
params.require(:comment_comment).permit(:commentable_type, :commentable_id, :parent_id, :body)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<div id="comment-<%= comment.id %>"
|
2
|
+
class="comment comment-depth-<%= comment.depth %> media"
|
3
|
+
data-parent-id="<%= comment.parent_id %>">
|
4
|
+
<div class="media-left">
|
5
|
+
<%= link_to image_tag(comment.user_avatar_url), comment.user_profile_url,
|
6
|
+
title: comment.user_name,
|
7
|
+
class: 'user-avatar' %>
|
8
|
+
</div>
|
9
|
+
<div class="media-body">
|
10
|
+
<div class="media-heading">
|
11
|
+
<span class="name">
|
12
|
+
<%= link_to comment.user_name, comment.user_profile_url,
|
13
|
+
title: comment.user_name,
|
14
|
+
class: 'user-avatar' %>
|
15
|
+
</span>
|
16
|
+
<span class="time">
|
17
|
+
<%= l comment.created_at, format: :long %>
|
18
|
+
</span>
|
19
|
+
<span class="opts pull-xs-right">
|
20
|
+
<% if comment.can_reply? %>
|
21
|
+
<%= link_to raw('<i class="fa fa-reply"></i>'), comments.reply_comment_path(comment), data: {remote: true} %>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<% if current_user.id == comment.user_id %>
|
25
|
+
<%= link_to raw('<i class="fa fa-trash"></i>'), comments.comment_path(comment), data: {method: 'delete', remote: true, confirm: "Are you sure?"} %>
|
26
|
+
<% end %>
|
27
|
+
</span>
|
28
|
+
</div>
|
29
|
+
<div class="media-content markdown">
|
30
|
+
<%= simple_format comment.body %>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="comments comments">
|
2
|
+
<div class="heading">Comments</div>
|
3
|
+
<div class="comments-list">
|
4
|
+
<%= render partial: 'comment/comments/comment', collection: comments, as: :comment %>
|
5
|
+
</div>
|
6
|
+
<div class="comments-footer">
|
7
|
+
</div>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<%= render partial: 'comment/comments/form', locals: {comment: comments.new} %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= form_for(comment, remote: true) do |f| %>
|
2
|
+
<div style="display:none">
|
3
|
+
<%= f.hidden_field :commentable_type %>
|
4
|
+
<%= f.hidden_field :commentable_id %>
|
5
|
+
<%= f.hidden_field :parent_id %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group row">
|
9
|
+
<div class="col-sm-9">
|
10
|
+
<%= f.text_area :body, class: 'form-control' %>
|
11
|
+
</div>
|
12
|
+
<div class="col-sm-3">
|
13
|
+
<% if comment.parent_id.blank? %>
|
14
|
+
<%= f.submit class: 'btn btn-primary btn-block' %>
|
15
|
+
<% else %>
|
16
|
+
<%= f.submit 'Reply', class: 'btn btn-primary' %>
|
17
|
+
<a href="#" class="btn btn-secondary" onclick="$(this).closest('.new_comment').remove(); return false;">Cancel</a>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateCommentComments < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :comment_comments do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.string :commentable_type
|
6
|
+
t.integer :commentable_id
|
7
|
+
t.text :body
|
8
|
+
t.integer :parent_id, :lft, :rgt
|
9
|
+
t.integer :depth, default: 0, null: false
|
10
|
+
|
11
|
+
t.timestamps null: false
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :comment_comments, [:commentable_type, :commentable_id]
|
15
|
+
add_index :comment_comments, :parent_id
|
16
|
+
add_index :comment_comments, :lft
|
17
|
+
add_index :comment_comments, :rgt
|
18
|
+
end
|
19
|
+
end
|
data/lib/go_comments.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module GoComments
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
initializer :append_migrations do |app|
|
4
|
+
# This prevents migrations from being loaded twice from the inside of the
|
5
|
+
# gem itself (dummy test app)
|
6
|
+
if app.root.to_s !~ /#{root}/
|
7
|
+
config.paths['db/migrate'].expanded.each do |migration_path|
|
8
|
+
app.config.paths['db/migrate'] << migration_path
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
config.assets.precompile += ['*.js', '*.css', '**/*.js', '**/*.css', '*.jpg',
|
14
|
+
'*.png', '*.ico', '*.gif', '*.woff2', '*.eot',
|
15
|
+
'*.woff', '*.ttf', '*.svg']
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: go_comments
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- João Carlos Ottobboni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: draper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: carrierwave
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: devise
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cancancan
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: go_gamification engine
|
98
|
+
email:
|
99
|
+
- jcottobboni@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- MIT-LICENSE
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- app/assets/config/go_comments_manifest.js
|
108
|
+
- app/assets/javascripts/comment/comments.js
|
109
|
+
- app/assets/stylesheets/comment/comments.css
|
110
|
+
- app/assets/stylesheets/scaffold.css
|
111
|
+
- app/controllers/comment/comments_controller.rb
|
112
|
+
- app/helpers/comment/comments_helper.rb
|
113
|
+
- app/models/application_record.rb
|
114
|
+
- app/models/comment.rb
|
115
|
+
- app/models/comment/comment.rb
|
116
|
+
- app/views/comment/comments/_comment.html.erb
|
117
|
+
- app/views/comment/comments/_comments.html.erb
|
118
|
+
- app/views/comment/comments/_form.html.erb
|
119
|
+
- config/routes.rb
|
120
|
+
- db/migrate/20171122232821_create_comment_comments.rb
|
121
|
+
- lib/go_comments.rb
|
122
|
+
- lib/go_comments/engine.rb
|
123
|
+
- lib/go_comments/version.rb
|
124
|
+
- lib/tasks/go_comments_tasks.rake
|
125
|
+
homepage: http://www.gorails.com.br
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.6.13
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: go_gamification engine
|
149
|
+
test_files: []
|