mongoid-forums 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +35 -0
  4. data/app/assets/javascripts/mongoid_forums/admin/base.js +2 -0
  5. data/app/assets/javascripts/mongoid_forums/admin/categories.js +2 -0
  6. data/app/assets/javascripts/mongoid_forums/admin/forums.js +2 -0
  7. data/app/assets/javascripts/mongoid_forums/application.js +13 -0
  8. data/app/assets/javascripts/mongoid_forums/forums.js +2 -0
  9. data/app/assets/javascripts/mongoid_forums/posts.js +2 -0
  10. data/app/assets/javascripts/mongoid_forums/topics.js +2 -0
  11. data/app/assets/stylesheets/mongoid_forums/admin/base.css +4 -0
  12. data/app/assets/stylesheets/mongoid_forums/admin/categories.css +4 -0
  13. data/app/assets/stylesheets/mongoid_forums/admin/forums.css +4 -0
  14. data/app/assets/stylesheets/mongoid_forums/application.css +15 -0
  15. data/app/assets/stylesheets/mongoid_forums/forums.css +4 -0
  16. data/app/assets/stylesheets/mongoid_forums/posts.css +4 -0
  17. data/app/assets/stylesheets/mongoid_forums/topics.css +4 -0
  18. data/app/assets/stylesheets/scaffold.css +56 -0
  19. data/app/controllers/mongoid_forums/admin/base_controller.rb +11 -0
  20. data/app/controllers/mongoid_forums/admin/categories_controller.rb +36 -0
  21. data/app/controllers/mongoid_forums/admin/forums_controller.rb +36 -0
  22. data/app/controllers/mongoid_forums/application_controller.rb +45 -0
  23. data/app/controllers/mongoid_forums/forums_controller.rb +57 -0
  24. data/app/controllers/mongoid_forums/posts_controller.rb +75 -0
  25. data/app/controllers/mongoid_forums/redirect_controller.rb +33 -0
  26. data/app/controllers/mongoid_forums/topics_controller.rb +84 -0
  27. data/app/helpers/mongoid_forums/admin/base_helper.rb +4 -0
  28. data/app/helpers/mongoid_forums/admin/categories_helper.rb +4 -0
  29. data/app/helpers/mongoid_forums/admin/forums_helper.rb +4 -0
  30. data/app/helpers/mongoid_forums/application_helper.rb +20 -0
  31. data/app/helpers/mongoid_forums/formatting_helper.rb +28 -0
  32. data/app/helpers/mongoid_forums/forums_helper.rb +15 -0
  33. data/app/helpers/mongoid_forums/posts_helper.rb +4 -0
  34. data/app/helpers/mongoid_forums/topics_helper.rb +4 -0
  35. data/app/models/mongoid_forums/alert.rb +80 -0
  36. data/app/models/mongoid_forums/category.rb +13 -0
  37. data/app/models/mongoid_forums/concerns/subscribable.rb +76 -0
  38. data/app/models/mongoid_forums/concerns/viewable.rb +60 -0
  39. data/app/models/mongoid_forums/forum.rb +42 -0
  40. data/app/models/mongoid_forums/permission.rb +95 -0
  41. data/app/models/mongoid_forums/post.rb +37 -0
  42. data/app/models/mongoid_forums/rank.rb +9 -0
  43. data/app/models/mongoid_forums/subscription.rb +66 -0
  44. data/app/models/mongoid_forums/topic.rb +45 -0
  45. data/app/models/mongoid_forums/view.rb +30 -0
  46. data/app/views/layouts/mongoid_forums/application.haml +21 -0
  47. data/app/views/mongoid_forums/admin/base/index.haml +4 -0
  48. data/app/views/mongoid_forums/admin/categories/edit.html.erb +2 -0
  49. data/app/views/mongoid_forums/admin/categories/new.haml +3 -0
  50. data/app/views/mongoid_forums/admin/forums/edit.html.erb +2 -0
  51. data/app/views/mongoid_forums/admin/forums/new.haml +4 -0
  52. data/app/views/mongoid_forums/forums/index.haml +43 -0
  53. data/app/views/mongoid_forums/forums/new.haml +15 -0
  54. data/app/views/mongoid_forums/forums/show.haml +43 -0
  55. data/app/views/mongoid_forums/posts/_form.haml +4 -0
  56. data/app/views/mongoid_forums/posts/_post.haml +20 -0
  57. data/app/views/mongoid_forums/posts/_quoted.haml +9 -0
  58. data/app/views/mongoid_forums/posts/edit.haml +17 -0
  59. data/app/views/mongoid_forums/posts/new.haml +17 -0
  60. data/app/views/mongoid_forums/topics/_topic.haml +2 -0
  61. data/app/views/mongoid_forums/topics/my_posts.haml +6 -0
  62. data/app/views/mongoid_forums/topics/my_subscriptions.haml +5 -0
  63. data/app/views/mongoid_forums/topics/my_topics.haml +6 -0
  64. data/app/views/mongoid_forums/topics/show.haml +12 -0
  65. data/config/routes.rb +40 -0
  66. data/lib/generators/mongoid_forums/install/templates/initializer.rb +5 -0
  67. data/lib/generators/mongoid_forums/install_generator.rb +101 -0
  68. data/lib/generators/mongoid_forums/views_generator.rb +27 -0
  69. data/lib/mongoid_forums/engine.rb +15 -0
  70. data/lib/mongoid_forums/sanitizer.rb +10 -0
  71. data/lib/mongoid_forums/version.rb +3 -0
  72. data/lib/mongoid_forums.rb +40 -0
  73. data/lib/tasks/mongoid_forums_tasks.rake +4 -0
  74. data/test/controllers/mongoid_forums/admin/base_controller_test.rb +11 -0
  75. data/test/controllers/mongoid_forums/admin/categories_controller_test.rb +31 -0
  76. data/test/controllers/mongoid_forums/admin/forums_controller_test.rb +31 -0
  77. data/test/controllers/mongoid_forums/forums_controller_test.rb +16 -0
  78. data/test/controllers/mongoid_forums/posts_controller_test.rb +36 -0
  79. data/test/controllers/mongoid_forums/topics_controller_test.rb +36 -0
  80. data/test/dummy/README.rdoc +28 -0
  81. data/test/dummy/Rakefile +6 -0
  82. data/test/dummy/app/assets/javascripts/application.js +13 -0
  83. data/test/dummy/app/assets/javascripts/welcome.js +2 -0
  84. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  85. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  86. data/test/dummy/app/assets/stylesheets/welcome.css +4 -0
  87. data/test/dummy/app/controllers/application_controller.rb +11 -0
  88. data/test/dummy/app/controllers/welcome_controller.rb +4 -0
  89. data/test/dummy/app/helpers/application_helper.rb +2 -0
  90. data/test/dummy/app/helpers/welcome_helper.rb +2 -0
  91. data/test/dummy/app/models/concerns/zero_oid_fix.rb +10 -0
  92. data/test/dummy/app/models/user.rb +43 -0
  93. data/test/dummy/app/views/layouts/application.haml +13 -0
  94. data/test/dummy/app/views/partials/_nav.haml +6 -0
  95. data/test/dummy/app/views/welcome/index.html.erb +2 -0
  96. data/test/dummy/bin/bundle +3 -0
  97. data/test/dummy/bin/rails +4 -0
  98. data/test/dummy/bin/rake +4 -0
  99. data/test/dummy/bin/setup +29 -0
  100. data/test/dummy/config/application.rb +29 -0
  101. data/test/dummy/config/boot.rb +5 -0
  102. data/test/dummy/config/environment.rb +5 -0
  103. data/test/dummy/config/environments/development.rb +41 -0
  104. data/test/dummy/config/environments/production.rb +76 -0
  105. data/test/dummy/config/environments/test.rb +42 -0
  106. data/test/dummy/config/initializers/assets.rb +11 -0
  107. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  108. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  109. data/test/dummy/config/initializers/devise.rb +259 -0
  110. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  111. data/test/dummy/config/initializers/inflections.rb +16 -0
  112. data/test/dummy/config/initializers/kaminari_config.rb +10 -0
  113. data/test/dummy/config/initializers/mime_types.rb +4 -0
  114. data/test/dummy/config/initializers/mongoid_forums.rb +5 -0
  115. data/test/dummy/config/initializers/session_store.rb +3 -0
  116. data/test/dummy/config/initializers/simple_form.rb +166 -0
  117. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  118. data/test/dummy/config/locales/devise.en.yml +60 -0
  119. data/test/dummy/config/locales/en.yml +23 -0
  120. data/test/dummy/config/locales/simple_form.en.yml +31 -0
  121. data/test/dummy/config/mongoid.yml +69 -0
  122. data/test/dummy/config/routes.rb +8 -0
  123. data/test/dummy/config/secrets.yml +22 -0
  124. data/test/dummy/config.ru +4 -0
  125. data/test/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
  126. data/test/dummy/log/development.log +152624 -0
  127. data/test/dummy/log/test.log +51 -0
  128. data/test/dummy/public/404.html +67 -0
  129. data/test/dummy/public/422.html +67 -0
  130. data/test/dummy/public/500.html +66 -0
  131. data/test/dummy/public/favicon.ico +0 -0
  132. data/test/dummy/test/controllers/welcome_controller_test.rb +9 -0
  133. data/test/dummy/test/fixtures/users.yml +11 -0
  134. data/test/dummy/test/models/user_test.rb +7 -0
  135. data/test/dummy/tmp/cache/assets/development/sprockets/0405ebcb982faa24d5a9bbe01ba43bf8 +0 -0
  136. data/test/dummy/tmp/cache/assets/development/sprockets/04b994ecf135576af395f1d87108f0e1 +0 -0
  137. data/test/dummy/tmp/cache/assets/development/sprockets/0532538bff94834533de08d16379c66f +0 -0
  138. data/test/dummy/tmp/cache/assets/development/sprockets/063d0c765cb2fe0a6fa3995059d65fcc +0 -0
  139. data/test/dummy/tmp/cache/assets/development/sprockets/0a395daf2ed2bad0174008f223997c21 +0 -0
  140. data/test/dummy/tmp/cache/assets/development/sprockets/0a4181c6e19406e1c40781394b0f7496 +0 -0
  141. data/test/dummy/tmp/cache/assets/development/sprockets/0f520169da88dbfbdd5b5f40cb5acc80 +0 -0
  142. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  143. data/test/dummy/tmp/cache/assets/development/sprockets/1b516e1e4f37dd27b32d035c2c825de7 +0 -0
  144. data/test/dummy/tmp/cache/assets/development/sprockets/1d1293f6abfd57a3035ab25a567fe43e +0 -0
  145. data/test/dummy/tmp/cache/assets/development/sprockets/25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
  146. data/test/dummy/tmp/cache/assets/development/sprockets/268f4f56598234185d91373d61899b3f +0 -0
  147. data/test/dummy/tmp/cache/assets/development/sprockets/26ce0653a8cb3da5990ace16181dbd63 +0 -0
  148. data/test/dummy/tmp/cache/assets/development/sprockets/2dedb8177c20286c4259c1d58c5646cc +0 -0
  149. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  150. data/test/dummy/tmp/cache/assets/development/sprockets/2fda08fb2ff79ca1dd653c3b688c1651 +0 -0
  151. data/test/dummy/tmp/cache/assets/development/sprockets/30d0258c36708f3d7911d6ba2303aaad +0 -0
  152. data/test/dummy/tmp/cache/assets/development/sprockets/311da47a66243f663a4557a7e9997796 +0 -0
  153. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  154. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  155. data/test/dummy/tmp/cache/assets/development/sprockets/37b103f4623089af1456b90830fe941c +0 -0
  156. data/test/dummy/tmp/cache/assets/development/sprockets/37f7e269b2ddbd05160232e59bf0288f +0 -0
  157. data/test/dummy/tmp/cache/assets/development/sprockets/408e554cb00cbb09ae89a1e7ac45ea4f +0 -0
  158. data/test/dummy/tmp/cache/assets/development/sprockets/41f10e590485de7db44ca61e32c135ea +0 -0
  159. data/test/dummy/tmp/cache/assets/development/sprockets/45e716730a5c02112d5817e1b8faa1a0 +0 -0
  160. data/test/dummy/tmp/cache/assets/development/sprockets/4acd6b11130459cfdf814caad7638e95 +0 -0
  161. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  162. data/test/dummy/tmp/cache/assets/development/sprockets/60f651a96095c10f531bd7bf9a14beb5 +0 -0
  163. data/test/dummy/tmp/cache/assets/development/sprockets/6b12ee5284cadf70954a584a88b6c529 +0 -0
  164. data/test/dummy/tmp/cache/assets/development/sprockets/6be29bb8e609ed29aaa3a6d4a04a9ae0 +0 -0
  165. data/test/dummy/tmp/cache/assets/development/sprockets/6cef1e9aec64b514669e261e511dc792 +0 -0
  166. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  167. data/test/dummy/tmp/cache/assets/development/sprockets/76dc342539f7133a15b70b919f77425a +0 -0
  168. data/test/dummy/tmp/cache/assets/development/sprockets/873adae1bf2f532256c8ffe71a557df5 +0 -0
  169. data/test/dummy/tmp/cache/assets/development/sprockets/8d7f8b5066922abfdf12e8cf0a7f2f0e +0 -0
  170. data/test/dummy/tmp/cache/assets/development/sprockets/948b1a4ef7d3401c10fc537c40b56a1e +0 -0
  171. data/test/dummy/tmp/cache/assets/development/sprockets/99d8deee7a422780b297ca618f4062c8 +0 -0
  172. data/test/dummy/tmp/cache/assets/development/sprockets/9d4262e6cd4898fd1df7f51b2d3e5c92 +0 -0
  173. data/test/dummy/tmp/cache/assets/development/sprockets/9e611bdf180a46600cc5019392a1b561 +0 -0
  174. data/test/dummy/tmp/cache/assets/development/sprockets/ab4dfca9c17bc07c2fce0127b5d9669f +0 -0
  175. data/test/dummy/tmp/cache/assets/development/sprockets/af01a98a48fa1ebf1d65f0429ba2bb28 +0 -0
  176. data/test/dummy/tmp/cache/assets/development/sprockets/bc0c996f7ce50479170183c13af2d29d +0 -0
  177. data/test/dummy/tmp/cache/assets/development/sprockets/beeaeba29291235e532fb452d94795b3 +0 -0
  178. data/test/dummy/tmp/cache/assets/development/sprockets/cc040cf4f4539a12745d02867976f5ba +0 -0
  179. data/test/dummy/tmp/cache/assets/development/sprockets/ce30207f8949b0e3a822f6094bd31dcc +0 -0
  180. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  181. data/test/dummy/tmp/cache/assets/development/sprockets/d675d8a6b14078d1fc331870b4992050 +0 -0
  182. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  183. data/test/dummy/tmp/cache/assets/development/sprockets/daba24276ab6f3be739a0385f977df1c +0 -0
  184. data/test/dummy/tmp/cache/assets/development/sprockets/df5f9fbb250c939b0513aa2a35b4855b +0 -0
  185. data/test/dummy/tmp/cache/assets/development/sprockets/e22980ed174c68b2505214836a40e271 +0 -0
  186. data/test/dummy/tmp/cache/assets/development/sprockets/e2c4f946939f2d7d0b42d86383755cae +0 -0
  187. data/test/dummy/tmp/cache/assets/development/sprockets/e6a87270f3b0e8a73bcec17322694b61 +0 -0
  188. data/test/dummy/tmp/cache/assets/development/sprockets/e95bb3887fb84a7d966c0fc7c4e087fd +0 -0
  189. data/test/dummy/tmp/cache/assets/development/sprockets/eaa7a7fe023d19cd34c33a47e6b303f3 +0 -0
  190. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  191. data/test/dummy/tmp/cache/assets/development/sprockets/f91f775cd15edae9264ec0c23937c58b +0 -0
  192. data/test/fixtures/mongoid_forums/categories.yml +11 -0
  193. data/test/fixtures/mongoid_forums/forums.yml +11 -0
  194. data/test/fixtures/mongoid_forums/posts.yml +11 -0
  195. data/test/fixtures/mongoid_forums/ranks.yml +11 -0
  196. data/test/fixtures/mongoid_forums/topics.yml +11 -0
  197. data/test/integration/navigation_test.rb +9 -0
  198. data/test/models/mongoid_forums/category_test.rb +9 -0
  199. data/test/models/mongoid_forums/forum_test.rb +9 -0
  200. data/test/models/mongoid_forums/post_test.rb +9 -0
  201. data/test/models/mongoid_forums/rank_test.rb +9 -0
  202. data/test/models/mongoid_forums/topic_test.rb +9 -0
  203. data/test/mongoid_forums_test.rb +7 -0
  204. data/test/test_helper.rb +17 -0
  205. metadata +491 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd0212413749f87b908dceb892b298518e46b042
4
+ data.tar.gz: 54860ded042b3e8508a6e8a5ee28e5aa60c61a31
5
+ SHA512:
6
+ metadata.gz: 09a6255546a1adda9c0a43522ce1f708bad0ba93ce0cebb9ea072cfab2de482794b162e5483ff2ce13bf54daeac94f8271497820d8b86d956ef249d6d556a5e3
7
+ data.tar.gz: 70c0fb8146db43ea7832fd1b3b1d58b8f28c6666e5472db65588f04a5e5b4eb29d8f9564ed16d769ef38f5fd3b069969656c0e6130bb40667e77f08c7222093a
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Njay Development Team
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/Rakefile ADDED
@@ -0,0 +1,35 @@
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 = 'MongoidForums'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
25
+ require 'rake/testtask'
26
+
27
+ Rake::TestTask.new(:test) do |t|
28
+ t.libs << 'lib'
29
+ t.libs << 'test'
30
+ t.pattern = 'test/**/*_test.rb'
31
+ t.verbose = false
32
+ end
33
+
34
+
35
+ task default: :test
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,11 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ class Admin::BaseController < ApplicationController
5
+
6
+
7
+ def index
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ module Admin
5
+ class CategoriesController < BaseController
6
+ def new
7
+ @category = Category.new
8
+ end
9
+
10
+ def create
11
+ if @category = Category.create(name: params[:category][:name])
12
+ flash[:notice] = "Category created successfully"
13
+ redirect_to root_path
14
+ else
15
+ flash.now.alert = "Category could not be created"
16
+ render :action => "new"
17
+ end
18
+ end
19
+
20
+ def edit
21
+ end
22
+
23
+ def update
24
+ end
25
+
26
+ def destroy
27
+ end
28
+
29
+ private
30
+
31
+ def category_params
32
+ params.require(:category).permit(:name)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ module Admin
5
+ class Admin::ForumsController < BaseController
6
+ def new
7
+ @forum = Forum.new
8
+ end
9
+
10
+ def create
11
+ if @forum = Forum.create(name: params[:forum][:name], category: params[:forum][:category])
12
+ flash[:notice] = "Category created successfully"
13
+ redirect_to @forum
14
+ else
15
+ flash.now.alert = "Category could not be created"
16
+ render :action => "new"
17
+ end
18
+ end
19
+
20
+ def edit
21
+ end
22
+
23
+ def update
24
+ end
25
+
26
+ def destroy
27
+ end
28
+
29
+ private
30
+
31
+ def category_params
32
+ params.require(:forum).permit(:name, :category)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,45 @@
1
+ class MongoidForums::ApplicationController < ApplicationController
2
+ helper MongoidForums::Engine.helpers
3
+
4
+ before_action :set_categories
5
+ before_action :set_alerts
6
+
7
+ before_filter :authorize
8
+
9
+ delegate :allow?, to: :current_permission
10
+ helper_method :allow?
11
+
12
+ #delegate :allow_param?, to: :current_permission
13
+ #helper_method :allow?
14
+
15
+ private
16
+
17
+ def set_alerts
18
+ if mongoid_forums_user.present?
19
+ @alerts = MongoidForums::Alert.where(:user_id => mongoid_forums_user.id, :read => false).desc(:updated_at).limit(25)
20
+ end
21
+ end
22
+
23
+ def set_categories
24
+ @categories = MongoidForums::Category.all
25
+ end
26
+
27
+
28
+ def current_permission
29
+ @current_permission ||= MongoidForums::Permission.new(mongoid_forums_user)
30
+ end
31
+
32
+ def current_resource
33
+ nil
34
+ end
35
+
36
+
37
+ def authorize
38
+ if current_permission.allow? params[:controller], params[:action], current_resource
39
+ #current_permission.permit_params! params
40
+ else
41
+ redirect_to root_path, alert: "Not authorized"
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,57 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ class ForumsController < ApplicationController
5
+ def index
6
+ @categories = Category.all.order_by([:order, :asc])
7
+ end
8
+
9
+ def show
10
+ @forum = Forum.find(params[:id])
11
+ register_view
12
+
13
+ @topics = @forum.topics
14
+ @topics = @topics.by_pinned_or_most_recent_post.page(params[:page]).per(MongoidForums.per_page)
15
+ end
16
+
17
+ # Note: This is not an action to make a new Forum!
18
+ # it is to create a new TOPIC within a forum
19
+ def new
20
+ @forum = Forum.find(params[:forum_id])
21
+ @topic = Topic.new
22
+ @topic.forum = @forum.id
23
+ end
24
+
25
+ def create
26
+ @forum = Forum.find(params[:forum_id])
27
+ @topic = Topic.new
28
+ @topic.name = topic_params[:name]
29
+ @topic.user = mongoid_forums_user.id
30
+ @topic.forum = @forum.id
31
+ @post = Post.new
32
+ @post.user = mongoid_forums_user.id
33
+ @post.text = topic_params[:posts][:text]
34
+ @topic.posts << @post
35
+
36
+ if @topic.save && @topic.posts.first.save
37
+ flash[:notice] = "Topic created successfully"
38
+ redirect_to @topic
39
+ else
40
+ flash.now.alert = "Topic could not be created"
41
+ render :action => "new"
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def register_view
48
+ @forum.register_view_by(mongoid_forums_user)
49
+ end
50
+
51
+ def topic_params
52
+ params.require(:topic).permit(:name, :posts => [:text])
53
+ end
54
+
55
+
56
+ end
57
+ end
@@ -0,0 +1,75 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ class PostsController < ApplicationController
5
+ def new
6
+ @topic = Topic.find(params[:topic_id])
7
+ @post = Post.new
8
+ @post.topic = @topic.id
9
+ end
10
+
11
+ def create
12
+
13
+ @post = Post.new
14
+ @post.text = params[:post][:text]
15
+ @post.topic = params[:topic_id]
16
+ @post.user = mongoid_forums_user.id
17
+ @post.reply_to_id = params[:post][:reply_to_id]
18
+
19
+ if @post.reply_to_id && @post.reply_to_id == @post.topic.posts.first.id
20
+ flash[:alert] = "You may not quote the original post"
21
+ redirect_to @post.topic
22
+ return
23
+ end
24
+
25
+
26
+ if @post.topic.locked
27
+ flash[:alert] = "You may not post on a locked topic"
28
+ redirect_to @post.topic
29
+ return
30
+ end
31
+
32
+ if @post.save
33
+ @post.topic.alert_subscribers(mongoid_forums_user.id)
34
+ flash[:notice] = "Reply created successfully"
35
+ redirect_to @post.topic
36
+ else
37
+ flash.now.alert = "Reply could not be created"
38
+ render :action => "new"
39
+ end
40
+ end
41
+
42
+ def show
43
+ end
44
+
45
+ def edit
46
+ end
47
+
48
+ def update
49
+ @post = current_resource
50
+
51
+ if @post.update_attributes(post_params)
52
+ flash[:notice] = "Reply updated successfully"
53
+ redirect_to current_resource.topic
54
+ else
55
+ flash[:notice] = "Reply could not be updated"
56
+ render :action => "edit"
57
+ end
58
+ end
59
+
60
+ def destroy
61
+ end
62
+
63
+ private
64
+
65
+ def current_resource
66
+ @current_resource ||= Post.find(params[:id]) if params[:id]
67
+ end
68
+
69
+ def post_params
70
+ params.require(:post).permit(:text, :reply_to_id)
71
+ end
72
+
73
+
74
+ end
75
+ end
@@ -0,0 +1,33 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ class RedirectController < ApplicationController
5
+
6
+ def forum
7
+ return redirect_to forum_path(params[:forum_id])
8
+ end
9
+
10
+ def topic
11
+ return redirect_to topic_path(params[:topic_id])
12
+ end
13
+
14
+ def posts
15
+ post = Post.find(params[:post_id])
16
+ return redirect_to root_path, :notice => "Post does not exist" if post.topic == nil
17
+ x = 0
18
+
19
+ posts = post.topic.posts
20
+
21
+ posts.each_with_index do |p, i|
22
+ x = i
23
+ break if p.id == post.id
24
+ end
25
+ return redirect_to topic_url(post.topic, :page => (x / MongoidForums.per_page) + 1) + "#" + post.id.to_s
26
+ end
27
+
28
+ def subscriptions
29
+ return redirect_to my_subscriptions_path
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,84 @@
1
+ require_dependency "mongoid_forums/application_controller"
2
+
3
+ module MongoidForums
4
+ class TopicsController < ApplicationController
5
+ before_filter :find_forum, :except => [:my_subscriptions, :my_posts, :my_topics]
6
+
7
+ def show
8
+ if find_topic
9
+ register_view
10
+ @topic = current_resource
11
+
12
+ @posts = @topic.posts.order_by([:created_at, :asc])
13
+ @posts = @posts.page(params[:page]).per(MongoidForums.per_page)
14
+
15
+ if mongoid_forums_user.present?
16
+ Alert.where(:user_id => mongoid_forums_user.id).update_all(:read => true)
17
+ end
18
+ end
19
+ end
20
+
21
+ def destroy
22
+ end
23
+
24
+ def my_subscriptions
25
+ @subscriptions = Subscription.where(:subscriber_id => mongoid_forums_user.id, :subscribable_type => "MongoidForums::Topic", :unsubscribed => false).desc(:updated_at)
26
+ @topics = @subscriptions.page(params[:page]).per(MongoidForums.per_page)
27
+ return @topics.sort_by!{:updated_at}
28
+ end
29
+
30
+ def my_posts
31
+ @posts = Post.where(:user_id => mongoid_forums_user.id).by_updated_at.page(params[:page]).per(MongoidForums.per_page)
32
+ end
33
+
34
+ def my_topics
35
+ @topics = Topic.where(:user_id => mongoid_forums_user.id).by_most_recent_post.page(params[:page]).per(MongoidForums.per_page)
36
+ end
37
+
38
+ def subscribe
39
+ if find_topic
40
+ @topic.subscribe_user(mongoid_forums_user.id)
41
+ flash[:notice] = "Successfully subscribed to topic"
42
+ redirect_to topic_url(@topic)
43
+ end
44
+ end
45
+
46
+ def unsubscribe
47
+ if find_topic
48
+ @topic.unsubscribe_user(mongoid_forums_user.id)
49
+ flash[:notice] = "Successfully unsubscribed to topic"
50
+ redirect_to topic_url(@topic)
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def find_forum
57
+ @forum = Topic.find(params[:id]).forum
58
+ allow? "mongoid_forums/forums", :show, @forum
59
+ end
60
+
61
+ def find_topic
62
+ begin
63
+ scope = @forum.topics # TODO: pending review stuff
64
+ @topic = scope.find(params[:id])
65
+ allow? "mongoid_forums/topics", :show, @topic
66
+ rescue Mongoid::Errors::DocumentNotFound
67
+ flash.alert = t("forem.topic.not_found")
68
+ redirect_to @forum and return
69
+ end
70
+ end
71
+
72
+ def register_view
73
+ @topic.register_view_by(mongoid_forums_user)
74
+ end
75
+
76
+ def current_resource
77
+ @current_resource ||= Topic.find(params[:id]) if params[:id]
78
+ end
79
+
80
+ def topic_params
81
+ params.require(:topic).permit(:name, posts: [:text])
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,4 @@
1
+ module MongoidForums
2
+ module Admin::BaseHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module MongoidForums
2
+ module Admin::CategoriesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module MongoidForums
2
+ module Admin::ForumsHelper
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ module MongoidForums
2
+ module ApplicationHelper
3
+ include FormattingHelper
4
+ # processes text with installed markup formatter
5
+ def mongoid_forums_format(text, *options)
6
+ as_formatted_html(text)
7
+ end
8
+
9
+ def mongoid_forums_quote(text)
10
+ as_quoted_text(text)
11
+ end
12
+
13
+ def mongoid_forums_markdown(text, *options)
14
+ #TODO: delete deprecated method
15
+ Rails.logger.warn("DEPRECATION: forem_markdown is replaced by forem_format() + forem-markdown_formatter gem, and will be removed")
16
+ forem_format(text)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ module MongoidForums
2
+ module FormattingHelper
3
+ # override with desired markup formatter, e.g. textile or markdown
4
+ def as_formatted_html(text)
5
+ if MongoidForums.formatter
6
+ MongoidForums.formatter.format(as_sanitized_text(text))
7
+ else
8
+ MongoidForums::Sanitizer.sanitize(text).html_safe
9
+ end
10
+ end
11
+
12
+ def as_quoted_text(text)
13
+ if MongoidForums.formatter && Forem.formatter.respond_to?(:blockquote)
14
+ MongoidForums.formatter.blockquote(as_sanitized_text(text)).html_safe
15
+ else
16
+ "<blockquote>#{(h(text))}</blockquote>\n\n".html_safe
17
+ end
18
+ end
19
+
20
+ def as_sanitized_text(text)
21
+ if MongoidForums.formatter.respond_to?(:sanitize)
22
+ MongoidForums.formatter.sanitize(text)
23
+ else
24
+ Forem::Sanitizer.sanitize(text)
25
+ end
26
+ end
27
+ end
28
+ end