talkie 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +14 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +11 -0
  7. data/Gemfile.lock +205 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +120 -0
  10. data/Rakefile +23 -0
  11. data/app/assets/javascripts/talkie/application.js +5 -0
  12. data/app/assets/stylesheets/talkie/_comment.scss +103 -0
  13. data/app/assets/stylesheets/talkie/_form.scss +50 -0
  14. data/app/assets/stylesheets/talkie/_variables.scss +71 -0
  15. data/app/assets/stylesheets/talkie/application.scss +3 -0
  16. data/app/controllers/talkie/comments_controller.rb +45 -0
  17. data/app/controllers/talkie_controller.rb +19 -0
  18. data/app/helpers/talkie/application_helper.rb +20 -0
  19. data/app/models/talkie/comment.rb +13 -0
  20. data/app/views/talkie/comments/_comment.html.erb +44 -0
  21. data/app/views/talkie/comments/_form.html.erb +11 -0
  22. data/app/views/talkie/comments/_template.html.erb +3 -0
  23. data/bin/console +14 -0
  24. data/bin/setup +10 -0
  25. data/config/locales/en.yml +16 -0
  26. data/config/locales/es.yml +16 -0
  27. data/config/routes.rb +3 -0
  28. data/lib/generators/talkie/install_generator.rb +27 -0
  29. data/lib/generators/talkie/templates/create_talkie_comments.rb +27 -0
  30. data/lib/generators/talkie/templates/talkie.rb +46 -0
  31. data/lib/talkie.rb +30 -0
  32. data/lib/talkie/acts_as_commentable.rb +27 -0
  33. data/lib/talkie/acts_as_talker.rb +29 -0
  34. data/lib/talkie/comments_renderer.rb +43 -0
  35. data/lib/talkie/controller.rb +18 -0
  36. data/lib/talkie/engine.rb +15 -0
  37. data/lib/talkie/permission.rb +16 -0
  38. data/lib/talkie/renderer_helper.rb +42 -0
  39. data/lib/talkie/version.rb +3 -0
  40. data/talkie.gemspec +41 -0
  41. metadata +251 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 387327deeaf25674ee27502bb4ed8b7b5b47f4041865cf5771cb14e74986531f
4
+ data.tar.gz: b369f237e253df6fc52c061bb90ff24eb87f3f62b86067db12272635ee2594e0
5
+ SHA512:
6
+ metadata.gz: 67cee7e1cedaca192c4288d89af9beee204705a7b5e4284ad68683fef1b10bc361dd2d6b3002e0c572d270783ac4be247d0cc6a2b0d3b52a68d84ece4d5ed0c3
7
+ data.tar.gz: 4818916e347a23a29bd3583f1f17d6c1b95847f1794104bd33ce54fb67d36b8cb68c7421a55071c90c700163f28f6973346b189dc7572943e20afc9c2e372ee0
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /spec/dummy/tmp
10
+ /spec/dummy/log
11
+ *.gem
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ before_script:
5
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
6
+ - chmod +x ./cc-test-reporter
7
+ - ./cc-test-reporter before-build
8
+
9
+ cache: bundler
10
+ rvm:
11
+ - 2.6.2
12
+ before_install: gem install bundler -v 1.17.2
13
+ after_script:
14
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kurenn@icalialabs.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in talkie.gemspec
6
+ gemspec
7
+
8
+ gem "sqlite3", "~> 1.4"
9
+ gem 'shoulda-matchers'
10
+ gem "database_cleaner","~> 1"
11
+ gem 'simplecov', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,205 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ talkie (0.1.0)
5
+ awesome_nested_set (~> 3.1)
6
+ rails (~> 5.0)
7
+ sassc-rails (~> 2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (5.2.3)
13
+ actionpack (= 5.2.3)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailer (5.2.3)
17
+ actionpack (= 5.2.3)
18
+ actionview (= 5.2.3)
19
+ activejob (= 5.2.3)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.2.3)
23
+ actionview (= 5.2.3)
24
+ activesupport (= 5.2.3)
25
+ rack (~> 2.0)
26
+ rack-test (>= 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.2.3)
30
+ activesupport (= 5.2.3)
31
+ builder (~> 3.1)
32
+ erubi (~> 1.4)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
+ activejob (5.2.3)
36
+ activesupport (= 5.2.3)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.2.3)
39
+ activesupport (= 5.2.3)
40
+ activerecord (5.2.3)
41
+ activemodel (= 5.2.3)
42
+ activesupport (= 5.2.3)
43
+ arel (>= 9.0)
44
+ activestorage (5.2.3)
45
+ actionpack (= 5.2.3)
46
+ activerecord (= 5.2.3)
47
+ marcel (~> 0.3.1)
48
+ activesupport (5.2.3)
49
+ concurrent-ruby (~> 1.0, >= 1.0.2)
50
+ i18n (>= 0.7, < 2)
51
+ minitest (~> 5.1)
52
+ tzinfo (~> 1.1)
53
+ ammeter (1.1.4)
54
+ activesupport (>= 3.0)
55
+ railties (>= 3.0)
56
+ rspec-rails (>= 2.2)
57
+ arel (9.0.0)
58
+ awesome_nested_set (3.1.4)
59
+ activerecord (>= 4.0.0, < 5.3)
60
+ builder (3.2.3)
61
+ coderay (1.1.2)
62
+ concurrent-ruby (1.1.5)
63
+ crass (1.0.4)
64
+ database_cleaner (1.7.0)
65
+ diff-lcs (1.3)
66
+ docile (1.1.5)
67
+ erubi (1.8.0)
68
+ ffi (1.11.1)
69
+ globalid (0.4.2)
70
+ activesupport (>= 4.2.0)
71
+ i18n (1.6.0)
72
+ concurrent-ruby (~> 1.0)
73
+ jquery-rails (4.3.3)
74
+ rails-dom-testing (>= 1, < 3)
75
+ railties (>= 4.2.0)
76
+ thor (>= 0.14, < 2.0)
77
+ json (2.2.0)
78
+ loofah (2.2.3)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.1)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (0.3.3)
84
+ mimemagic (~> 0.3.2)
85
+ method_source (0.9.2)
86
+ mimemagic (0.3.3)
87
+ mini_mime (1.0.1)
88
+ mini_portile2 (2.4.0)
89
+ minitest (5.11.3)
90
+ nio4r (2.3.1)
91
+ nokogiri (1.10.3)
92
+ mini_portile2 (~> 2.4.0)
93
+ pry (0.12.2)
94
+ coderay (~> 1.1.0)
95
+ method_source (~> 0.9.0)
96
+ rack (2.0.7)
97
+ rack-test (1.1.0)
98
+ rack (>= 1.0, < 3)
99
+ rails (5.2.3)
100
+ actioncable (= 5.2.3)
101
+ actionmailer (= 5.2.3)
102
+ actionpack (= 5.2.3)
103
+ actionview (= 5.2.3)
104
+ activejob (= 5.2.3)
105
+ activemodel (= 5.2.3)
106
+ activerecord (= 5.2.3)
107
+ activestorage (= 5.2.3)
108
+ activesupport (= 5.2.3)
109
+ bundler (>= 1.3.0)
110
+ railties (= 5.2.3)
111
+ sprockets-rails (>= 2.0.0)
112
+ rails-controller-testing (1.0.4)
113
+ actionpack (>= 5.0.1.x)
114
+ actionview (>= 5.0.1.x)
115
+ activesupport (>= 5.0.1.x)
116
+ rails-dom-testing (2.0.3)
117
+ activesupport (>= 4.2.0)
118
+ nokogiri (>= 1.6)
119
+ rails-html-sanitizer (1.0.4)
120
+ loofah (~> 2.2, >= 2.2.2)
121
+ rails-i18n (5.1.3)
122
+ i18n (>= 0.7, < 2)
123
+ railties (>= 5.0, < 6)
124
+ railties (5.2.3)
125
+ actionpack (= 5.2.3)
126
+ activesupport (= 5.2.3)
127
+ method_source
128
+ rake (>= 0.8.7)
129
+ thor (>= 0.19.0, < 2.0)
130
+ rake (10.5.0)
131
+ rspec (3.8.0)
132
+ rspec-core (~> 3.8.0)
133
+ rspec-expectations (~> 3.8.0)
134
+ rspec-mocks (~> 3.8.0)
135
+ rspec-core (3.8.0)
136
+ rspec-support (~> 3.8.0)
137
+ rspec-expectations (3.8.3)
138
+ diff-lcs (>= 1.2.0, < 2.0)
139
+ rspec-support (~> 3.8.0)
140
+ rspec-mocks (3.8.0)
141
+ diff-lcs (>= 1.2.0, < 2.0)
142
+ rspec-support (~> 3.8.0)
143
+ rspec-rails (3.8.2)
144
+ actionpack (>= 3.0)
145
+ activesupport (>= 3.0)
146
+ railties (>= 3.0)
147
+ rspec-core (~> 3.8.0)
148
+ rspec-expectations (~> 3.8.0)
149
+ rspec-mocks (~> 3.8.0)
150
+ rspec-support (~> 3.8.0)
151
+ rspec-support (3.8.0)
152
+ sassc (2.0.1)
153
+ ffi (~> 1.9)
154
+ rake
155
+ sassc-rails (2.1.1)
156
+ railties (>= 4.0.0)
157
+ sassc (>= 2.0)
158
+ sprockets (> 3.0)
159
+ sprockets-rails
160
+ tilt
161
+ shoulda-matchers (4.0.1)
162
+ activesupport (>= 4.2.0)
163
+ simplecov (0.13.0)
164
+ docile (~> 1.1.0)
165
+ json (>= 1.8, < 3)
166
+ simplecov-html (~> 0.10.0)
167
+ simplecov-html (0.10.2)
168
+ sprockets (3.7.2)
169
+ concurrent-ruby (~> 1.0)
170
+ rack (> 1, < 3)
171
+ sprockets-rails (3.2.1)
172
+ actionpack (>= 4.0)
173
+ activesupport (>= 4.0)
174
+ sprockets (>= 3.0.0)
175
+ sqlite3 (1.4.1)
176
+ thor (0.20.3)
177
+ thread_safe (0.3.6)
178
+ tilt (2.0.9)
179
+ tzinfo (1.2.5)
180
+ thread_safe (~> 0.1)
181
+ websocket-driver (0.7.0)
182
+ websocket-extensions (>= 0.1.0)
183
+ websocket-extensions (0.1.3)
184
+
185
+ PLATFORMS
186
+ ruby
187
+
188
+ DEPENDENCIES
189
+ ammeter (~> 1.1)
190
+ bundler (~> 1.17)
191
+ database_cleaner (~> 1)
192
+ jquery-rails (~> 4.3)
193
+ pry (~> 0.12)
194
+ rails-controller-testing (~> 1.0)
195
+ rails-i18n (~> 5.1)
196
+ rake (~> 10.0)
197
+ rspec (~> 3.0)
198
+ rspec-rails (~> 3.8)
199
+ shoulda-matchers
200
+ simplecov
201
+ sqlite3 (~> 1.4)
202
+ talkie!
203
+
204
+ BUNDLED WITH
205
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Abraham Kuri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # Talkie
2
+
3
+ [![Build Status](https://travis-ci.org/kurenn/talkie.svg?branch=master)](https://travis-ci.org/kurenn/talkie)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a9148bef84de0a1f97ad/test_coverage)](https://codeclimate.com/github/kurenn/talkie/test_coverage)
5
+ <a href="https://codeclimate.com/github/kurenn/talkie/maintainability"><img src="https://api.codeclimate.com/v1/badges/a9148bef84de0a1f97ad/maintainability" /></a>
6
+
7
+ Talkie is highly customizable comments engine to easily integrate threads to any existing model, inspired by [commontator](https://github.com/lml/commontator) and with simplicity as the drive for this. Its intention is to be a full solution for your application in case you need to provide your users with the ability to open a forum anywhere.
8
+
9
+ - [Talkie](#talkie)
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Customization](#customization)
13
+ - [Styles](#styles)
14
+ - [Development](#development)
15
+ - [Contributing](#contributing)
16
+ - [License](#license)
17
+ - [Code of Conduct](#code-of-conduct)
18
+
19
+ ## Installation
20
+
21
+ Talkie works with Rails 5.0 onwards. The first step is to add it to your `Gemfile`:
22
+
23
+ ```ruby
24
+ gem "talkie"
25
+ ```
26
+
27
+ And then run the `bundle install`.
28
+
29
+ Next, you need to run the install generator:
30
+
31
+ ```console
32
+ $ rails generate talkie:install
33
+ ```
34
+
35
+ At this point, a thanks message will appear in the console. **Be aware that you need to have a current_user method with the logged in user, there is no guest support currently**
36
+
37
+ The generator will install an initializer which describes ALL Talkie's configuration options. It is highly recommended that you take a look at it. Also notice that a new migration is provided, you need to migrate your database:
38
+
39
+ ```console
40
+ $ rails db:migrate
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ After running the generator, you need to set up the models you need to add comments to and the ones who are able to post them.
46
+
47
+ 1. For the models to be able to comment to:
48
+
49
+ ```ruby
50
+ acts_as_commentable
51
+ ```
52
+
53
+ 2. For the models to be able to create comments(commonly the `User` model):
54
+
55
+ ```ruby
56
+ acts_as_talker
57
+ ```
58
+
59
+ After that you just need to call the helper to render the comments thread. So let's say you have an `Article` model on which you desire to add this:
60
+
61
+ **app/views/articles/show.html.erb**
62
+
63
+ ```erb
64
+ <%= talkie_on @article %>
65
+ ```
66
+
67
+ For more options on how to customize the render of the comments, check out the [customization](#customization) section.
68
+
69
+ After this, you need to add the default styles and JS provided by the gem, just add them to the corresponding manifests like so:
70
+
71
+ **app/assets/stylesheets/application.scss**
72
+
73
+ ```css
74
+ @import "talkie/application";
75
+ ```
76
+
77
+ **app/assets/javascripts/application.js**
78
+
79
+ ```js
80
+ //= require talkie/application
81
+ ```
82
+
83
+ ### Customization
84
+
85
+ Talkie, currently only offers 3 options for the `talkie_on` helper method:
86
+
87
+ | Name | Description |
88
+ | ------------------------------------------------------------ | :----------------------------------------------------------- |
89
+ | **nested** | Whether users are able to reply to comments or not. *Default: false* |
90
+ | **display_user_avatar** | Whether the helper should render an avatar. *Default: true* |
91
+ | **display_user_handler** | Whether the helper should render the user handler. *Default: false* |
92
+
93
+ Don't worry about those nasty N+1 queries, Talkie is smart enough to take care of them. You don't need to restart the server for chanes on this invokation.
94
+
95
+ There is another way to customize Talkie, and that is at the `initializer` provided by the install generator, you can check that [here](lib/generators/talkie/templates/talkie.rb)
96
+
97
+ #### Styles
98
+
99
+ Talkie is all about customization, so almost every default style provided by the gem can be overwritten through sass variables, which you can find [here](https://github.com/kurenn/talkie/blob/master/app/assets/stylesheets/talkie/_variables.scss). Make sure you add the variables right before importing the sass talkie manifest:
100
+
101
+ ```css
102
+ @import "my_variables_to_override";
103
+ @import "talkie/application";
104
+ ```
105
+
106
+ ## Development
107
+
108
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests.
109
+
110
+ ## Contributing
111
+
112
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kurenn/talkie. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
113
+
114
+ ## License
115
+
116
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
117
+
118
+ ## Code of Conduct
119
+
120
+ Everyone interacting in the Talkie project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kurenn/talkie/blob/master/CODE_OF_CONDUCT.md).