commontator 4.10.5 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -2
  3. data/Rakefile +8 -9
  4. data/app/assets/javascripts/commontator/application.js +3 -0
  5. data/app/assets/javascripts/commontator/application.js~ +3 -0
  6. data/app/assets/javascripts/commontator/mentions.js +32 -0
  7. data/app/assets/javascripts/commontator/mentions.js~ +31 -0
  8. data/app/assets/stylesheets/commontator/application.css +1 -9
  9. data/app/assets/stylesheets/commontator/application.css~ +14 -0
  10. data/app/assets/stylesheets/commontator/threads.css +5 -0
  11. data/app/assets/stylesheets/commontator/threads.css~ +71 -0
  12. data/app/controllers/commontator/comments_controller.rb +8 -0
  13. data/app/controllers/commontator/comments_controller.rb~ +160 -0
  14. data/app/controllers/commontator/threads_controller.rb +21 -0
  15. data/app/controllers/commontator/threads_controller.rb~ +75 -0
  16. data/app/mailers/commontator/subscriptions_mailer.rb +31 -13
  17. data/app/mailers/commontator/subscriptions_mailer.rb~ +65 -0
  18. data/app/models/commontator/comment.rb~ +124 -0
  19. data/app/models/commontator/subscription.rb~ +23 -0
  20. data/app/views/commontator/comments/_form.html.erb +1 -0
  21. data/app/views/commontator/comments/_list.html.erb +1 -1
  22. data/app/views/commontator/shared/_thread.html.erb +2 -4
  23. data/app/views/commontator/shared/_thread.html.erb~ +21 -0
  24. data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +1 -1
  25. data/app/views/commontator/subscriptions_mailer/comment_created.html.erb~ +10 -0
  26. data/app/views/commontator/threads/_hide_show.js.erb~ +21 -0
  27. data/app/views/commontator/threads/_hide_show_links.js.erb +17 -0
  28. data/app/views/commontator/threads/_hide_show_links.js.erb~ +17 -0
  29. data/app/views/commontator/threads/_show.html.erb +96 -72
  30. data/app/views/commontator/threads/_show.html.erb~ +118 -0
  31. data/app/views/commontator/threads/_show.js.erb~ +18 -0
  32. data/config/initializers/commontator.rb +39 -8
  33. data/config/initializers/commontator.rb~ +290 -0
  34. data/config/locales/en.yml +3 -2
  35. data/config/locales/en.yml~ +101 -0
  36. data/config/locales/ru.yml +3 -2
  37. data/config/locales/ru.yml~ +79 -0
  38. data/config/locales/zh.yml +79 -0
  39. data/config/locales/zh.yml~ +79 -0
  40. data/config/routes.rb +2 -0
  41. data/config/routes.rb~ +25 -0
  42. data/db/migrate/0_install_commontator.rb~ +52 -0
  43. data/db/migrate/1_add_parent_comment_id_to_commontator_comments.rb~ +9 -0
  44. data/lib/commontator.rb +16 -9
  45. data/lib/commontator.rb~ +145 -0
  46. data/lib/commontator/{controller_includes.rb → controllers.rb} +2 -2
  47. data/lib/commontator/shared_helper.rb~ +26 -0
  48. data/lib/commontator/version.rb +1 -1
  49. data/lib/commontator/version.rb~ +3 -0
  50. data/spec/controllers/commontator/comments_controller_spec.rb +46 -0
  51. data/spec/controllers/commontator/comments_controller_spec.rb~ +612 -0
  52. data/spec/controllers/commontator/subscriptions_controller_spec.rb~ +101 -0
  53. data/spec/controllers/commontator/threads_controller_spec.rb +88 -0
  54. data/spec/controllers/commontator/threads_controller_spec.rb~ +218 -0
  55. data/spec/dummy/README.md~ +3 -0
  56. data/spec/dummy/Rakefile~ +6 -0
  57. data/spec/dummy/app/assets/javascripts/application.js +1 -0
  58. data/spec/dummy/app/assets/javascripts/application.js~ +16 -0
  59. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  60. data/spec/dummy/app/assets/stylesheets/application.css~ +14 -0
  61. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  62. data/spec/dummy/app/controllers/application_controller.rb~ +4 -0
  63. data/spec/dummy/app/controllers/dummy_models_controller.rb +3 -15
  64. data/spec/dummy/app/controllers/dummy_models_controller.rb~ +23 -0
  65. data/spec/dummy/app/helpers/application_helper.rb~ +15 -0
  66. data/spec/dummy/app/models/dummy_model.rb~ +3 -0
  67. data/spec/dummy/app/models/dummy_user.rb~ +13 -0
  68. data/spec/dummy/app/views/dummy_models/index.html.erb~ +6 -0
  69. data/spec/dummy/app/views/{dummy_model → dummy_models}/show.html.erb +0 -0
  70. data/spec/dummy/app/views/dummy_models/show.html.erb~ +2 -0
  71. data/spec/dummy/app/views/layouts/application.html.erb~ +14 -0
  72. data/spec/dummy/config.ru~ +4 -0
  73. data/spec/dummy/config/application.rb~ +26 -0
  74. data/spec/dummy/config/boot.rb~ +5 -0
  75. data/spec/dummy/config/database.yml~ +25 -0
  76. data/spec/dummy/config/environment.rb +2 -0
  77. data/spec/dummy/config/environment.rb~ +8 -0
  78. data/spec/dummy/config/environments/development.rb~ +31 -0
  79. data/spec/dummy/config/environments/production.rb~ +82 -0
  80. data/spec/dummy/config/environments/test.rb~ +40 -0
  81. data/spec/dummy/config/initializers/backtrace_silencers.rb~ +7 -0
  82. data/spec/dummy/config/initializers/commontator.rb +5 -0
  83. data/spec/dummy/config/initializers/commontator.rb~ +21 -0
  84. data/spec/dummy/config/initializers/filter_parameter_logging.rb~ +4 -0
  85. data/spec/dummy/config/initializers/inflections.rb~ +16 -0
  86. data/spec/dummy/config/initializers/mime_types.rb~ +5 -0
  87. data/spec/dummy/config/initializers/secret_token.rb~ +12 -0
  88. data/spec/dummy/config/initializers/session_store.rb~ +3 -0
  89. data/spec/dummy/config/initializers/wrap_parameters.rb~ +14 -0
  90. data/spec/dummy/config/routes.rb +4 -2
  91. data/spec/dummy/config/routes.rb~ +10 -0
  92. data/spec/dummy/db/development.sqlite3 +0 -0
  93. data/spec/dummy/db/migrate/1_create_dummy_models.rb~ +7 -0
  94. data/spec/dummy/db/migrate/2_create_dummy_users.rb~ +7 -0
  95. data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb~ +27 -0
  96. data/spec/dummy/db/schema.rb +6 -6
  97. data/spec/dummy/db/test.sqlite3 +0 -0
  98. data/spec/dummy/lib/controllers.rb~ +10 -0
  99. data/spec/dummy/lib/dummy_controllers.rb +10 -0
  100. data/spec/dummy/log/development.log +5825 -29
  101. data/spec/dummy/log/test.log +111962 -32939
  102. data/spec/dummy/public/404.html~ +26 -0
  103. data/spec/dummy/public/422.html~ +26 -0
  104. data/spec/dummy/public/500.html~ +25 -0
  105. data/spec/dummy/script/rails~ +6 -0
  106. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/-RolHYhJdGiLoPkoWZXQdI9AIWUjMMCa2yFJezCE_Bo.cache +2 -0
  107. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/-STzK7UuGeY3gSvnmTELWLvtRMKpmSAQCEw4ao3b1r8.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/3NH8nN7uktAXgA3NqaqXTXDVic3BxBvqCxoLpGGbib4.cache +0 -0
  109. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/4_iT7KM6P2IT75Rssrk9p4crTBwM8DQWR41gmsxczL0.cache +0 -0
  110. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/58TLCXvf5bFFYY-mIUXrQNOVWlGsq7qPAoSX2OIIB8Y.cache +0 -0
  111. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6OQdyrATvNatvWu8Mp1qbuvRx-HLmzCZ5XBGYca-rZU.cache +0 -0
  112. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6UKCUV-ZLaWCoPMfMB6a2W0RCFPQzPJ6Mz-y67sH7zk.cache +2 -0
  113. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6wKNjFdNd4OHjIpLC0nq1kBWcbYg1aEYrp7ZhWoJlvY.cache +1 -0
  114. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/7Xxb5iYP5elo40JRlhNQB1gLbv3ueELK2rTinYt5xdc.cache +1 -0
  115. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/7twIKlS6VYCyLlwhsQg2vu4wLSUJsT2REHR4DjZf1oE.cache +2 -0
  116. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/87m-4EcbQnkbo2HYkQp4V9I2U3AYQO1mPeReieduolA.cache +1 -0
  117. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/8B331vt8qC4iXTcVzkx3j-ET8i1oaQskj5LyqGq8mPQ.cache +0 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/8KWvIOgvo7BVJYtdTpFuiSQQFFwZhLWYtwacZv52y48.cache +0 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/9yQa5M2ObK2-qDu231zMoarjVbhKUUg-ND3r2iXqB_Q.cache +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/A-ffuUI2juZT6qFpTUwUR1P8OPWcyFFN26WSUZe60Ko.cache +1 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/BbO4diS6uacx69Hn_bCabYlXEbWWdjHShRlfzlWSOMI.cache +0 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/CXhqxaQQAQ8b0Y8y0jTQyiqsZ6Oe4fZn0YiacpJ9IoI.cache +1 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/E1zaNOh68xzPxdtdOwRtOaMCoKivN2dxVwCP65WEi5I.cache +2 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/EmPkV3H8p2Snv9WyPjWran_kOMQ0MqQ1a9CVdGDd8l4.cache +1 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Hc12Nxe7cw2e0u2pzNsAe8D3ncQpcqLuI2NVL7aAXgw.cache +1 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/HdWuQr9W2mZvggsAxVjDgLYUNfg3rbI-T8KhaDIsvQk.cache +0 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/I7lsrHTKpbfLWqIqdDIx2RN_12yFL2PyLRyYsMxg1IU.cache +1 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JOCzfBjMjX3D5BUUGh5lJ7fjzMuJrHLxAginRA2_hZQ.cache +0 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JusxTSXt06IqBm9jeCMM2nTmM3Wvbl3i3L1IwEvW5YA.cache +2 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KAY1_IaTONtGr0KK8ihOdoA-RDXybqBMNSZLIDRHx68.cache +1 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KBHIDNfa4ryw9LAkYqK8GgPWne7HkX6mNYgrJajGm94.cache +1 -0
  132. data/spec/dummy/tmp/cache/assets/{test/sprockets/v3.0/E6KZN1luOC7jAKXFS_xo-XOd5H41vK-eeCsj8MITJHA.cache → development/sprockets/v3.0/L_lv02y00MmIFiFhg5c9zhl7CDHLSahehzLyi_mRZeY.cache} +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MOT2X4iikR8v89A4N1bxDTeS1-xV8c9036TNFXmwXCM.cache +1 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MiX2Z4Vbha1riozZWw1U3_PGttRiZ1iQ_o4wSZJnKCs.cache +3 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MntKfwol0ud4LuvrX3MVPthTlfNlJZRYbQXpQBxhRrs.cache +1 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MrqmgPGNYJV1capJKIKJOVEQ4NiO-Z_2YhpjNteJ8B8.cache +2 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NVMnAwylzGp5bjl_o9dwMAQxVAPDzc4ygddNQSD1fiw.cache +0 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/O2sKqGxNuCYhjzuEZVC9hX_FeemOfRn_1-CCuHBQYyg.cache +1 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Qy3TykLFmAt5jhSluMTaZaefcA5c_vfBRhQ7tin-gsk.cache +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/R3DpUgZ_hja1dQTIzumiP9AD_r8mlOaqv0U9QqnGQqo.cache +0 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/RF07mgb06A30OcDWtCaDlM5tEc1yp0uAsk986Gqs5w8.cache +1 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/S-6Iq5YOEpVnd_vQ0RSSfrmyIwB1dk0op35alFgJ9xA.cache +2 -0
  143. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/TKV8dUTo88gdFY-z2I7Xa5vDC1Z3LY6Paa18385MJsI.cache +1 -0
  144. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UI4zPmWfZA2d_5ZZIXqK9KmkjOKSDg6JoM7qcOIxm0Q.cache +1 -0
  145. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UP29vrIQbCkfghZGSCFxpW5gjlsgCxlVrncjjopvRqM.cache +2 -0
  146. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UoU16f4V7haEXM5GY5j4QFuNMP7PJZaAMEvVNNtNLBA.cache +1 -0
  147. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/VqPqYNG07yqcjbd7FA05Mu-jr5hzsZPaHFf8X0FFbXk.cache +2 -0
  148. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/WkN1QFvcuzXSsyNmfaK02ojXPk-8zmdEegzNPfdAEL4.cache +0 -0
  149. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/WkQX7Wiz41OKx2aGF7uffOmS04hIVZeGCondBAvwum8.cache +2 -0
  150. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/XMeYF1vwAg53eVjXVkw_IKQH2W3-9tWvtuCdqUCbPBM.cache +2 -0
  151. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/XX0Z7OM0xZKfQaAvHARpyeQNZCstNyu9MlsnwThSkg8.cache +1 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Y-pGNFTA6bAKxSvqZvmMVs3b4Els1aByxZVFxtJR71c.cache +1 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Y3p3m5V5NOm7yq56apKmF5KZUUsTfnhT_SG3fqbEJgo.cache +1 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/YLZuRWklL6q-csC-7A7CiOTTTYEQcA9PCdWEOm9MpNU.cache +1 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Yo7V5YXukEBm6z37l-TIRCJx3HZExEUBu3MUMhAzkMU.cache +1 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/bK6QttR8pGmMAMJO0avCBLwH0za8_bAC-yWqkU3Yj24.cache +1 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/cLncjrqpQXzsVBp7K0W7iG1STLrnzfGpbJXxNE7aIUk.cache +2 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/dBcAd64EZFdhHZNXKGXPIR7EtPGf03bzqkci2W12T8g.cache +2 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/d_bbPiareJHKkzFZFCl3pcwfQOFzsB1KHn4A2xxhR20.cache +1 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/eaHZBuJRcawVlkGZVyyRr5_4xYKVOXbCqnTcmaNXzL0.cache +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/gWnmfJty3jBn53qsJfOXKrWv4e8i3Dp80wVel-f1L1E.cache +1 -0
  162. data/spec/dummy/tmp/cache/assets/{test/sprockets/v3.0/SN7TWtuyq1ZblzWxqqcr26s_vanAr5PyZ8q_w8IxIPE.cache → development/sprockets/v3.0/gumo32Bd3W_q7MYEt9JIZEiQdHF93tLSsGfmXIm2MqU.cache} +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/jKTlG9KP0iaCGHwg8kQ1amz9SHJ1OAWeCRRn9wc5w7c.cache +1 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kPJfTiWbmX-q6i2rjM9MAMdEf2silSihU0_lxlTGVA8.cache +1 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lrt1SWPj4qWUZUMH9xg3n9KLYUqJZxRn-XI-NTU6oTI.cache +1 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/mcCP5u08nlCL6TgWdzzrem9uE2rbsbG3KyIXxvWvlJE.cache +3 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/pC4exGjkQLXXPE0O9hjX_2AJ4DASTFeB6RGjXagxEac.cache +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/pIRh_Lq-ZhYC_XdRcqIsCtUkTnwVET0Wrrpw1EltHd8.cache +2 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/qfXc71sDbi1cE9f327D6ABPURPU6lLguGiJqH2fqM0w.cache +1 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/rBcrkzXcMaiCjwvWl8tO0eARzKZS69I3i-lfsTAFzcc.cache +1 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/sfl8l1_1AGn-4llkmb91Q0wHJ-A-x5gAGkIUWe1zLqo.cache +1 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/tFQc0MOeWpJ7t7cNP2GOzo7o9Z6YBgLEpdS0tGLvUSw.cache +0 -0
  173. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/tb9v5OemP-ADEwYnETLLi1r088kZm_TMb9ZVeTV5JxI.cache +1 -0
  174. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/uKmWfbgaNZ8FTsVK1VNuUv15rmtTHzSdJ7TQRGr0Rck.cache +2 -0
  175. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ul0QEoovfr_12YOpyWx8BJs8fvz5Ay3AZG8-lsLr-a4.cache +1 -0
  176. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/vY6eUgBIXKHqfU2ZroS-GugKPg5_fo2QBs-vS5gBN2o.cache +0 -0
  177. data/spec/dummy/tmp/cache/assets/{test/sprockets/v3.0/Kg9VuIGtHRNvM4_TXG3EmqpEWzfEY1kQUI1Mx8AHklY.cache → development/sprockets/v3.0/vrRc4DPAbHIJHJqsXfBYdyKUPFv8f8YYKJUrk-1zdVw.cache} +0 -0
  178. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/wTET4PQq7wlxzrgvNivPJad-CACkoQS4BNxAP0FQaR4.cache +0 -0
  179. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/wcvE87iLx7cDjMDs_Yu1jKYvep-VyLEyj1eXL79KLp4.cache +0 -0
  180. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/xQeZ92qbm2t9FaRck5xUakvNP-MJ2cs0RroN-fm0Tf8.cache +1 -0
  181. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/xQz9WPf67Mu5uV4rNuOfU-y6_KWSlWcnTWrTvQPonKM.cache +0 -0
  182. data/spec/dummy/tmp/cache/assets/{test/sprockets/v3.0/CT_fvD-uYyN5f1Kis6kQ7DNUnwtnSVT1sdDKxW1e4hw.cache → development/sprockets/v3.0/xhYTRUOS8cIvyRp2Jn6FKnXlGOSsIM2z3HAGOJoJs7w.cache} +0 -0
  183. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/yLxMFI0ARh2OKSOQLF2xEfM7sbst2vUbOBXoOuI6iTE.cache +1 -0
  184. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ynnYZxuxqerlFUytw54dl_CwP94g0U4HmGjyILWnhfQ.cache +1 -0
  185. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/zCivVPbSRpKF_X-P5OJeld32YhymG-bkjQwzqe2o6zg.cache +2 -0
  186. data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
  187. data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/{afa63eb365bdf4f42584b17ac9176b9d → a3fb9025f90ff05a6fd4afc7ded2692c} +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/{a473b3873e554893372a53d71f5e9879 → c69ee3cc5796188d873574179290a6ef} +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/-gXoYfEJ-e9QQUbNRpNa-pwMCnTc7Eqvkq6Bosde6W8.cache +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/6iNAIrMKxHltOChiHQQf9VNsLQuj2rVKz6oqWnK7aSM.cache +1 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/E1zaNOh68xzPxdtdOwRtOaMCoKivN2dxVwCP65WEi5I.cache +2 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HsNbq1o4RbrEWNL4zXVqFfUVnXXLK_y0F0BvddDre6g.cache +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/JusxTSXt06IqBm9jeCMM2nTmM3Wvbl3i3L1IwEvW5YA.cache +2 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/L5DjABL_iOtoxSOLn3X7_YlxECU5EhnrVIKxJFAysgc.cache +1 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/PNc9TJUmRdGTSwgZvGlxKaIiJIkyoWtTPiGGWBqpHAE.cache +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/QkgTHa6nNs7XP6RPoV3yBbWWV-uo1u2-qxLuvLCFe_0.cache +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/S-6Iq5YOEpVnd_vQ0RSSfrmyIwB1dk0op35alFgJ9xA.cache +2 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Vuc93A9yywiFxc9CAdxrzdsAQw4jxiCa6JRzRjNxOYs.cache +1 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YAPBll4U0cgs6cz-WyMRKoakK_gVOOcl9n0CvGyxPjY.cache +1 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/bDNeZfPBQaef5z0YajZc4jFE54nNy9gc06mPNKvvPFk.cache +1 -0
  205. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/c5Wa2loowFYFRBaMoTn1IWYXo4BGMbEy7NIi0vbvfRU.cache +1 -0
  206. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/dkn8MYu2ve_AJW6u0jjTlKrj1KBRqorOHQR0Obx2elU.cache +0 -0
  207. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/fZuAzt_-48u9C7ZXmsPgTraGDYtNC9B9zN-9-EnxJG4.cache +1 -0
  208. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/gumo32Bd3W_q7MYEt9JIZEiQdHF93tLSsGfmXIm2MqU.cache +1 -0
  209. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/ige85jXyj8X7XYr7HpA0gSTThqfPUm71HjhSJXtTbUY.cache +1 -0
  210. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/kuYeE5bV6FdXmfB_o-xhflhSDWoQhYYaaupAXODZ9dQ.cache +1 -0
  211. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qhZbbNIRUaAOtGano94zLHjeBKUhKr4qbh2tTCi0Bnk.cache +2 -0
  212. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/wJJbzdHJHP6tchng3HhfTwmjc5LursgX8yZkAjpO5UA.cache +0 -0
  213. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/xNL1WW-qU3EvV2iTSW6F4hAFRBsCYmFKJhLjgCZkOV8.cache +2 -0
  214. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/ytHkF2DwUE6oaiLyrK6tL-0INpeNhjN6ctD7J0LNY6I.cache +2 -0
  215. data/spec/helpers/commontator/application_helper_spec.rb~ +9 -0
  216. data/spec/lib/commontator/acts_as_commontable_spec.rb~ +25 -0
  217. data/spec/lib/commontator/acts_as_commontator_spec.rb~ +52 -0
  218. data/spec/lib/commontator/commontable_config_spec.rb~ +29 -0
  219. data/spec/lib/commontator/commontator_config_spec.rb~ +29 -0
  220. data/spec/lib/commontator/controller_includes_spec.rb~ +18 -0
  221. data/spec/lib/commontator/controllers_spec.rb +18 -0
  222. data/spec/lib/commontator/{controller_includes_spec.rb → controllers_spec.rb~} +0 -0
  223. data/spec/lib/commontator/shared_helper_spec.rb~ +22 -0
  224. data/spec/lib/commontator_spec.rb~ +26 -0
  225. data/spec/mailers/commontator/subscriptions_mailer_spec.rb +21 -1
  226. data/spec/mailers/commontator/subscriptions_mailer_spec.rb~ +30 -0
  227. data/spec/models/commontator/comment_spec.rb~ +82 -0
  228. data/spec/models/commontator/subscription_spec.rb~ +38 -0
  229. data/spec/models/commontator/thread_spec.rb~ +122 -0
  230. data/spec/rails_helper.rb~ +74 -0
  231. data/spec/spec_helper.rb +1 -0
  232. data/spec/spec_helper.rb~ +93 -0
  233. data/vendor/assets/javascripts/mentionsInput/index.js~ +3 -0
  234. data/vendor/assets/javascripts/mentionsInput/jquery.mentionsInput.js +538 -0
  235. data/vendor/assets/javascripts/underscore/underscore.js +1590 -0
  236. data/vendor/assets/stylesheets/mentionsInput/jquery.mentionsInput.css +114 -0
  237. metadata +445 -100
  238. data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
  239. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/2MuTpyqaQLj1O4wgROKGqNe4lXIGrVZDYXCWWWMRmrA.cache +0 -0
  240. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/4CjNCL1K4fowKckGvL9F3HkCEtCH42rfsn2geU5A1xs.cache +0 -0
  241. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/CjR916jO_S7Mo8eTI1vKieKJoKQ0t-bk4sxhcYYQ5Bw.cache +0 -1
  242. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/DtzP3rNdkPulzFug4nVQunOws8OXjvPJwB2nNhp9Scs.cache +0 -0
  243. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/FmvRMZstlcKHCKy5g4mmAu4vjz-YPScTigFnnvs1v-E.cache +0 -1
  244. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HXtFVXhiLFEohXrf9PBX2u9xkPew5yU2IOyxmFCa7fo.cache +0 -2
  245. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Kqg37VotFbWELQyr3-R20M2yWWoiloqBWDWRG-i3m5E.cache +0 -2
  246. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/PeZjQ1KGvso4tt6qvVQZniMzlTlVTWeH-tjln1fERkw.cache +0 -1
  247. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/VH5BWA_SC2XnIxStJ5vtjX3pNqdbo7uMo9Tg9GVFUGU.cache +0 -1
  248. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/lzmR_-kjjgHYgaJd_fvBlAimt7_xADtnhEPo_CIBiPM.cache +0 -1
  249. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/q3giWdNvlLQ39xIHQWPY8vzbfjW9zXkSqwibRQBKcvM.cache +0 -2
  250. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/zpCVMbdGU9JtJWkk95WWomNsxP3Q7jqZmWKJXnsGH0g.cache +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35cb6a59267e1597636ccbd546b34d781ca940ce
4
- data.tar.gz: a5d8730f0f7c1bb4835781cacd4a619c928da9db
3
+ metadata.gz: 060c9423cbec58969dbbf6957a0f186a0bf6c3b5
4
+ data.tar.gz: 18684e3ebf3d9bfde025154d6e557cf628d123e1
5
5
  SHA512:
6
- metadata.gz: f321c9fc6ca3c40e739905ddf127290838740ea994274639c1c361f93cddc19fbd12c3c9bc695c55ce525192d0fb1c75a01969d99d3465a3fafac9df9fd04daa
7
- data.tar.gz: e666f726a69be8a5dac830cd590fbe4cb6e2bede38f63421c8e90c88a4f467a7659d52c72b19eb85dc6e7f895aa5004e004a133ae6aee49ffc1e9051093f1d46
6
+ metadata.gz: 189a5502659f64239702c9bd805f479a21a93b57c01aacb7bc50892ddedda693ff4ff1f011bb525d2bdeab04dfd751c36a47f2f522d424c5d4a20b2d32d3de1b
7
+ data.tar.gz: e256734e04028203d3aee190986678d2254e084ccb6eb69bdbfe063f4c36746d74c4580a5382ce87f4dbe1876f9b72533eec6ac652539882ce98d0ab0148a2a4
data/README.md CHANGED
@@ -58,7 +58,7 @@ There are 4 steps you must follow to install commontator:
58
58
 
59
59
  4. Routes
60
60
 
61
- Add this line to your Rails application's routes file:
61
+ Add this line to your Rails application's `routes.rb` file:
62
62
 
63
63
  ```rb
64
64
  mount Commontator::Engine => '/commontator'
@@ -66,6 +66,15 @@ There are 4 steps you must follow to install commontator:
66
66
 
67
67
  You can change the mount path if you would like a different one.
68
68
 
69
+ 5. Stylesheets
70
+
71
+ In order to display comment threads properly,
72
+ you must add the following to your `application.css`:
73
+
74
+ ```css
75
+ *= require commontator/application
76
+ ```
77
+
69
78
  ## Usage
70
79
 
71
80
  Follow the steps below to add commontator to your models and views:
@@ -107,7 +116,7 @@ Follow the steps below to add commontator to your models and views:
107
116
  In that case, just add the following method call to the controller action that displays the page in question:
108
117
 
109
118
  ```rb
110
- commontator_thread_show(commontable)
119
+ commontator_thread_show(@commontable)
111
120
  ```
112
121
 
113
122
  Note that the call to `commontator_thread` in the view is still necessary in either case.
@@ -127,6 +136,8 @@ If sending emails, remember to add your host URL's to your environment files
127
136
  config.action_mailer.default_url_options = { :host => "www.example.com" }
128
137
  ```
129
138
 
139
+ Batch sending through Mailgun is also supported.
140
+
130
141
  ## Voting
131
142
 
132
143
  You can allow users to vote on each others' comments by adding the `acts_as_votable` gem to your gemfile:
@@ -141,9 +152,44 @@ And enabling the relevant option in commontator's initializer:
141
152
  config.comment_voting = :ld # See the initializer for available options
142
153
  ```
143
154
 
155
+ ## Mentions
156
+
157
+ You can allow users to mention other users in the comments.
158
+ Mentioned users are automatically subscribed to the thread and receive email notifications.
159
+
160
+ First add the following to your application.js file:
161
+
162
+ ```js
163
+ //= require commontator/application
164
+ ```
165
+
166
+ Then enable mentions in commontator's initializer:
167
+
168
+ ```rb
169
+ config.mentions_enabled = true
170
+ ```
171
+
172
+ Finally configure the user_mentions_proc, which receives the current user
173
+ and the search query inputted by that user and should return a relation
174
+ containing the users that can be mentioned and match the query string:
175
+
176
+ ```rb
177
+ config.user_mentions_proc = lambda { |current_user, query| ... }
178
+ ```
179
+
180
+ Please be aware that with mentions enabled, any registered user
181
+ can use the `user_mentions_proc` to search for other users.
182
+ Make sure to properly escape SQL in this proc and to not allow searches on sensitive fields.
183
+
184
+ Use '@' with at least three other characters to mention someone in a new/edited comment.
185
+
186
+ The mentions script assumes that commontator is mounted at `/commontator`,
187
+ so make sure that is indeed the case if you plan to use mentions.
188
+
144
189
  ## Browser Support
145
190
 
146
191
  Commontator should work properly on any of the major browsers.
192
+ The mentions functionality won't work with IE before version 8.
147
193
  To function properly, this gem requires that visitors to the site have javascript enabled.
148
194
 
149
195
  ## Customization
data/Rakefile CHANGED
@@ -1,23 +1,22 @@
1
1
  #!/usr/bin/env rake
2
-
2
+ # http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
3
3
  begin
4
4
  require 'bundler/setup'
5
5
  rescue LoadError
6
6
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
7
  end
8
8
 
9
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
10
10
  load 'rails/tasks/engine.rake'
11
11
 
12
12
  Bundler::GemHelper.install_tasks
13
13
 
14
- begin
15
- require 'rspec/core/rake_task'
14
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
16
15
 
17
- RSpec::Core::RakeTask.new(:spec)
16
+ require 'rspec/core'
17
+ require 'rspec/core/rake_task'
18
18
 
19
- task :default => :spec
20
- rescue LoadError
21
- # no rspec available
22
- end
19
+ desc 'Run all specs in spec directory (excluding plugin specs)'
20
+ RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
23
21
 
22
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ //= require underscore/underscore
2
+ //= require mentionsInput/jquery.mentionsInput
3
+ //= require commontator/mentions
@@ -0,0 +1,3 @@
1
+ //= require underscore/underscore
2
+ //= require jquery.mentionsInput
3
+ //= require commontator/mentions
@@ -0,0 +1,32 @@
1
+ window.Commontator = {};
2
+ Commontator._ = window._.noConflict();
3
+ Commontator.initMentions = function() {
4
+ $('.comment_form_field textarea:not(.mentions-added)').each(function(_index, textarea){
5
+ $textarea = $(textarea);
6
+ $form = $textarea.parents('form');
7
+ threadId = $textarea.parents('.thread').attr('id').match(/[\d]+/)[0];
8
+ $textarea.addClass('mentions-added');
9
+ currentValue = $textarea.val();
10
+ $textarea.mentionsInput({
11
+ elastic: false,
12
+ showAvatars: false,
13
+ allowRepeat: true,
14
+ minChars: 3,
15
+ onDataRequest:function (mode, query, callback) {
16
+ $.getJSON('/commontator/threads/'+threadId+'/mentions.json', {q: query}, function(responseData) {
17
+ callback.call(this, responseData.mentions);
18
+ });
19
+ }
20
+ });
21
+ $textarea.val(currentValue);
22
+ $textarea.on('focusout', function(){
23
+ $textarea.mentionsInput('getMentions', function(mentions){
24
+ $form.find('input[name="mentioned_ids[]"]').remove();
25
+ $(mentions).each(function(_index, mention){
26
+ $input = $('<input>', { type: 'hidden', name: 'mentioned_ids[]', value: mention.id });
27
+ $form.append($input)
28
+ });
29
+ });
30
+ });
31
+ });
32
+ };
@@ -0,0 +1,31 @@
1
+ window.Commontator = {};
2
+ Commontator._ = window._.noConflict();
3
+ Commontator.initMentions = function() {
4
+ $('.comment_form_field textarea:not(.mentions-added)').each(function(_index, textarea){
5
+ $textarea = $(textarea);
6
+ $form = $textarea.parents('form');
7
+ threadId = $textarea.parents('.thread').attr('id').match(/[\d]+/)[0];
8
+ $textarea.addClass('mentions-added');
9
+ currentValue = $textarea.val();
10
+ $textarea.mentionsInput({
11
+ elastic: false,
12
+ showAvatars: false,
13
+ allowRepeat: true,
14
+ onDataRequest:function (mode, query, callback) {
15
+ $.getJSON('commontator/threads/'+threadId+'/mentions.json', {q: query}, function(responseData) {
16
+ callback.call(this, responseData.mentions);
17
+ });
18
+ }
19
+ });
20
+ $textarea.val(currentValue);
21
+ $textarea.on('focusout', function(){
22
+ $textarea.mentionsInput('getMentions', function(mentions){
23
+ $form.find('input[name="mentioned_ids[]"]').remove();
24
+ $(mentions).each(function(_index, mention){
25
+ $input = $('<input>', { type: 'hidden', name: 'mentioned_ids[]', value: mention.id });
26
+ $form.append($input)
27
+ });
28
+ });
29
+ });
30
+ });
31
+ };
@@ -1,13 +1,5 @@
1
1
  /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
2
  *= require_self
3
+ *= require mentionsInput/jquery.mentionsInput
12
4
  *= require_tree .
13
5
  */
@@ -0,0 +1,14 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require mentionsInput/jquery.mentionsInput
13
+ *= require_tree .
14
+ */
@@ -64,3 +64,8 @@ http://www.strangerstudios.com/sandbox/pagination/diggstyle.php */
64
64
 
65
65
  color: #DDD;
66
66
  }
67
+
68
+ .thread .mentions-input-box .mentions {
69
+ left: -2px !important;
70
+ top: -2px !important;
71
+ }
@@ -0,0 +1,71 @@
1
+ .thread {
2
+ display: block !important;
3
+ }
4
+
5
+ .thread .commontator_hidden {
6
+ display: none;
7
+ }
8
+
9
+ .thread_actions {
10
+ float: right;
11
+ }
12
+
13
+ .thread_header {
14
+ font-size: 16px;
15
+ font-weight: bold;
16
+ font-style: normal;
17
+ margin-top: 5px;
18
+ margin-bottom: 5px;
19
+ display: block;
20
+ }
21
+
22
+ /* Modified from:
23
+ http://www.strangerstudios.com/sandbox/pagination/diggstyle.php */
24
+ .thread_page_entries_info {
25
+ margin-top: 10px;
26
+ margin-bottom: 10px;
27
+ }
28
+
29
+ .thread_will_paginate {
30
+ margin-top: 10px;
31
+ margin-bottom: 10px;
32
+ }
33
+
34
+ .thread_pagination a {
35
+ padding: 2px 5px 2px 5px;
36
+ margin-right: 4px;
37
+ border: 1px solid #999;
38
+
39
+ text-decoration: none;
40
+ color: #666;
41
+ }
42
+
43
+ .thread_pagination a:hover,
44
+ .thread_pagination a:active {
45
+ border: 1px solid #555;
46
+
47
+ color: #000;
48
+ }
49
+
50
+ .thread_pagination em {
51
+ padding: 2px 5px 2px 5px;
52
+ margin-right: 4px;
53
+ border: 1px solid #555;
54
+
55
+ font-weight: bold;
56
+ background-color: #555;
57
+ color: #FFF;
58
+ }
59
+
60
+ .thread_pagination span {
61
+ padding: 2px 5px 2px 5px;
62
+ margin-right: 4px;
63
+ border: 1px solid #EEE;
64
+
65
+ color: #DDD;
66
+ }
67
+
68
+ .thread .mentions-input-box .mentions {
69
+ left: -2px !important;
70
+ top: -2px !important;
71
+ }
@@ -26,6 +26,7 @@ module Commontator
26
26
  @comment.creator = @user
27
27
  @comment.body = params[:comment].nil? ? nil : params[:comment][:body]
28
28
  security_transgression_unless @comment.can_be_created_by?(@user)
29
+ subscribe_mentioned if Commontator.mentions_enabled
29
30
 
30
31
  respond_to do |format|
31
32
  if !params[:cancel].nil?
@@ -62,6 +63,7 @@ module Commontator
62
63
  security_transgression_unless @comment.can_be_edited_by?(@user)
63
64
  @comment.body = params[:comment].nil? ? nil : params[:comment][:body]
64
65
  @comment.editor = @user
66
+ subscribe_mentioned if Commontator.mentions_enabled
65
67
 
66
68
  respond_to do |format|
67
69
  if !params[:cancel].nil?
@@ -147,5 +149,11 @@ module Commontator
147
149
  @thread = @comment.thread
148
150
  commontator_set_new_comment(@thread, @user)
149
151
  end
152
+
153
+ def subscribe_mentioned
154
+ Commontator.commontator_mentions(@user, '').where(id: params[:mentioned_ids]).each do |user|
155
+ @thread.subscribe(user)
156
+ end
157
+ end
150
158
  end
151
159
  end
@@ -0,0 +1,160 @@
1
+ module Commontator
2
+ class CommentsController < Commontator::ApplicationController
3
+ before_filter :set_thread, :only => [:new, :create]
4
+ before_filter :set_comment_and_thread, :except => [:new, :create]
5
+
6
+ # GET /threads/1/comments/new
7
+ def new
8
+ @comment = Comment.new
9
+ @comment.thread = @thread
10
+ @comment.creator = @user
11
+ security_transgression_unless @comment.can_be_created_by?(@user)
12
+
13
+ @per_page = params[:per_page] || @thread.config.comments_per_page
14
+
15
+ respond_to do |format|
16
+ format.html { redirect_to @thread }
17
+ format.js
18
+ end
19
+
20
+ end
21
+
22
+ # POST /threads/1/comments
23
+ def create
24
+ @comment = Comment.new
25
+ @comment.thread = @thread
26
+ @comment.creator = @user
27
+ @comment.body = params[:comment].nil? ? nil : params[:comment][:body]
28
+ security_transgression_unless @comment.can_be_created_by?(@user)
29
+ subscribe_mentioned if Commontator.mentions_enabled
30
+
31
+ respond_to do |format|
32
+ if !params[:cancel].nil?
33
+ format.html { redirect_to @thread }
34
+ format.js { render :cancel }
35
+ elsif @comment.save
36
+ sub = @thread.config.thread_subscription.to_sym
37
+ @thread.subscribe(@user) if sub == :a || sub == :b
38
+ Subscription.comment_created(@comment)
39
+
40
+ @per_page = params[:per_page] || @thread.config.comments_per_page
41
+
42
+ format.html { redirect_to @thread }
43
+ format.js
44
+ else
45
+ format.html { redirect_to @thread }
46
+ format.js { render :new }
47
+ end
48
+ end
49
+ end
50
+
51
+ # GET /comments/1/edit
52
+ def edit
53
+ security_transgression_unless @comment.can_be_edited_by?(@user)
54
+
55
+ respond_to do |format|
56
+ format.html { redirect_to @thread }
57
+ format.js
58
+ end
59
+ end
60
+
61
+ # PUT /comments/1
62
+ def update
63
+ security_transgression_unless @comment.can_be_edited_by?(@user)
64
+ @comment.body = params[:comment].nil? ? nil : params[:comment][:body]
65
+ @comment.editor = @user
66
+ subscribe_mentioned if Commontator.mentions_enabled
67
+
68
+ respond_to do |format|
69
+ if !params[:cancel].nil?
70
+ format.html { redirect_to @thread }
71
+ format.js { render :cancel }
72
+ elsif @comment.save
73
+ format.html { redirect_to @thread }
74
+ format.js
75
+ else
76
+ format.html { redirect_to @thread }
77
+ format.js { render :edit }
78
+ end
79
+ end
80
+ end
81
+
82
+ # PUT /comments/1/delete
83
+ def delete
84
+ security_transgression_unless @comment.can_be_deleted_by?(@user)
85
+
86
+ @comment.errors.add(:base, t('commontator.comment.errors.already_deleted')) \
87
+ unless @comment.delete_by(@user)
88
+
89
+ respond_to do |format|
90
+ format.html { redirect_to @thread }
91
+ format.js { render :delete }
92
+ end
93
+ end
94
+
95
+ # PUT /comments/1/undelete
96
+ def undelete
97
+ security_transgression_unless @comment.can_be_deleted_by?(@user)
98
+
99
+ @comment.errors.add(:base, t('commontator.comment.errors.not_deleted')) \
100
+ unless @comment.undelete_by(@user)
101
+
102
+ respond_to do |format|
103
+ format.html { redirect_to @thread }
104
+ format.js { render :delete }
105
+ end
106
+ end
107
+
108
+ # PUT /comments/1/upvote
109
+ def upvote
110
+ security_transgression_unless @comment.can_be_voted_on_by?(@user)
111
+
112
+ @comment.upvote_from @user
113
+
114
+ respond_to do |format|
115
+ format.html { redirect_to @thread }
116
+ format.js { render :vote }
117
+ end
118
+ end
119
+
120
+ # PUT /comments/1/downvote
121
+ def downvote
122
+ security_transgression_unless @comment.can_be_voted_on_by?(@user) &&\
123
+ @comment.thread.config.comment_voting.to_sym == :ld
124
+
125
+ @comment.downvote_from @user
126
+
127
+ respond_to do |format|
128
+ format.html { redirect_to @thread }
129
+ format.js { render :vote }
130
+ end
131
+ end
132
+
133
+ # PUT /comments/1/unvote
134
+ def unvote
135
+ security_transgression_unless @comment.can_be_voted_on_by?(@user)
136
+
137
+ @comment.unvote :voter => @user
138
+
139
+ respond_to do |format|
140
+ format.html { redirect_to @thread }
141
+ format.js { render :vote }
142
+ end
143
+ end
144
+
145
+ protected
146
+
147
+ def set_comment_and_thread
148
+ @comment = Comment.find(params[:id])
149
+ @thread = @comment.thread
150
+ commontator_set_new_comment(@thread, @user)
151
+ end
152
+
153
+ def subscribe_mentioned
154
+ debugger
155
+ Commontator.commontator_mentions(@user, '').where(id: params[:mentioned_ids]).each do |user|
156
+ @thread.subscribe(user)
157
+ end
158
+ end
159
+ end
160
+ end