dm_forum 4.2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +23 -0
  3. data/README.md +33 -0
  4. data/Rakefile +30 -0
  5. data/app/assets/javascripts/dm_forum/admin.js +20 -0
  6. data/app/assets/javascripts/dm_forum/application.js +16 -0
  7. data/app/assets/javascripts/dm_forum/dm_forum.js +3 -0
  8. data/app/assets/stylesheets/dm_forum/admin.css +2 -0
  9. data/app/assets/stylesheets/dm_forum/application.css +12 -0
  10. data/app/controllers/dm_forum/admin/admin_controller.rb +13 -0
  11. data/app/controllers/dm_forum/admin/dashboard_controller.rb +12 -0
  12. data/app/controllers/dm_forum/admin/forum_categories_controller.rb +80 -0
  13. data/app/controllers/dm_forum/admin/forum_sites_controller.rb +40 -0
  14. data/app/controllers/dm_forum/admin/forums_controller.rb +113 -0
  15. data/app/controllers/dm_forum/application_controller.rb +25 -0
  16. data/app/controllers/dm_forum/forum_comments_controller.rb +88 -0
  17. data/app/controllers/dm_forum/forum_topics_controller.rb +93 -0
  18. data/app/controllers/dm_forum/forums_controller.rb +45 -0
  19. data/app/datatables/forum_user_datatable.rb +79 -0
  20. data/app/helpers/dm_forum/application_helper.rb +5 -0
  21. data/app/helpers/dm_forum/forum_helper.rb +109 -0
  22. data/app/mailers/forum_notification_mailer.rb +27 -0
  23. data/app/models/dm_forum/concerns/ability.rb +50 -0
  24. data/app/models/dm_forum/concerns/user.rb +37 -0
  25. data/app/models/dm_forum/permitted_params.rb +38 -0
  26. data/app/models/forum.rb +74 -0
  27. data/app/models/forum_category.rb +14 -0
  28. data/app/models/forum_comment.rb +93 -0
  29. data/app/models/forum_site.rb +27 -0
  30. data/app/models/forum_topic.rb +146 -0
  31. data/app/presenters/forum_comment_presenter.rb +8 -0
  32. data/app/presenters/forum_common_presenter.rb +31 -0
  33. data/app/presenters/forum_presenter.rb +14 -0
  34. data/app/views/dm_forum/admin/dashboard/_widget_forum_comments.html.erb +38 -0
  35. data/app/views/dm_forum/admin/dashboard/widget_forum_comments.js.erb +1 -0
  36. data/app/views/dm_forum/admin/forum_categories/_content_toolbar.html.erb +5 -0
  37. data/app/views/dm_forum/admin/forum_categories/_form.html.erb +18 -0
  38. data/app/views/dm_forum/admin/forum_categories/edit.html.erb +3 -0
  39. data/app/views/dm_forum/admin/forum_categories/index.html.erb +25 -0
  40. data/app/views/dm_forum/admin/forum_categories/new.html.erb +3 -0
  41. data/app/views/dm_forum/admin/forum_categories/show.html.erb +41 -0
  42. data/app/views/dm_forum/admin/forum_sites/_form.html.erb +18 -0
  43. data/app/views/dm_forum/admin/forum_sites/edit.html.erb +2 -0
  44. data/app/views/dm_forum/admin/forum_sites/show.html.erb +12 -0
  45. data/app/views/dm_forum/admin/forums/_content_toolbar.html.erb +5 -0
  46. data/app/views/dm_forum/admin/forums/_form.html.erb +24 -0
  47. data/app/views/dm_forum/admin/forums/edit.html.erb +2 -0
  48. data/app/views/dm_forum/admin/forums/new.html.erb +2 -0
  49. data/app/views/dm_forum/admin/forums/show.html.erb +68 -0
  50. data/app/views/dm_forum/forum_comments/_formatting.html.erb +12 -0
  51. data/app/views/dm_forum/forum_comments/edit.html.erb +15 -0
  52. data/app/views/dm_forum/forum_topics/_comment_item.html.erb +26 -0
  53. data/app/views/dm_forum/forum_topics/_comments_list.html.erb +63 -0
  54. data/app/views/dm_forum/forum_topics/_follow_button.html.erb +3 -0
  55. data/app/views/dm_forum/forum_topics/_form.html.erb +24 -0
  56. data/app/views/dm_forum/forum_topics/edit.html.erb +13 -0
  57. data/app/views/dm_forum/forum_topics/new.html.erb +13 -0
  58. data/app/views/dm_forum/forum_topics/show.html.erb +49 -0
  59. data/app/views/dm_forum/forum_topics/toggle_follow.js.coffee +5 -0
  60. data/app/views/dm_forum/forums/_category_side_list.html.erb +28 -0
  61. data/app/views/dm_forum/forums/_forum_header.html.erb +14 -0
  62. data/app/views/dm_forum/forums/_no_forums.html.erb +1 -0
  63. data/app/views/dm_forum/forums/_topics_list.html.erb +86 -0
  64. data/app/views/dm_forum/forums/categories.html.erb +32 -0
  65. data/app/views/dm_forum/forums/list.html.erb +10 -0
  66. data/app/views/dm_forum/forums/show.html.erb +39 -0
  67. data/app/views/layouts/email_templates/forum_notification.html.erb +15 -0
  68. data/app/views/layouts/email_templates/forum_notification.text.erb +16 -0
  69. data/config/initializers/dm_forum.rb +0 -0
  70. data/config/locales/fms.cs.yml +104 -0
  71. data/config/locales/fms.de.yml +104 -0
  72. data/config/locales/fms.en.yml +104 -0
  73. data/config/locales/fms.fi.yml +104 -0
  74. data/config/locales/fms.ja.yml +104 -0
  75. data/config/routes.rb +43 -0
  76. data/db/migrate/20130103151149_create_forums.rb +72 -0
  77. data/db/migrate/20130424125513_add_public_forum.rb +13 -0
  78. data/db/migrate/20130430084925_add_forum_category.rb +7 -0
  79. data/db/migrate/20140201112134_delete_monitorships.rb +17 -0
  80. data/db/migrate/20140303121325_add_requires_subscription_forum.rb +5 -0
  81. data/db/migrate/20140423113420_add_forum_owner.rb +6 -0
  82. data/db/migrate/20160821150125_index_foreign_keys_in_fms_forum_sites.rb +5 -0
  83. data/db/migrate/20160821150126_index_foreign_keys_in_fms_forum_topics.rb +9 -0
  84. data/db/migrate/20160821150127_index_foreign_keys_in_fms_forums.rb +7 -0
  85. data/lib/dm_forum/engine.rb +9 -0
  86. data/lib/dm_forum/version.rb +3 -0
  87. data/lib/dm_forum.rb +4 -0
  88. data/lib/tasks/dm_forum_tasks.rake +4 -0
  89. data/spec/dummy/README.rdoc +28 -0
  90. data/spec/dummy/Rakefile +6 -0
  91. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  92. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  93. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  94. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  95. data/spec/dummy/app/models/ability.rb +12 -0
  96. data/spec/dummy/app/models/user.rb +6 -0
  97. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  98. data/spec/dummy/bin/bundle +3 -0
  99. data/spec/dummy/bin/rails +4 -0
  100. data/spec/dummy/bin/rake +4 -0
  101. data/spec/dummy/config/application.rb +26 -0
  102. data/spec/dummy/config/boot.rb +5 -0
  103. data/spec/dummy/config/database.yml +25 -0
  104. data/spec/dummy/config/environment.rb +5 -0
  105. data/spec/dummy/config/environments/development.rb +37 -0
  106. data/spec/dummy/config/environments/production.rb +82 -0
  107. data/spec/dummy/config/environments/test.rb +39 -0
  108. data/spec/dummy/config/initializers/assets.rb +8 -0
  109. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  110. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  111. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  112. data/spec/dummy/config/initializers/inflections.rb +16 -0
  113. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  114. data/spec/dummy/config/initializers/session_store.rb +3 -0
  115. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  116. data/spec/dummy/config/locales/en.yml +23 -0
  117. data/spec/dummy/config/routes.rb +17 -0
  118. data/spec/dummy/config/secrets.yml +22 -0
  119. data/spec/dummy/config.ru +4 -0
  120. data/spec/dummy/db/development.sqlite3 +0 -0
  121. data/spec/dummy/db/migrate/20141114170927_add_globalize_countries.dm_core.rb +50 -0
  122. data/spec/dummy/db/migrate/20141114170928_devise_create_users.dm_core.rb +46 -0
  123. data/spec/dummy/db/migrate/20141114170929_add_user_fields.dm_core.rb +14 -0
  124. data/spec/dummy/db/migrate/20141114170930_rolify_create_roles.dm_core.rb +20 -0
  125. data/spec/dummy/db/migrate/20141114170931_add_last_access.dm_core.rb +10 -0
  126. data/spec/dummy/db/migrate/20141114170932_create_versions.dm_core.rb +19 -0
  127. data/spec/dummy/db/migrate/20141114170933_add_object_changes_column_to_versions.dm_core.rb +12 -0
  128. data/spec/dummy/db/migrate/20141114170934_create_dm_core_accounts.dm_core.rb +13 -0
  129. data/spec/dummy/db/migrate/20141114170935_add_account_to_users.dm_core.rb +9 -0
  130. data/spec/dummy/db/migrate/20141114170936_create_preferences.dm_core.rb +13 -0
  131. data/spec/dummy/db/migrate/20141114170937_create_comments.dm_core.rb +22 -0
  132. data/spec/dummy/db/migrate/20141114170938_add_activity.dm_core.rb +21 -0
  133. data/spec/dummy/db/migrate/20141114170939_add_type_to_comments.dm_core.rb +9 -0
  134. data/spec/dummy/db/migrate/20141114170940_add_category.dm_core.rb +28 -0
  135. data/spec/dummy/db/migrate/20141114170941_create_email_table.dm_core.rb +26 -0
  136. data/spec/dummy/db/migrate/20141114170942_add_user_profile.dm_core.rb +46 -0
  137. data/spec/dummy/db/migrate/20141114170943_add_profile_email.dm_core.rb +14 -0
  138. data/spec/dummy/db/migrate/20141114170944_create_payment_history.dm_core.rb +37 -0
  139. data/spec/dummy/db/migrate/20141114170945_change_anchor_field.dm_core.rb +10 -0
  140. data/spec/dummy/db/migrate/20141114170946_create_user_site_profile.dm_core.rb +27 -0
  141. data/spec/dummy/db/migrate/20141114170947_add_avatar.dm_core.rb +12 -0
  142. data/spec/dummy/db/migrate/20141114170948_add_notify_to_payment_history.dm_core.rb +8 -0
  143. data/spec/dummy/db/migrate/20141114170949_acts_as_votable_migration.dm_core.rb +28 -0
  144. data/spec/dummy/db/migrate/20141114170950_add_user_site_profile_uuid.dm_core.rb +19 -0
  145. data/spec/dummy/db/migrate/20141114170951_add_invoice_id.dm_core.rb +7 -0
  146. data/spec/dummy/db/migrate/20141114170952_acts_as_follower_migration.dm_core.rb +18 -0
  147. data/spec/dummy/db/migrate/20141114170953_rename_invoice_id.dm_core.rb +12 -0
  148. data/spec/dummy/db/migrate/20141114170954_add_core_addresses.dm_core.rb +18 -0
  149. data/spec/dummy/db/migrate/20141114170955_papertrail_increase_column.dm_core.rb +9 -0
  150. data/spec/dummy/db/migrate/20141114170956_acts_as_taggable_on_migration.dm_core.rb +32 -0
  151. data/spec/dummy/db/migrate/20141114170957_add_missing_unique_indices.dm_core.rb +23 -0
  152. data/spec/dummy/db/migrate/20141114170958_add_taggings_counter_cache_to_tags.dm_core.rb +16 -0
  153. data/spec/dummy/db/migrate/20141114170959_create_custom_fields.dm_core.rb +40 -0
  154. data/spec/dummy/db/migrate/20141114170960_add_missing_taggable_index.dm_core.rb +11 -0
  155. data/spec/dummy/db/migrate/20141119112030_create_cms.dm_cms.rb +92 -0
  156. data/spec/dummy/db/migrate/20141119112031_add_account_to_cms.dm_cms.rb +11 -0
  157. data/spec/dummy/db/migrate/20141119112032_create_blog.dm_cms.rb +62 -0
  158. data/spec/dummy/db/migrate/20141119112033_add_notification_sent.dm_cms.rb +6 -0
  159. data/spec/dummy/db/migrate/20141119112034_add_blog_comment.dm_cms.rb +8 -0
  160. data/spec/dummy/db/migrate/20141119112035_add_blog_image.dm_cms.rb +6 -0
  161. data/spec/dummy/db/migrate/20141119112036_rename_snippet_slug.dm_cms.rb +14 -0
  162. data/spec/dummy/db/migrate/20141119112037_add_requires_subscription_blog.dm_cms.rb +8 -0
  163. data/spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb +23 -0
  164. data/spec/dummy/db/migrate/20141119112039_add_blog_owner.dm_cms.rb +7 -0
  165. data/spec/dummy/db/migrate/20141119112040_create_media_files.dm_cms.rb +30 -0
  166. data/spec/dummy/db/migrate/20141119112041_add_cmspage_summary.dm_cms.rb +7 -0
  167. data/spec/dummy/db/migrate/20141119112042_add_blog_image_email_header.dm_cms.rb +6 -0
  168. data/spec/dummy/db/migrate/20141119112043_add_header_image.dm_cms.rb +10 -0
  169. data/spec/dummy/db/migrate/20160128144312_add_favored_locale.dm_core.rb +17 -0
  170. data/spec/dummy/db/migrate/20160128144313_update_papertrail_v4.dm_core.rb +41 -0
  171. data/spec/dummy/db/schema.rb +628 -0
  172. data/spec/dummy/public/404.html +67 -0
  173. data/spec/dummy/public/422.html +67 -0
  174. data/spec/dummy/public/500.html +66 -0
  175. data/spec/dummy/public/favicon.ico +0 -0
  176. data/spec/factories/accounts.rb +9 -0
  177. data/spec/factories/user_profiles.rb +10 -0
  178. data/spec/factories/users.rb +19 -0
  179. data/spec/models/forum_spec.rb +9 -0
  180. data/spec/rails_helper.rb +70 -0
  181. data/spec/spec_helper.rb +85 -0
  182. data/spec/support/accounts.rb +17 -0
  183. data/spec/support/devise.rb +44 -0
  184. data/spec/support/fix_locale.rb +57 -0
  185. metadata +337 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3506b203a501e3947202c72e34736bf2de3d6ae7
4
+ data.tar.gz: ac2c16612a4216a13406d6904674196cdab9b7cf
5
+ SHA512:
6
+ metadata.gz: 43f82a4dbaef34e13cf79c8aab88e2d25a71b94645677875126bda3bf6f20646c2d671bb7a6d27460607d9776623e38f28a176300d4b66a2c97c8fa20dfb4f1e
7
+ data.tar.gz: 64af476e10ba9edaecd5a8aaad85089284054a58c7fcf09cf26d0b45443f4ed445563e0276422d2a1cb684938af06ace0714be3c75c4b0e1f656ab160a90ad81
data/MIT-LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright 2013 digitalMoksha LLC
2
+
3
+ Portions of this code is based off of Heterotic Beast and it's ancestors, which was
4
+ Copyright (c) 2006 - 2011 Josh Goebel, Courtenay Gasking, Rick Olson and Jacques Distler
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # dm_forum
2
+
3
+ **dm_forum** provides the forum management system for the MokshaCMS collection of gems. Forum and forum categories can be created. Forums can be publically open, or private with access limited to specific registered users or users that are registered in an event/workshop (dm_event)
4
+
5
+ _The MokshaCMS collection of gems provides an integrated system of services for content, event, forum, learning, and newsletter management. It supports sites with multiple languages and mutliple distinct sites per installation. Administration is built in. Additional services/engines can be written to provide additional functionality._
6
+
7
+ - core foundation ([dm_core](https://github.com/digitalmoksha/dm_core))
8
+ - content management ([dm_cms](https://github.com/digitalmoksha/dm_cms))
9
+ - event management ([dm_event](https://github.com/digitalmoksha/dm_event))
10
+ - forum management ([dm_forum](https://github.com/digitalmoksha/dm_forum))
11
+ - learning management ([dm_lms](https://github.com/digitalmoksha/dm_lms))
12
+ - newsletter management ([dm_newsletter](https://github.com/digitalmoksha/dm_newsletter))
13
+
14
+ ## Installation
15
+
16
+ Add the following to your Gem file:
17
+
18
+ ```
19
+ gem 'dm_preferences', '~> 1.0'
20
+ gem 'dm_core', git: 'https://github.com/digitalmoksha/dm_core.git', branch: '4-2-stable'
21
+ gem 'dm_cms', git: 'https://github.com/digitalmoksha/dm_cms.git', branch: '4-2-stable'
22
+ gem 'dm_forum', git: 'https://github.com/digitalmoksha/dm_forum.git', branch: '4-2-stable'
23
+ gem 'themes_for_rails', git: 'git://github.com/digitalmoksha/themes_for_rails.git'
24
+ gem 'aced_rails', git: 'git://github.com/digitalmoksha/aced_rails.git'
25
+ ```
26
+
27
+ After running `bundle install`, run
28
+
29
+ ```
30
+ rake dm_core:install:migrations
31
+ rake dm_cms:install:migrations
32
+ rake dm_forum:install:migrations
33
+ ```
data/Rakefile ADDED
@@ -0,0 +1,30 @@
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 = 'DmForum'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ require 'rspec/core'
25
+ require 'rspec/core/rake_task'
26
+
27
+ desc "Run all specs in spec directory (excluding plugin specs)"
28
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
29
+
30
+ task :default => :spec
@@ -0,0 +1,20 @@
1
+ $(document).ready(function() {
2
+
3
+ //----------------------------------------------------------------
4
+ $('#forum_user_table').dataTable( {
5
+ bJQueryUI: false,
6
+ bAutoWidth: false,
7
+ sPaginationType: 'full_numbers',
8
+ iDisplayLength: 10,
9
+ bProcessing: false,
10
+ bServerSide: true,
11
+ bStateSave: false,
12
+ aaSorting: [[0, 'asc']],
13
+ sDom: '<"datatable-header"f>t<"datatable-footer">',
14
+ oLanguage: {
15
+ sLengthMenu: "<span>Show entries:</span> _MENU_"
16
+ },
17
+ sAjaxSource: $('#forum_user_table').data('source')
18
+ });
19
+
20
+ });
@@ -0,0 +1,16 @@
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 vendor/assets/javascripts of plugins, if any, 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
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
16
+
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+
3
+ });
@@ -0,0 +1,2 @@
1
+ /*=== DmForum specific CSS ===*/
2
+
@@ -0,0 +1,12 @@
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
+ */
@@ -0,0 +1,13 @@
1
+ class DmForum::Admin::AdminController < DmCore::Admin::AdminController
2
+ before_filter :authorize_access
3
+
4
+ protected
5
+
6
+ #------------------------------------------------------------------------------
7
+ def authorize_access
8
+ unless can?(:manage_forums, :all)
9
+ flash[:alert] = "Unauthorized Access!"
10
+ redirect_to current_account.index_path
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class DmForum::Admin::DashboardController < DmForum::Admin::AdminController
2
+
3
+ #------------------------------------------------------------------------------
4
+ def widget_forum_comments
5
+ @comment_day = params[:comment_day].to_i
6
+ respond_to do |format|
7
+ format.html
8
+ format.js
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,80 @@
1
+ class DmForum::Admin::ForumCategoriesController < DmForum::Admin::AdminController
2
+ include DmForum::PermittedParams
3
+
4
+ before_filter :check_forum_site, only: [:index]
5
+ before_filter :category_lookup, except: [:index, :new, :create]
6
+
7
+ # GET /admin/forum_categories
8
+ #------------------------------------------------------------------------------
9
+ def index
10
+ @forum_categories = ForumCategory.ordered
11
+ end
12
+
13
+ # GET /admin/forum_categories/1
14
+ #------------------------------------------------------------------------------
15
+ def show
16
+ end
17
+
18
+ # GET /admin/forum_categories/new
19
+ #------------------------------------------------------------------------------
20
+ def new
21
+ @forum_category = ForumCategory.new
22
+ end
23
+
24
+ # GET /admin/forum_categories/1/edit
25
+ #------------------------------------------------------------------------------
26
+ def edit
27
+ end
28
+
29
+ # POST /admin/forum_categories
30
+ #------------------------------------------------------------------------------
31
+ def create
32
+ @forum_category = ForumCategory.new(forum_category_params)
33
+
34
+ if @forum_category.save
35
+ redirect_to admin_forum_category_url(@forum_category), notice: 'Forum Category was successfully created.'
36
+ else
37
+ render action: :new
38
+ end
39
+ end
40
+
41
+ # PUT /admin/forum_categories/1
42
+ #------------------------------------------------------------------------------
43
+ def update
44
+ if @forum_category.update_attributes(forum_category_params)
45
+ redirect_to admin_forum_category_url(@forum_category), notice: 'Forum Category was successfully updated.'
46
+ else
47
+ render action: :edit
48
+ end
49
+ end
50
+
51
+ # DELETE /admin/forum_categories/1
52
+ #------------------------------------------------------------------------------
53
+ def destroy
54
+ @forum_category.destroy
55
+
56
+ redirect_to admin_forum_categories_url
57
+ end
58
+
59
+ #------------------------------------------------------------------------------
60
+ def sort
61
+ @forum_category.update_attribute(:row_order_position, params[:item][:row_order_position])
62
+
63
+ #--- this action will be called via ajax
64
+ render nothing: true
65
+ end
66
+
67
+ private
68
+
69
+ # make sure a ForumSite singleton is created
70
+ #------------------------------------------------------------------------------
71
+ def check_forum_site
72
+ ForumSite.create(enabled: true) unless ForumSite.site
73
+ end
74
+
75
+ #------------------------------------------------------------------------------
76
+ def category_lookup
77
+ @forum_category = ForumCategory.find(params[:id])
78
+ end
79
+
80
+ end
@@ -0,0 +1,40 @@
1
+ # This controller is now deprecated. At the moment I find no use
2
+ # for the enableg, tagline, or description.
3
+ #------------------------------------------------------------------------------
4
+ class DmForum::Admin::ForumSitesController < DmForum::Admin::AdminController
5
+ include DmForum::PermittedParams
6
+
7
+ before_filter :forum_site_lookup
8
+
9
+ # GET /admin/fms/forum_site
10
+ #------------------------------------------------------------------------------
11
+ def show
12
+ unless @forum_site
13
+ @forum_site = ForumSite.create(enabled: true)
14
+ end
15
+ end
16
+
17
+
18
+ # GET /admin/fms/forum_site/edit
19
+ #------------------------------------------------------------------------------
20
+ def edit
21
+ end
22
+
23
+ # PUT /admin/fms/forum_site
24
+ #------------------------------------------------------------------------------
25
+ def update
26
+ if @forum_site.update_attributes(forum_site_params)
27
+ redirect_to dm_forum.admin_forum_site_url, notice: "Forum settings were successfully updated."
28
+ else
29
+ render action: :edit
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ #------------------------------------------------------------------------------
36
+ def forum_site_lookup
37
+ @forum_site = ForumSite.site
38
+ end
39
+
40
+ end
@@ -0,0 +1,113 @@
1
+ class DmForum::Admin::ForumsController < DmForum::Admin::AdminController
2
+ include DmForum::PermittedParams
3
+
4
+ before_filter :category_lookup, :only => [:index, :new, :create]
5
+ before_filter :forum_lookup, :except => [:index, :new, :create]
6
+ #before_filter :set_title
7
+
8
+ # GET /admin/fms/forums
9
+ #------------------------------------------------------------------------------
10
+ def index
11
+ if ForumSite.first
12
+ @forums = @forum_category.forums.ordered
13
+ else
14
+ redirect_to admin_forum_site_path, notice: "Please configure the Forum system first"
15
+ end
16
+ end
17
+
18
+ #------------------------------------------------------------------------------
19
+ def show
20
+
21
+ end
22
+
23
+ # GET /admin/fms/forums/new
24
+ #------------------------------------------------------------------------------
25
+ def new
26
+ @forum = @forum_category.forums.build
27
+ end
28
+
29
+ # GET /admin/fms/forums/1/edit
30
+ #------------------------------------------------------------------------------
31
+ def edit
32
+ end
33
+
34
+ # POST /admin/fms/forums
35
+ #------------------------------------------------------------------------------
36
+ def create
37
+ @forum = @forum_category.forums.new(forum_params)
38
+ @forum.forum_site = ForumSite.site
39
+
40
+ if @forum.save
41
+ redirect_to admin_forum_category_url(@forum_category), notice: 'Forum was successfully created.'
42
+ else
43
+ render action: :new
44
+ end
45
+ end
46
+
47
+ # PUT /admin/fms/forums/1
48
+ #------------------------------------------------------------------------------
49
+ def update
50
+ if @forum.update_attributes(forum_params)
51
+ redirect_to admin_forum_url(@forum), notice: 'Forum was successfully updated.'
52
+ else
53
+ render action: :edit
54
+ end
55
+ end
56
+
57
+ # DELETE /admin/fms/forums/1
58
+ #------------------------------------------------------------------------------
59
+ def destroy
60
+ @forum.destroy
61
+
62
+ redirect_to admin_forum_category_url(@forum.forum_category)
63
+ end
64
+
65
+ #------------------------------------------------------------------------------
66
+ def sort
67
+ @forum.update_attribute(:row_order_position, params[:item][:row_order_position])
68
+
69
+ #--- this action will be called via ajax
70
+ render nothing: true
71
+ end
72
+
73
+ #------------------------------------------------------------------------------
74
+ def forum_users
75
+ respond_to do |format|
76
+ format.json { render json: ForumUserDatatable.new(view_context, @forum) }
77
+ end
78
+ end
79
+
80
+ # Add user(s) to forum.
81
+ # => user_id: add a single user
82
+ #------------------------------------------------------------------------------
83
+ def forum_add_member
84
+ if !params[:user_id].blank?
85
+ user = User.find(params[:user_id])
86
+ @forum.add_member(user)
87
+ redirect_to admin_forum_url(@forum), notice: "Forum access granted for #{user.full_name}"
88
+ else
89
+ redirect_to admin_forum_url(@forum), alert: "Incorrect parameters supplied"
90
+ end
91
+ end
92
+
93
+ #------------------------------------------------------------------------------
94
+ def forum_delete_member
95
+ user = User.find(params[:user_id])
96
+ @forum.remove_member(user)
97
+ redirect_to admin_forum_url(@forum), notice: "Forum access removed for #{user.full_name}"
98
+ end
99
+
100
+ private
101
+
102
+ #------------------------------------------------------------------------------
103
+ def category_lookup
104
+ @forum_category = ForumCategory.find(params[:forum_category_id])
105
+ end
106
+
107
+ #------------------------------------------------------------------------------
108
+ def forum_lookup
109
+ @forum = Forum.friendly.find(params[:id])
110
+ @forum_category = @forum.forum_category
111
+ end
112
+
113
+ end
@@ -0,0 +1,25 @@
1
+ # Subclass from main ApplicationController, which will subclass from DmCore
2
+ #------------------------------------------------------------------------------
3
+ class DmForum::ApplicationController < ::ApplicationController
4
+ include ApplicationHelper
5
+
6
+ #--- these are needed to support rendering layouts built for the CMS
7
+ helper DmCms::RenderHelper
8
+ helper DmCore::LiquidHelper
9
+ helper DmCms::PagesHelper
10
+ include DmCore::RenderHelper
11
+
12
+ #before_filter :authenticate_user!
13
+
14
+ layout 'forum_templates/forum_list'
15
+
16
+ rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
17
+
18
+ private
19
+
20
+ #------------------------------------------------------------------------------
21
+ def record_not_found
22
+ flash[:error] = "The forum or discussion you were looking for could not be found."
23
+ redirect_to forum_root_path
24
+ end
25
+ end
@@ -0,0 +1,88 @@
1
+ class DmForum::ForumCommentsController < DmForum::ApplicationController
2
+ include DmForum::PermittedParams
3
+ include ActionView::RecordIdentifier # for the dom_id method
4
+
5
+ before_filter :find_parents
6
+ before_filter :find_post, :only => [:edit, :update, :destroy]
7
+
8
+ # {todo} look into caching and sweepers - most of our stuff is not directly public
9
+ #cache_sweeper :forum_comments_sweeper, :only => [:create, :update, :destroy]
10
+
11
+ # /posts
12
+ # /users/1/posts
13
+ # /forums/1/posts
14
+ # /forums/1/topics/1/posts
15
+ #------------------------------------------------------------------------------
16
+ def index
17
+ @followed = user_signed_in? && params[:followed]
18
+ @q = params[:q] ? params[:q].purify : nil
19
+ @posts = (@parent ? @parent.forum_comments : ForumSite.site.forum_comments).search(@q, :page => page_number)
20
+ @followed_posts = user_signed_in? ? (@parent ? @parent.forum_comments : ForumSite.site.forum_comments).search_followed(current_user.id, @q, :page => page_number) : nil
21
+ @users = @user ? {@user.id => @user} : User.index_from(@posts)
22
+ end
23
+
24
+ #------------------------------------------------------------------------------
25
+ def show
26
+ redirect_to forum_forum_topic_path(@forum, @forum_topic)
27
+ end
28
+
29
+ #------------------------------------------------------------------------------
30
+ def edit
31
+ end
32
+
33
+ #------------------------------------------------------------------------------
34
+ def create
35
+ @forum_comment = ForumComment.create_comment(@forum_topic, params[:forum_comment][:body], current_user)
36
+ if @forum_comment.new_record?
37
+ redirect_to forum_forum_topic_path(@forum, @forum_topic)
38
+ else
39
+ current_user.following.follow(@forum_topic)
40
+ flash[:notice] = 'Comment successfully created.'
41
+ redirect_to(forum_forum_topic_path(@forum, @forum_topic, {:anchor => dom_id(@forum_comment), :page => @forum_topic.last_page}))
42
+ end
43
+ end
44
+
45
+ #------------------------------------------------------------------------------
46
+ def update
47
+ if @forum_comment.update_attributes(forum_comment_params)
48
+ flash[:notice] = 'Post was successfully updated.'
49
+ redirect_to(forum_forum_topic_path(@forum, @forum_topic, {:anchor => dom_id(@forum_comment), :page => @forum_topic.comment_page(@forum_comment)}))
50
+ else
51
+ render :action => :edit
52
+ end
53
+ end
54
+
55
+ #------------------------------------------------------------------------------
56
+ def destroy
57
+ @forum_comment.destroy
58
+
59
+ if @forum.forum_topics.exists?(@forum_topic)
60
+ redirect_to forum_forum_topic_path(@forum, @forum_topic)
61
+ else
62
+ redirect_to @forum
63
+ end
64
+ end
65
+
66
+ protected
67
+
68
+ #------------------------------------------------------------------------------
69
+ def find_parents
70
+ if params[:user_id]
71
+ @parent = @user = User.find(params[:user_id])
72
+ elsif params[:forum_id]
73
+ @parent = @forum = Forum.find_by_slug!(params[:forum_id])
74
+ @parent = @forum_topic = @forum.forum_topics.find_by_slug(params[:forum_topic_id]) if params[:forum_topic_id]
75
+ authorize! :read, @forum
76
+ end
77
+ end
78
+
79
+ #------------------------------------------------------------------------------
80
+ def find_post
81
+ forum_comment = @forum_topic.forum_comments.find(params[:id])
82
+ if forum_comment.user == current_user || can?(:moderate, @forum)
83
+ @forum_comment = forum_comment
84
+ else
85
+ raise ActiveRecord::RecordNotFound
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,93 @@
1
+ class DmForum::ForumTopicsController < DmForum::ApplicationController
2
+ include DmForum::PermittedParams
3
+
4
+ before_filter :find_forum
5
+ before_filter :find_topic, :only => [:show, :edit, :update, :destroy]
6
+ # before_filter :admin_required, :only => [:edit, :update, :destroy]
7
+ #
8
+
9
+ layout 'forum_templates/forum_list'
10
+
11
+ #------------------------------------------------------------------------------
12
+ def index
13
+ respond_to do |format|
14
+ format.html { redirect_to forum_path(@forum) }
15
+ format.xml do
16
+ @forum_topics = find_forum.topics.paginate(:page => page_number)
17
+ render :xml => @forum_topics
18
+ end
19
+ end
20
+ end
21
+
22
+ #------------------------------------------------------------------------------
23
+ def show
24
+ (session[:forum_topics] ||= {})[@forum_topic.id] = Time.now.utc if user_signed_in?
25
+ @forum_topic.hit! unless user_signed_in? && @forum_topic.user_id == current_user.id
26
+ @forum_comments = @forum_topic.forum_comments.paginate :page => page_number
27
+ @forum_comment = ForumComment.new
28
+ @following = user_signed_in? && @forum_topic.followed_by?(current_user.following)
29
+ end
30
+
31
+ #------------------------------------------------------------------------------
32
+ def new
33
+ @forum_topic = @forum.forum_topics.new
34
+ end
35
+
36
+ #------------------------------------------------------------------------------
37
+ def create
38
+ params[:forum_topic].delete(:forum_id)
39
+ @forum_topic = @forum.forum_topics.new(forum_topic_params)
40
+ @forum_topic.user = current_user
41
+ if @forum_topic.save
42
+ current_user.following.follow(@forum_topic)
43
+ redirect_to forum_forum_topic_path(@forum, @forum_topic), notice: 'Topic was successfully created.'
44
+ else
45
+ render :action => :new
46
+ end
47
+ end
48
+
49
+ #------------------------------------------------------------------------------
50
+ def edit
51
+ end
52
+
53
+ #------------------------------------------------------------------------------
54
+ def update
55
+ #current_user.revise @topic, params[:topic]
56
+ attributes = forum_topic_params
57
+ @forum_topic.title = attributes[:title] if attributes.key?(:title)
58
+ @forum_topic.sticky, @forum_topic.locked, @forum_topic.forum_id = attributes[:sticky], attributes[:locked], attributes[:forum_id] if can?(:moderate, @forum_topic.forum)
59
+ @forum_topic.save
60
+ if @forum_topic.errors.empty?
61
+ flash[:notice] = 'Topic was successfully updated.'
62
+ redirect_to(forum_forum_topic_path(Forum.find(@forum_topic.forum_id), @forum_topic))
63
+ else
64
+ render :action => "edit"
65
+ end
66
+ end
67
+
68
+ #------------------------------------------------------------------------------
69
+ def destroy
70
+ @forum_topic.destroy if is_admin?
71
+ redirect_to @forum
72
+ end
73
+
74
+ #------------------------------------------------------------------------------
75
+ def toggle_follow
76
+ @forum_topic = @forum.forum_topics.find(params[:forum_topic_id])
77
+ @following = current_user.following.following?(@forum_topic)
78
+ @following ? current_user.following.stop_following(@forum_topic) : current_user.following.follow(@forum_topic)
79
+ end
80
+
81
+ protected
82
+
83
+ #------------------------------------------------------------------------------
84
+ def find_forum
85
+ @forum = Forum.find_by_slug!(params[:forum_id])
86
+ authorize! :read, @forum
87
+ end
88
+
89
+ #------------------------------------------------------------------------------
90
+ def find_topic
91
+ @forum_topic = @forum.forum_topics.find_by_slug!(params[:id])
92
+ end
93
+ end
@@ -0,0 +1,45 @@
1
+ class DmForum::ForumsController < DmForum::ApplicationController
2
+ include ApplicationHelper
3
+
4
+ #--- these are needed to support rendering layouts built for the CMS
5
+ helper DmCms::RenderHelper
6
+ helper DmCore::LiquidHelper
7
+ helper DmCms::PagesHelper
8
+ include DmCore::RenderHelper
9
+
10
+ before_filter :forum_lookup, :except => [:list, :categories]
11
+
12
+ layout 'forum_templates/forum_list', :only => [:list, :show, :categories]
13
+
14
+ #------------------------------------------------------------------------------
15
+ def categories
16
+ @forum_categories = ForumCategory.ordered
17
+ end
18
+
19
+ # GET /forum
20
+ #------------------------------------------------------------------------------
21
+ def list
22
+ @forums = Forum.available_to_user(current_user)
23
+ end
24
+
25
+ # GET /forum/:slug
26
+ #------------------------------------------------------------------------------
27
+ def show
28
+ (session[:forums] ||= {})[@forum.id] = Time.now.utc
29
+ (session[:forums_page] ||= Hash.new(1))[@forum.id] = page_number if page_number > 1
30
+ @followed = user_signed_in? && params[:followed]
31
+ @forum_topics ||= @forum.forum_topics.paginate :page => page_number
32
+ @followed_topics ||= user_signed_in? ?
33
+ (@forum.followed_topics(current_user).paginate :page => page_number) :
34
+ nil
35
+ end
36
+
37
+ protected
38
+
39
+ #------------------------------------------------------------------------------
40
+ def forum_lookup
41
+ @forum = Forum.find_by_slug!(params[:id])
42
+ authorize! :read, @forum
43
+ end
44
+
45
+ end