the_comments_ruby 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +30 -0
  3. data/.ruby-gemset.example +1 -0
  4. data/.ruby-version.example +1 -0
  5. data/.rvmrc.example +1 -0
  6. data/.travis.yml +5 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +338 -0
  10. data/Rakefile +1 -0
  11. data/app/assets/javascripts/the_comments.js.coffee +108 -0
  12. data/app/assets/javascripts/the_comments_manage.js.coffee +27 -0
  13. data/app/assets/stylesheets/the_comments.css.scss +248 -0
  14. data/app/controllers/_templates_/comments_controller.rb +44 -0
  15. data/app/controllers/concerns/the_comments/controller.rb +197 -0
  16. data/app/controllers/concerns/the_comments/view_token.rb +20 -0
  17. data/app/helpers/render_comments_tree_helper.rb +111 -0
  18. data/app/models/_templates_/comment.rb +38 -0
  19. data/app/models/concerns/the_comments/comment.rb +116 -0
  20. data/app/models/concerns/the_comments/comment_states.rb +80 -0
  21. data/app/models/concerns/the_comments/commentable.rb +69 -0
  22. data/app/models/concerns/the_comments/user.rb +56 -0
  23. data/app/views/the_comments/_tree.html.erb +3 -0
  24. data/app/views/the_comments/haml/_additional_info.html.haml +13 -0
  25. data/app/views/the_comments/haml/_comment.html.haml +1 -0
  26. data/app/views/the_comments/haml/_comment_body.html.haml +25 -0
  27. data/app/views/the_comments/haml/_comment_edit.html.haml +26 -0
  28. data/app/views/the_comments/haml/_form.html.haml +8 -0
  29. data/app/views/the_comments/haml/_guest_form.html.haml +22 -0
  30. data/app/views/the_comments/haml/_logined_form.html.haml +18 -0
  31. data/app/views/the_comments/haml/_manage_controls.html.haml +30 -0
  32. data/app/views/the_comments/haml/_sidebar.html.haml +9 -0
  33. data/app/views/the_comments/haml/_sidebar_admin.html.haml +12 -0
  34. data/app/views/the_comments/haml/_sidebar_backlink.html.haml +3 -0
  35. data/app/views/the_comments/haml/_sidebar_user.html.haml +29 -0
  36. data/app/views/the_comments/haml/_tree.html.haml +16 -0
  37. data/app/views/the_comments/haml/manage.html.haml +26 -0
  38. data/app/views/the_comments/slim/_additional_info.html.slim +13 -0
  39. data/app/views/the_comments/slim/_comment.html.slim +1 -0
  40. data/app/views/the_comments/slim/_comment_body.html.slim +24 -0
  41. data/app/views/the_comments/slim/_comment_edit.html.slim +26 -0
  42. data/app/views/the_comments/slim/_form.html.slim +8 -0
  43. data/app/views/the_comments/slim/_guest_form.html.slim +22 -0
  44. data/app/views/the_comments/slim/_logined_form.html.slim +18 -0
  45. data/app/views/the_comments/slim/_manage_controls.html.slim +30 -0
  46. data/app/views/the_comments/slim/_sidebar.html.slim +9 -0
  47. data/app/views/the_comments/slim/_sidebar_admin.html.slim +12 -0
  48. data/app/views/the_comments/slim/_sidebar_backlink.html.slim +3 -0
  49. data/app/views/the_comments/slim/_sidebar_user.html.slim +29 -0
  50. data/app/views/the_comments/slim/_tree.html.slim +16 -0
  51. data/app/views/the_comments/slim/index.html.slim +18 -0
  52. data/app/views/the_comments/slim/manage.html.slim +26 -0
  53. data/app/views/the_comments/slim/my_comments.html.slim +28 -0
  54. data/config/initializers/the_comments.rb +14 -0
  55. data/config/locales/en.yml +68 -0
  56. data/config/locales/ru.yml +71 -0
  57. data/config/routes.rb +38 -0
  58. data/db/migrate/20130101010101_the_comments_change_user.rb +18 -0
  59. data/db/migrate/20130101010102_the_comments_create_comments.rb +50 -0
  60. data/db/migrate/20130101010103_the_comments_change_commentable.rb +13 -0
  61. data/docs/admin_ui_installation.md +145 -0
  62. data/docs/advanced_installation.md +185 -0
  63. data/docs/comment_api.md +58 -0
  64. data/docs/commentable_api.md +59 -0
  65. data/docs/config_file.md +27 -0
  66. data/docs/content_preprocessors.md +73 -0
  67. data/docs/customazation_of_views.md +30 -0
  68. data/docs/denormalization_and_recent_comments.md +40 -0
  69. data/docs/documentation.md +29 -0
  70. data/docs/generators.md +74 -0
  71. data/docs/pagination.md +123 -0
  72. data/docs/routes.md +77 -0
  73. data/docs/screencast.jpg +0 -0
  74. data/docs/the_comments.jpg +0 -0
  75. data/docs/the_comments_view_1.gif +0 -0
  76. data/docs/the_comments_view_2.gif +0 -0
  77. data/docs/the_comments_view_3.gif +0 -0
  78. data/docs/the_comments_view_4.gif +0 -0
  79. data/docs/the_comments_view_5.gif +0 -0
  80. data/docs/user_api.md +75 -0
  81. data/docs/what_is_comcoms.md +63 -0
  82. data/docs/whats_wrong_with_other_gems.md +28 -0
  83. data/docs/where_is_example_application.md +37 -0
  84. data/gem_version.rb +3 -0
  85. data/lib/generators/the_comments/USAGE +44 -0
  86. data/lib/generators/the_comments/the_comments_generator.rb +56 -0
  87. data/lib/generators/the_comments/views_generator.rb +79 -0
  88. data/lib/the_comments/config.rb +37 -0
  89. data/lib/the_comments/version.rb +1 -0
  90. data/lib/the_comments.rb +28 -0
  91. data/spec/dummy_app/.gitignore +18 -0
  92. data/spec/dummy_app/.rspec +1 -0
  93. data/spec/dummy_app/Gemfile +43 -0
  94. data/spec/dummy_app/README.md +33 -0
  95. data/spec/dummy_app/Rakefile +6 -0
  96. data/spec/dummy_app/app/assets/images/.keep +0 -0
  97. data/spec/dummy_app/app/assets/javascripts/admin_panel.js +5 -0
  98. data/spec/dummy_app/app/assets/javascripts/application.js +16 -0
  99. data/spec/dummy_app/app/assets/stylesheets/admin_panel.css +3 -0
  100. data/spec/dummy_app/app/assets/stylesheets/app.css.scss +4 -0
  101. data/spec/dummy_app/app/assets/stylesheets/application.css +16 -0
  102. data/spec/dummy_app/app/controllers/application_controller.rb +7 -0
  103. data/spec/dummy_app/app/controllers/comments_controller.rb +28 -0
  104. data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
  105. data/spec/dummy_app/app/controllers/posts_controller.rb +13 -0
  106. data/spec/dummy_app/app/controllers/users_controller.rb +7 -0
  107. data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
  108. data/spec/dummy_app/app/mailers/.keep +0 -0
  109. data/spec/dummy_app/app/models/.keep +0 -0
  110. data/spec/dummy_app/app/models/comment.rb +32 -0
  111. data/spec/dummy_app/app/models/concerns/.keep +0 -0
  112. data/spec/dummy_app/app/models/post.rb +17 -0
  113. data/spec/dummy_app/app/models/user.rb +21 -0
  114. data/spec/dummy_app/app/views/layouts/admin.html.haml +25 -0
  115. data/spec/dummy_app/app/views/layouts/application.html.haml +20 -0
  116. data/spec/dummy_app/app/views/posts/index.html.haml +22 -0
  117. data/spec/dummy_app/app/views/posts/show.html.haml +7 -0
  118. data/spec/dummy_app/bin/bundle +3 -0
  119. data/spec/dummy_app/bin/rails +4 -0
  120. data/spec/dummy_app/bin/rake +4 -0
  121. data/spec/dummy_app/config/application.rb +23 -0
  122. data/spec/dummy_app/config/boot.rb +4 -0
  123. data/spec/dummy_app/config/database.yml +11 -0
  124. data/spec/dummy_app/config/environment.rb +5 -0
  125. data/spec/dummy_app/config/environments/development.rb +29 -0
  126. data/spec/dummy_app/config/environments/production.rb +80 -0
  127. data/spec/dummy_app/config/environments/test.rb +36 -0
  128. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
  129. data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
  130. data/spec/dummy_app/config/initializers/inflections.rb +16 -0
  131. data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
  132. data/spec/dummy_app/config/initializers/secret_token.rb +12 -0
  133. data/spec/dummy_app/config/initializers/session_store.rb +3 -0
  134. data/spec/dummy_app/config/initializers/sorcery.rb +437 -0
  135. data/spec/dummy_app/config/initializers/the_comments.rb +14 -0
  136. data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
  137. data/spec/dummy_app/config/locales/en.yml +23 -0
  138. data/spec/dummy_app/config/routes.rb +19 -0
  139. data/spec/dummy_app/config.ru +4 -0
  140. data/spec/dummy_app/db/migrate/20130712061503_sorcery_core.rb +16 -0
  141. data/spec/dummy_app/db/migrate/20130712065951_create_posts.rb +11 -0
  142. data/spec/dummy_app/db/migrate/20131027185332_change_user.the_comments_engine.rb +19 -0
  143. data/spec/dummy_app/db/migrate/20131027185333_create_comments.the_comments_engine.rb +51 -0
  144. data/spec/dummy_app/db/migrate/20131027185334_change_commentable.the_comments_engine.rb +14 -0
  145. data/spec/dummy_app/db/schema.rb +74 -0
  146. data/spec/dummy_app/db/seeds.rb +42 -0
  147. data/spec/dummy_app/lib/assets/.keep +0 -0
  148. data/spec/dummy_app/lib/tasks/.keep +0 -0
  149. data/spec/dummy_app/lib/tasks/app_bootstrap.rake +15 -0
  150. data/spec/dummy_app/log/.keep +0 -0
  151. data/spec/dummy_app/public/404.html +58 -0
  152. data/spec/dummy_app/public/422.html +58 -0
  153. data/spec/dummy_app/public/500.html +57 -0
  154. data/spec/dummy_app/public/favicon.ico +0 -0
  155. data/spec/dummy_app/public/robots.txt +5 -0
  156. data/spec/dummy_app/spec/factories/post.rb +6 -0
  157. data/spec/dummy_app/spec/factories/user.rb +6 -0
  158. data/spec/dummy_app/spec/models/user_counters_spec.rb +339 -0
  159. data/spec/dummy_app/spec/spec_helper.rb +29 -0
  160. data/spec/dummy_app/test/controllers/.keep +0 -0
  161. data/spec/dummy_app/test/fixtures/.keep +0 -0
  162. data/spec/dummy_app/test/helpers/.keep +0 -0
  163. data/spec/dummy_app/test/integration/.keep +0 -0
  164. data/spec/dummy_app/test/mailers/.keep +0 -0
  165. data/spec/dummy_app/test/models/.keep +0 -0
  166. data/spec/dummy_app/test/test_helper.rb +15 -0
  167. data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
  168. data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
  169. data/the_comments.gemspec +25 -0
  170. data/the_comments.yml.teamocil.example +11 -0
  171. data/views_converter.rb +16 -0
  172. metadata +333 -0
@@ -0,0 +1,437 @@
1
+ # The first thing you need to configure is which modules you need in your app.
2
+ # The default is nothing which will include only core features (password encryption, login/logout).
3
+ # Available submodules are: :user_activation, :http_basic_auth, :remember_me,
4
+ # :reset_password, :session_timeout, :brute_force_protection, :activity_logging, :external
5
+ Rails.application.config.sorcery.submodules = [:reset_password]
6
+
7
+ # Here you can configure each submodule's features.
8
+ Rails.application.config.sorcery.configure do |config|
9
+ # -- core --
10
+ # What controller action to call for non-authenticated users. You can also
11
+ # override the 'not_authenticated' method of course.
12
+ # Default: `:not_authenticated`
13
+ #
14
+ # config.not_authenticated_action =
15
+
16
+
17
+ # When a non logged in user tries to enter a page that requires login, save
18
+ # the URL he wanted to reach, and send him there after login, using 'redirect_back_or_to'.
19
+ # Default: `true`
20
+ #
21
+ # config.save_return_to_url =
22
+
23
+
24
+ # Set domain option for cookies; Useful for remember_me submodule.
25
+ # Default: `nil`
26
+ #
27
+ # config.cookie_domain =
28
+
29
+
30
+ # -- session timeout --
31
+ # How long in seconds to keep the session alive.
32
+ # Default: `3600`
33
+ #
34
+ # config.session_timeout =
35
+
36
+
37
+ # Use the last action as the beginning of session timeout.
38
+ # Default: `false`
39
+ #
40
+ # config.session_timeout_from_last_action =
41
+
42
+
43
+ # -- http_basic_auth --
44
+ # What realm to display for which controller name. For example {"My App" => "Application"}
45
+ # Default: `{"application" => "Application"}`
46
+ #
47
+ # config.controller_to_realm_map =
48
+
49
+
50
+ # -- activity logging --
51
+ # will register the time of last user login, every login.
52
+ # Default: `true`
53
+ #
54
+ # config.register_login_time =
55
+
56
+
57
+ # will register the time of last user logout, every logout.
58
+ # Default: `true`
59
+ #
60
+ # config.register_logout_time =
61
+
62
+
63
+ # will register the time of last user action, every action.
64
+ # Default: `true`
65
+ #
66
+ # config.register_last_activity_time =
67
+
68
+
69
+ # -- external --
70
+ # What providers are supported by this app, i.e. [:twitter, :facebook, :github, :linkedin, :xing, :google, :liveid] .
71
+ # Default: `[]`
72
+ #
73
+ # config.external_providers =
74
+
75
+
76
+ # You can change it by your local ca_file. i.e. '/etc/pki/tls/certs/ca-bundle.crt'
77
+ # Path to ca_file. By default use a internal ca-bundle.crt.
78
+ # Default: `'path/to/ca_file'`
79
+ #
80
+ # config.ca_file =
81
+
82
+
83
+ # For information about LinkedIn API:
84
+ # - user info fields go to https://developer.linkedin.com/documents/profile-fields
85
+ # - access permissions go to https://developer.linkedin.com/documents/authentication#granting
86
+ #
87
+ # config.linkedin.key = ""
88
+ # config.linkedin.secret = ""
89
+ # config.linkedin.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=linkedin"
90
+ # config.linkedin.user_info_fields = ['first-name', 'last-name']
91
+ # config.linkedin.user_info_mapping = {first_name: "firstName", last_name: "lastName"}
92
+ # config.linkedin.access_permissions = ['r_basicprofile']
93
+ #
94
+ #
95
+ # For information about XING API:
96
+ # - user info fields go to https://dev.xing.com/docs/get/users/me
97
+ #
98
+ # config.xing.key = ""
99
+ # config.xing.secret = ""
100
+ # config.xing.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=xing"
101
+ # config.xing.user_info_mapping = {first_name: "first_name", last_name: "last_name"}
102
+ #
103
+ #
104
+ # Twitter wil not accept any requests nor redirect uri containing localhost,
105
+ # make sure you use 0.0.0.0:3000 to access your app in development
106
+ #
107
+ # config.twitter.key = ""
108
+ # config.twitter.secret = ""
109
+ # config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter"
110
+ # config.twitter.user_info_mapping = {:email => "screen_name"}
111
+ #
112
+ # config.facebook.key = ""
113
+ # config.facebook.secret = ""
114
+ # config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook"
115
+ # config.facebook.user_info_mapping = {:email => "name"}
116
+ # config.facebook.access_permissions = ["email", "publish_stream"]
117
+ #
118
+ # config.github.key = ""
119
+ # config.github.secret = ""
120
+ # config.github.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=github"
121
+ # config.github.user_info_mapping = {:email => "name"}
122
+ #
123
+ # config.google.key = ""
124
+ # config.google.secret = ""
125
+ # config.google.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=google"
126
+ # config.google.user_info_mapping = {:email => "email", :username => "name"}
127
+ #
128
+ # config.vk.key = ""
129
+ # config.vk.secret = ""
130
+ # config.vk.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=vk"
131
+ # config.vk.user_info_mapping = {:login => "domain", :name => "full_name"}
132
+ #
133
+ # To use liveid in development mode you have to replace mydomain.com with
134
+ # a valid domain even in development. To use a valid domain in development
135
+ # simply add your domain in your /etc/hosts file in front of 127.0.0.1
136
+ #
137
+ # config.liveid.key = ""
138
+ # config.liveid.secret = ""
139
+ # config.liveid.callback_url = "http://mydomain.com:3000/oauth/callback?provider=liveid"
140
+ # config.liveid.user_info_mapping = {:username => "name"}
141
+
142
+
143
+ # --- user config ---
144
+ config.user_config do |user|
145
+ # -- core --
146
+ # specify username attributes, for example: [:username, :email].
147
+ # Default: `[:username]`
148
+ #
149
+ # user.username_attribute_names =
150
+
151
+
152
+ # change *virtual* password attribute, the one which is used until an encrypted one is generated.
153
+ # Default: `:password`
154
+ #
155
+ # user.password_attribute_name =
156
+
157
+
158
+ # downcase the username before trying to authenticate, default is false
159
+ # Default: `false`
160
+ #
161
+ # user.downcase_username_before_authenticating =
162
+
163
+
164
+ # change default email attribute.
165
+ # Default: `:email`
166
+ #
167
+ # user.email_attribute_name =
168
+
169
+
170
+ # change default crypted_password attribute.
171
+ # Default: `:crypted_password`
172
+ #
173
+ # user.crypted_password_attribute_name =
174
+
175
+
176
+ # what pattern to use to join the password with the salt
177
+ # Default: `""`
178
+ #
179
+ # user.salt_join_token =
180
+
181
+
182
+ # change default salt attribute.
183
+ # Default: `:salt`
184
+ #
185
+ # user.salt_attribute_name =
186
+
187
+
188
+ # how many times to apply encryption to the password.
189
+ # Default: `nil`
190
+ #
191
+ # user.stretches =
192
+
193
+
194
+ # encryption key used to encrypt reversible encryptions such as AES256.
195
+ # WARNING: If used for users' passwords, changing this key will leave passwords undecryptable!
196
+ # Default: `nil`
197
+ #
198
+ # user.encryption_key =
199
+
200
+
201
+ # use an external encryption class.
202
+ # Default: `nil`
203
+ #
204
+ # user.custom_encryption_provider =
205
+
206
+
207
+ # encryption algorithm name. See 'encryption_algorithm=' for available options.
208
+ # Default: `:bcrypt`
209
+ #
210
+ # user.encryption_algorithm =
211
+
212
+
213
+ # make this configuration inheritable for subclasses. Useful for ActiveRecord's STI.
214
+ # Default: `false`
215
+ #
216
+ # user.subclasses_inherit_config =
217
+
218
+
219
+ # -- remember_me --
220
+ # allow the remember_me cookie to settable through AJAX
221
+ # Default: `true`
222
+ #
223
+ # user.remember_me_httponly =
224
+
225
+ # How long in seconds the session length will be
226
+ # Default: `604800`
227
+ #
228
+ # user.remember_me_for =
229
+
230
+
231
+ # -- user_activation --
232
+ # the attribute name to hold activation state (active/pending).
233
+ # Default: `:activation_state`
234
+ #
235
+ # user.activation_state_attribute_name =
236
+
237
+
238
+ # the attribute name to hold activation code (sent by email).
239
+ # Default: `:activation_token`
240
+ #
241
+ # user.activation_token_attribute_name =
242
+
243
+
244
+ # the attribute name to hold activation code expiration date.
245
+ # Default: `:activation_token_expires_at`
246
+ #
247
+ # user.activation_token_expires_at_attribute_name =
248
+
249
+
250
+ # how many seconds before the activation code expires. nil for never expires.
251
+ # Default: `nil`
252
+ #
253
+ # user.activation_token_expiration_period =
254
+
255
+
256
+ # your mailer class. Required.
257
+ # Default: `nil`
258
+ #
259
+ # user.user_activation_mailer =
260
+
261
+
262
+ # when true sorcery will not automatically
263
+ # email activation details and allow you to
264
+ # manually handle how and when email is sent.
265
+ # Default: `false`
266
+ #
267
+ # user.activation_mailer_disabled =
268
+
269
+
270
+ # activation needed email method on your mailer class.
271
+ # Default: `:activation_needed_email`
272
+ #
273
+ # user.activation_needed_email_method_name =
274
+
275
+
276
+ # activation success email method on your mailer class.
277
+ # Default: `:activation_success_email`
278
+ #
279
+ # user.activation_success_email_method_name =
280
+
281
+
282
+ # do you want to prevent or allow users that did not activate by email to login?
283
+ # Default: `true`
284
+ #
285
+ # user.prevent_non_active_users_to_login =
286
+
287
+
288
+ # -- reset_password --
289
+ # reset password code attribute name.
290
+ # Default: `:reset_password_token`
291
+ #
292
+ # user.reset_password_token_attribute_name =
293
+
294
+
295
+ # expires at attribute name.
296
+ # Default: `:reset_password_token_expires_at`
297
+ #
298
+ # user.reset_password_token_expires_at_attribute_name =
299
+
300
+
301
+ # when was email sent, used for hammering protection.
302
+ # Default: `:reset_password_email_sent_at`
303
+ #
304
+ # user.reset_password_email_sent_at_attribute_name =
305
+
306
+
307
+ # mailer class. Needed.
308
+ # Default: `nil`
309
+ #
310
+ # user.reset_password_mailer = ResetPasswordMailer
311
+
312
+
313
+ # reset password email method on your mailer class.
314
+ # Default: `:reset_password_email`
315
+ #
316
+ # user.reset_password_email_method_name =
317
+
318
+
319
+ # when true sorcery will not automatically
320
+ # email password reset details and allow you to
321
+ # manually handle how and when email is sent
322
+ # Default: `false`
323
+ #
324
+ user.reset_password_mailer_disabled = true
325
+
326
+
327
+ # how many seconds before the reset request expires. nil for never expires.
328
+ # Default: `nil`
329
+ #
330
+ # user.reset_password_expiration_period =
331
+
332
+
333
+ # hammering protection, how long to wait before allowing another email to be sent.
334
+ # Default: `5 * 60`
335
+ #
336
+ # user.reset_password_time_between_emails =
337
+
338
+
339
+ # -- brute_force_protection --
340
+ # Failed logins attribute name.
341
+ # Default: `:failed_logins_count`
342
+ #
343
+ # user.failed_logins_count_attribute_name =
344
+
345
+
346
+ # This field indicates whether user is banned and when it will be active again.
347
+ # Default: `:lock_expires_at`
348
+ #
349
+ # user.lock_expires_at_attribute_name =
350
+
351
+
352
+ # How many failed logins allowed.
353
+ # Default: `50`
354
+ #
355
+ # user.consecutive_login_retries_amount_limit =
356
+
357
+
358
+ # How long the user should be banned. in seconds. 0 for permanent.
359
+ # Default: `60 * 60`
360
+ #
361
+ # user.login_lock_time_period =
362
+
363
+ # Unlock token attribute name
364
+ # Default: `:unlock_token`
365
+ #
366
+ # user.unlock_token_attribute_name =
367
+
368
+ # Unlock token mailer method
369
+ # Default: `:send_unlock_token_email`
370
+ #
371
+ # user.unlock_token_email_method_name =
372
+
373
+ # when true sorcery will not automatically
374
+ # send email with unlock token
375
+ # Default: `false`
376
+ #
377
+ # user.unlock_token_mailer_disabled = true
378
+
379
+ # Unlock token mailer class
380
+ # Default: `nil`
381
+ #
382
+ # user.unlock_token_mailer = UserMailer
383
+
384
+ # -- activity logging --
385
+ # Last login attribute name.
386
+ # Default: `:last_login_at`
387
+ #
388
+ # user.last_login_at_attribute_name =
389
+
390
+
391
+ # Last logout attribute name.
392
+ # Default: `:last_logout_at`
393
+ #
394
+ # user.last_logout_at_attribute_name =
395
+
396
+
397
+ # Last activity attribute name.
398
+ # Default: `:last_activity_at`
399
+ #
400
+ # user.last_activity_at_attribute_name =
401
+
402
+
403
+ # How long since last activity is he user defined logged out?
404
+ # Default: `10 * 60`
405
+ #
406
+ # user.activity_timeout =
407
+
408
+
409
+ # -- external --
410
+ # Class which holds the various external provider data for this user.
411
+ # Default: `nil`
412
+ #
413
+ # user.authentications_class =
414
+
415
+
416
+ # User's identifier in authentications class.
417
+ # Default: `:user_id`
418
+ #
419
+ # user.authentications_user_id_attribute_name =
420
+
421
+
422
+ # Provider's identifier in authentications class.
423
+ # Default: `:provider`
424
+ #
425
+ # user.provider_attribute_name =
426
+
427
+
428
+ # User's external unique identifier in authentications class.
429
+ # Default: `:uid`
430
+ #
431
+ # user.provider_uid_attribute_name =
432
+ end
433
+
434
+ # This line must come after the 'user config' block.
435
+ # Define which model authenticates with sorcery.
436
+ config.user_class = "User"
437
+ end
@@ -0,0 +1,14 @@
1
+ # TheComments.config.param_name => value
2
+
3
+ TheComments.configure do |config|
4
+ config.max_reply_depth = 3 # comments tree depth
5
+ config.tolerance_time = 5 # sec - after this delay user can post a comment
6
+ config.default_state = :draft # default state for comment
7
+ config.default_owner_state = :published # default state for comment for Moderator
8
+ config.empty_inputs = [:commentBody] # array of spam trap fields
9
+ config.default_title = 'Undefined title' # default commentable_title for denormalization
10
+ config.template_engine = :haml
11
+
12
+ config.empty_trap_protection = true
13
+ config.tolerance_time_protection = true
14
+ end
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,19 @@
1
+ App::Application.routes.draw do
2
+ root 'posts#index'
3
+
4
+ get "autologin/:id" => "users#autologin", as: :autologin
5
+
6
+ # Login system
7
+ get "login" => "sessions#new", as: :login
8
+ delete "logout" => "sessions#destroy", as: :logout
9
+ get "signup" => "users#new", as: :signup
10
+ post "sessions" => "sessions#create", as: :sessions
11
+
12
+ resources :posts
13
+ resources :users
14
+
15
+ # TheComments routes
16
+ concern :user_comments, TheComments::UserRoutes.new
17
+ concern :admin_comments, TheComments::AdminRoutes.new
18
+ resources :comments, concerns: [:user_comments, :admin_comments]
19
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,16 @@
1
+ class SorceryCore < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :username, :null => false # if you use another field as a username, for example email, you can safely remove this field.
5
+ t.string :email, :default => nil # if you use this field as a username, you might want to make it :null => false.
6
+ t.string :crypted_password, :default => nil
7
+ t.string :salt, :default => nil
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :users
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+ t.integer :user_id
5
+ t.string :title
6
+ t.text :content
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # This migration comes from the_comments_engine (originally 20130101010101)
2
+ # null: false => de-facto db-level validation
3
+ class ChangeUser < ActiveRecord::Migration
4
+ def change
5
+ change_table :users do |t|
6
+ # "Written by me" (cache counters)
7
+ t.integer :my_draft_comments_count, default: 0
8
+ t.integer :my_published_comments_count, default: 0
9
+ t.integer :my_comments_count, default: 0 # my_draft_comments_count + my_published_comments_count
10
+
11
+ # commentable's comments => comcoms (cache counters)
12
+ # Relation through Comment#holder_id field
13
+ t.integer :draft_comcoms_count, default: 0
14
+ t.integer :published_comcoms_count, default: 0
15
+ t.integer :deleted_comcoms_count, default: 0
16
+ t.integer :spam_comcoms_count, default: 0
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,51 @@
1
+ # This migration comes from the_comments_engine (originally 20130101010102)
2
+ class CreateComments < ActiveRecord::Migration
3
+ def change
4
+ create_table :comments do |t|
5
+ # relations
6
+ t.integer :user_id
7
+ t.integer :holder_id
8
+
9
+ # polymorphic, commentable object
10
+ t.integer :commentable_id
11
+ t.string :commentable_type
12
+
13
+ # denormalization
14
+ t.string :commentable_url
15
+ t.string :commentable_title
16
+ t.string :commentable_state
17
+
18
+ # comment
19
+ t.string :anchor
20
+
21
+ t.string :title
22
+ t.string :contacts
23
+
24
+ t.text :raw_content
25
+ t.text :content
26
+
27
+ # moderation token
28
+ t.string :view_token
29
+
30
+ # state machine => :draft | :published | :deleted
31
+ t.string :state, default: :draft
32
+
33
+ # base user data (BanHammer power)
34
+ t.string :ip, default: :undefined
35
+ t.string :referer, default: :undefined
36
+ t.string :user_agent, default: :undefined
37
+ t.integer :tolerance_time
38
+
39
+ # unusable: for future versions
40
+ t.boolean :spam, default: false
41
+
42
+ # nested set
43
+ t.integer :parent_id
44
+ t.integer :lft
45
+ t.integer :rgt
46
+ t.integer :depth, default: 0
47
+
48
+ t.timestamps
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,14 @@
1
+ # This migration comes from the_comments_engine (originally 20130101010103)
2
+ class ChangeCommentable < ActiveRecord::Migration
3
+ def change
4
+ # Uncomment this. Add fields to Commentable Models
5
+ #
6
+ [:users, :posts].each do |table_name|
7
+ change_table table_name do |t|
8
+ t.integer :draft_comments_count, default: 0
9
+ t.integer :published_comments_count, default: 0
10
+ t.integer :deleted_comments_count, default: 0
11
+ end
12
+ end
13
+ end
14
+ end