thredded 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/commands/thredded/at_notification_extractor.rb +1 -0
  4. data/app/commands/thredded/autofollow_users.rb +1 -0
  5. data/app/commands/thredded/create_messageboard.rb +1 -0
  6. data/app/commands/thredded/mark_all_read.rb +1 -0
  7. data/app/commands/thredded/moderate_post.rb +1 -0
  8. data/app/commands/thredded/notify_following_users.rb +1 -0
  9. data/app/commands/thredded/notify_private_topic_users.rb +1 -0
  10. data/app/controllers/concerns/thredded/new_post_params.rb +1 -0
  11. data/app/controllers/concerns/thredded/new_private_post_params.rb +1 -0
  12. data/app/controllers/concerns/thredded/new_private_topic_params.rb +1 -0
  13. data/app/controllers/concerns/thredded/new_topic_params.rb +1 -0
  14. data/app/controllers/concerns/thredded/render_preview.rb +1 -0
  15. data/app/controllers/thredded/application_controller.rb +1 -0
  16. data/app/controllers/thredded/autocomplete_users_controller.rb +1 -0
  17. data/app/controllers/thredded/messageboards_controller.rb +4 -3
  18. data/app/controllers/thredded/moderation_controller.rb +1 -0
  19. data/app/controllers/thredded/post_permalinks_controller.rb +1 -0
  20. data/app/controllers/thredded/post_previews_controller.rb +1 -0
  21. data/app/controllers/thredded/posts_controller.rb +1 -0
  22. data/app/controllers/thredded/preferences_controller.rb +4 -3
  23. data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -0
  24. data/app/controllers/thredded/private_post_previews_controller.rb +1 -0
  25. data/app/controllers/thredded/private_posts_controller.rb +1 -0
  26. data/app/controllers/thredded/private_topic_previews_controller.rb +1 -0
  27. data/app/controllers/thredded/private_topics_controller.rb +1 -0
  28. data/app/controllers/thredded/read_states_controller.rb +1 -0
  29. data/app/controllers/thredded/theme_previews_controller.rb +1 -0
  30. data/app/controllers/thredded/topic_previews_controller.rb +1 -0
  31. data/app/controllers/thredded/topics_controller.rb +5 -4
  32. data/app/forms/thredded/edit_topic_form.rb +1 -0
  33. data/app/forms/thredded/post_form.rb +2 -0
  34. data/app/forms/thredded/private_post_form.rb +2 -0
  35. data/app/forms/thredded/private_topic_form.rb +1 -0
  36. data/app/forms/thredded/topic_form.rb +1 -0
  37. data/app/forms/thredded/user_preferences_form.rb +1 -0
  38. data/app/helpers/thredded/application_helper.rb +1 -0
  39. data/app/helpers/thredded/nav_helper.rb +7 -6
  40. data/app/helpers/thredded/render_helper.rb +1 -0
  41. data/app/helpers/thredded/urls_helper.rb +1 -0
  42. data/app/jobs/thredded/activity_updater_job.rb +1 -0
  43. data/app/jobs/thredded/auto_follow_and_notify_job.rb +1 -0
  44. data/app/jobs/thredded/notify_private_topic_users_job.rb +1 -0
  45. data/app/mailer_previews/thredded/base_mailer_preview.rb +2 -1
  46. data/app/mailer_previews/thredded/post_mailer_preview.rb +3 -2
  47. data/app/mailer_previews/thredded/private_topic_mailer_preview.rb +2 -1
  48. data/app/mailers/thredded/base_mailer.rb +1 -0
  49. data/app/mailers/thredded/post_mailer.rb +1 -0
  50. data/app/mailers/thredded/private_topic_mailer.rb +1 -0
  51. data/app/models/concerns/thredded/content_moderation_state.rb +1 -0
  52. data/app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb +1 -0
  53. data/app/models/concerns/thredded/moderation_state.rb +2 -1
  54. data/app/models/concerns/thredded/notifier_preference.rb +1 -0
  55. data/app/models/concerns/thredded/post_common.rb +1 -0
  56. data/app/models/concerns/thredded/search_parser.rb +3 -2
  57. data/app/models/concerns/thredded/topic_common.rb +2 -1
  58. data/app/models/concerns/thredded/topics_search.rb +1 -0
  59. data/app/models/concerns/thredded/user_topic_read_state_common.rb +1 -0
  60. data/app/models/thredded/category.rb +2 -1
  61. data/app/models/thredded/messageboard.rb +5 -4
  62. data/app/models/thredded/messageboard_group.rb +1 -0
  63. data/app/models/thredded/messageboard_notifications_for_followed_topics.rb +2 -1
  64. data/app/models/thredded/messageboard_user.rb +1 -0
  65. data/app/models/thredded/notifications_for_followed_topics.rb +2 -1
  66. data/app/models/thredded/notifications_for_private_topics.rb +2 -1
  67. data/app/models/thredded/null_user.rb +1 -0
  68. data/app/models/thredded/null_user_topic_read_state.rb +1 -0
  69. data/app/models/thredded/post.rb +4 -3
  70. data/app/models/thredded/post_moderation_record.rb +3 -2
  71. data/app/models/thredded/private_post.rb +3 -2
  72. data/app/models/thredded/private_topic.rb +4 -3
  73. data/app/models/thredded/private_user.rb +2 -1
  74. data/app/models/thredded/stats.rb +1 -0
  75. data/app/models/thredded/topic.rb +6 -5
  76. data/app/models/thredded/topic_category.rb +1 -0
  77. data/app/models/thredded/user_detail.rb +2 -1
  78. data/app/models/thredded/user_extender.rb +2 -1
  79. data/app/models/thredded/user_messageboard_preference.rb +2 -1
  80. data/app/models/thredded/user_permissions/admin/if_admin_column_true.rb +1 -0
  81. data/app/models/thredded/user_permissions/admin/none.rb +1 -0
  82. data/app/models/thredded/user_permissions/message/readers_of_writeable_boards.rb +1 -0
  83. data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +1 -0
  84. data/app/models/thredded/user_permissions/moderate/none.rb +1 -0
  85. data/app/models/thredded/user_permissions/read/all.rb +1 -0
  86. data/app/models/thredded/user_permissions/write/all.rb +1 -0
  87. data/app/models/thredded/user_permissions/write/none.rb +1 -0
  88. data/app/models/thredded/user_post_notification.rb +2 -1
  89. data/app/models/thredded/user_preference.rb +2 -1
  90. data/app/models/thredded/user_private_topic_read_state.rb +2 -1
  91. data/app/models/thredded/user_topic_follow.rb +3 -2
  92. data/app/models/thredded/user_topic_read_state.rb +2 -1
  93. data/app/notifiers/thredded/base_notifier.rb +1 -1
  94. data/app/notifiers/thredded/email_notifier.rb +1 -0
  95. data/app/policies/thredded/messageboard_group_policy.rb +1 -0
  96. data/app/policies/thredded/messageboard_policy.rb +1 -0
  97. data/app/policies/thredded/post_policy.rb +1 -0
  98. data/app/policies/thredded/private_post_policy.rb +1 -0
  99. data/app/policies/thredded/private_topic_policy.rb +1 -0
  100. data/app/policies/thredded/topic_policy.rb +1 -0
  101. data/app/view_hooks/thredded/all_view_hooks.rb +1 -0
  102. data/app/view_models/thredded/base_topic_view.rb +1 -0
  103. data/app/view_models/thredded/messageboard_group_view.rb +1 -0
  104. data/app/view_models/thredded/post_view.rb +1 -0
  105. data/app/view_models/thredded/posts_page_view.rb +1 -0
  106. data/app/view_models/thredded/private_topic_view.rb +1 -0
  107. data/app/view_models/thredded/private_topics_page_view.rb +1 -0
  108. data/app/view_models/thredded/topic_email_view.rb +1 -0
  109. data/app/view_models/thredded/topic_posts_page_view.rb +1 -0
  110. data/app/view_models/thredded/topic_view.rb +1 -0
  111. data/app/view_models/thredded/topics_page_view.rb +1 -0
  112. data/app/views/thredded/messageboards/index.html.erb +2 -2
  113. data/app/views/thredded/posts_common/actions/_edit.html.erb +2 -1
  114. data/app/views/thredded/private_topics/_header.html.erb +2 -1
  115. data/app/views/thredded/topics/_header.html.erb +2 -1
  116. data/app/views/thredded/topics/index.html.erb +1 -1
  117. data/bin/rails +1 -0
  118. data/bin/rubocop +1 -0
  119. data/config/routes.rb +13 -12
  120. data/db/migrate/20160329231848_create_thredded.rb +75 -66
  121. data/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb +6 -3
  122. data/db/upgrade_migrations/20160723012349_upgrade_v0_6_to_v0_7.rb +4 -1
  123. data/db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb +4 -1
  124. data/db/upgrade_migrations/20161113161801_upgrade_v0_8_to_v0_9.rb +11 -8
  125. data/db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb +12 -6
  126. data/db/upgrade_migrations/20170312131417_upgrade_thredded_v0_10_to_v0_11.rb +6 -3
  127. data/db/upgrade_migrations/20170420163138_upgrade_thredded_v0_11_to_v0_12.rb +4 -1
  128. data/lib/generators/thredded/install/install_generator.rb +1 -0
  129. data/lib/generators/thredded/install/templates/initializer.rb +1 -0
  130. data/lib/tasks/thredded_tasks.rake +1 -0
  131. data/lib/thredded.rb +7 -0
  132. data/lib/thredded/base_migration.rb +14 -0
  133. data/lib/thredded/collection_to_strings_with_cache_renderer.rb +1 -0
  134. data/lib/thredded/content_formatter.rb +7 -6
  135. data/lib/thredded/database_seeder.rb +1 -0
  136. data/lib/thredded/db_tools.rb +9 -8
  137. data/lib/thredded/email_transformer.rb +1 -0
  138. data/lib/thredded/email_transformer/onebox.rb +1 -0
  139. data/lib/thredded/engine.rb +3 -2
  140. data/lib/thredded/errors.rb +1 -0
  141. data/lib/thredded/formatting_demo_content.rb +1 -0
  142. data/lib/thredded/html_pipeline/at_mention_filter.rb +3 -2
  143. data/lib/thredded/html_pipeline/autolink_filter.rb +1 -0
  144. data/lib/thredded/html_pipeline/kramdown_filter.rb +2 -1
  145. data/lib/thredded/html_pipeline/onebox_filter.rb +2 -1
  146. data/lib/thredded/html_pipeline/wrap_iframes_filter.rb +1 -0
  147. data/lib/thredded/version.rb +2 -1
  148. data/lib/thredded/view_hooks/config.rb +1 -0
  149. data/lib/thredded/view_hooks/renderer.rb +1 -0
  150. metadata +5 -7
  151. data/db/upgrade_migrations/20160410111522_upgrade_v0_2_to_v0_3.rb +0 -63
  152. data/db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb +0 -13
  153. data/db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb +0 -56
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Admin
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Admin
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Message
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Moderate
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Moderate
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Read
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Write
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserPermissions
4
5
  module Write
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # Delivery records for Thredded::Post notifications.
4
5
  class UserPostNotification < ActiveRecord::Base
5
- belongs_to :user, class_name: Thredded.user_class, inverse_of: :thredded_post_notifications
6
+ belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_post_notifications
6
7
  belongs_to :post, class_name: 'Thredded::Post', inverse_of: :user_notifications
7
8
 
8
9
  # @param post [Thredded::Post]
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class UserPreference < ActiveRecord::Base
4
- belongs_to :user, class_name: Thredded.user_class, inverse_of: :thredded_user_preference
5
+ belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_user_preference
5
6
 
6
7
  with_options(inverse_of: :user_preference, primary_key: :user_id, foreign_key: :user_id,
7
8
  dependent: :destroy) do |opt|
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class UserPrivateTopicReadState < ActiveRecord::Base
4
5
  include Thredded::UserTopicReadStateCommon
5
6
  belongs_to :user,
6
- class_name: Thredded.user_class,
7
+ class_name: Thredded.user_class_name,
7
8
  inverse_of: :thredded_private_topic_read_states
8
9
  belongs_to :postable,
9
10
  class_name: 'Thredded::PrivateTopic',
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class UserTopicFollow < ActiveRecord::Base
4
- enum reason: [:manual, :posted, :mentioned, :auto]
5
+ enum reason: %i[manual posted mentioned auto]
5
6
 
6
- belongs_to :user, inverse_of: :thredded_topic_follows, class_name: Thredded.user_class
7
+ belongs_to :user, inverse_of: :thredded_topic_follows, class_name: Thredded.user_class_name
7
8
  belongs_to :topic, inverse_of: :user_follows
8
9
 
9
10
  validates :user_id, presence: true
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class UserTopicReadState < ActiveRecord::Base
4
5
  include Thredded::UserTopicReadStateCommon
5
6
  belongs_to :user,
6
- class_name: Thredded.user_class,
7
+ class_name: Thredded.user_class_name,
7
8
  inverse_of: :thredded_topic_read_states
8
9
  belongs_to :postable,
9
10
  class_name: 'Thredded::Topic',
@@ -6,7 +6,7 @@ module Thredded
6
6
  unless notifier.respond_to?(:key) && /^[a-z_]+$/.match(notifier.key)
7
7
  fail "Notifier problem: #{notifier.class.name} must respond to #key with a snake_case string"
8
8
  end
9
- [:human_name, :new_post, :new_private_post].each do |m|
9
+ %i[human_name new_post new_private_post].each do |m|
10
10
  unless notifier.respond_to?(m)
11
11
  fail "#{notifier.class.name} must respond to ##{m}"
12
12
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class EmailNotifier
4
5
  def human_name
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class MessageboardGroupPolicy
4
5
  # @param user [Thredded.user_class]
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class MessageboardPolicy
4
5
  # The scope of readable messageboards
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PostPolicy
4
5
  # The scope of readable posts.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PrivatePostPolicy
4
5
  # @param user [Thredded.user_class]
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PrivateTopicPolicy
4
5
  # @param user [Thredded.user_class]
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class TopicPolicy
4
5
  # The scope of readable topics.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class AllViewHooks
4
5
  # @return [PostCommon]
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for TopicCommon.
4
5
  class BaseTopicView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for a page of MessageboardGroupViews.
4
5
  class MessageboardGroupView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for PostCommon.
4
5
  class PostView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for a page of PostViews.
4
5
  class PostsPageView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for PrivateTopic.
4
5
  class PrivateTopicView < Thredded::BaseTopicView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for a page of BaseTopicViews.
4
5
  class PrivateTopicsPageView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class TopicEmailView
4
5
  # @param [Thredded::TopicCommon] topic
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for a page of PostViews of a Topic.
4
5
  class TopicPostsPageView < Thredded::PostsPageView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for Topic.
4
5
  class TopicView < Thredded::BaseTopicView
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # A view model for a page of BaseTopicViews.
4
5
  class TopicsPageView
@@ -19,12 +19,12 @@
19
19
 
20
20
  <div class="thredded--messageboards--actions">
21
21
  <% if policy(Thredded::Messageboard.new).create? %>
22
- <a class="thredded--button" href="<%= new_messageboard_path %>">
22
+ <a class="thredded--button" href="<%= new_messageboard_path %>" rel="nofollow">
23
23
  <%= t('thredded.messageboard.create') %>
24
24
  </a>
25
25
  <% end %>
26
26
  <% if policy(Thredded::MessageboardGroup.new).create? %>
27
- <a class="thredded--button" href="<%= new_messageboard_group_path %>">
27
+ <a class="thredded--button" href="<%= new_messageboard_group_path %>" rel="nofollow">
28
28
  <%= t('thredded.messageboard_group.create') %>
29
29
  </a>
30
30
  <% end %>
@@ -1,2 +1,3 @@
1
1
  <%= link_to t('thredded.posts.edit'), post.edit_path,
2
- class: 'thredded--post--edit thredded--post--dropdown--actions--item' %>
2
+ class: 'thredded--post--edit thredded--post--dropdown--actions--item',
3
+ rel: 'nofollow' %>
@@ -11,6 +11,7 @@
11
11
  </span>
12
12
  <% if topic.can_update? %>
13
13
  <%= link_to t('thredded.private_topics.edit'), topic.edit_path,
14
- class: 'thredded--topic-header--edit-topic' %>
14
+ class: 'thredded--topic-header--edit-topic',
15
+ rel: 'nofollow' %>
15
16
  <% end %>
16
17
  </header>
@@ -7,7 +7,8 @@
7
7
  </cite>
8
8
  <% if topic.can_update? %>
9
9
  <%= link_to t('thredded.topics.edit'), topic.edit_path,
10
- class: 'thredded--topic-header--edit-topic' %>
10
+ class: 'thredded--topic-header--edit-topic',
11
+ rel: 'nofollow' %>
11
12
  <% end %>
12
13
  <% if thredded_current_user %>
13
14
  <% if topic.followed? %>
@@ -22,7 +22,7 @@
22
22
 
23
23
  <div class="thredded--messageboards--actions">
24
24
  <% if policy(messageboard).update? %>
25
- <a class="thredded--button" href="<%= edit_messageboard_path(messageboard) %>">
25
+ <a class="thredded--button" href="<%= edit_messageboard_path(messageboard) %>" rel="nofollow">
26
26
  <%= t('thredded.nav.edit_messageboard') %>
27
27
  </a>
28
28
  <% end %>
data/bin/rails CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  APP_PATH = File.expand_path('../../spec/dummy/config/application', __FILE__)
4
5
  require File.expand_path('../../spec/dummy/config/boot', __FILE__)
5
6
  require 'rails/commands'
data/bin/rubocop CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  #
4
5
  # This file was generated by Bundler.
5
6
  #
data/config/routes.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
3
- resource :theme_preview, only: [:show], path: 'theme-preview' if %w(development test).include? Rails.env
4
+ resource :theme_preview, only: [:show], path: 'theme-preview' if %w[development test].include? Rails.env
4
5
 
5
6
  page_constraint = { page: /[1-9]\d*/ }
6
7
 
@@ -9,11 +10,11 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
9
10
  resource :private_topic, only: [:new], path: '' do
10
11
  post :preview, on: :new, controller: 'private_topic_previews'
11
12
  end
12
- resources :private_topics, except: [:new, :show], path: '' do
13
+ resources :private_topics, except: %i[new show], path: '' do
13
14
  member do
14
15
  get '(page-:page)', action: :show, as: '', constraints: page_constraint
15
16
  end
16
- resources :private_posts, path: '', except: [:index, :show] do
17
+ resources :private_posts, path: '', except: %i[index show] do
17
18
  post :preview, on: :new, controller: 'private_post_previews'
18
19
  resource :preview, only: [:update], controller: 'private_post_previews'
19
20
  member do
@@ -37,7 +38,7 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
37
38
  end
38
39
 
39
40
  scope path: 'admin' do
40
- resources :messageboard_groups, only: [:new, :create]
41
+ resources :messageboard_groups, only: %i[new create]
41
42
  scope controller: :moderation, path: 'moderation' do
42
43
  scope constraints: page_constraint do
43
44
  get '(/page-:page)', action: :pending, as: :pending_moderation
@@ -51,15 +52,15 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
51
52
  end
52
53
  end
53
54
 
54
- resource :preferences, only: [:edit, :update], as: :global_preferences
55
+ resource :preferences, only: %i[edit update], as: :global_preferences
55
56
  resource :messageboard, path: 'messageboards', only: [:new]
56
- resources :messageboards, only: [:edit, :update]
57
- resources :messageboards, only: [:index, :create], path: '' do
58
- resource :preferences, only: [:edit, :update]
57
+ resources :messageboards, only: %i[edit update]
58
+ resources :messageboards, only: %i[index create], path: '' do
59
+ resource :preferences, only: %i[edit update]
59
60
  resource :topic, path: 'topics', only: [:new] do
60
61
  post :preview, on: :new, controller: 'topic_previews'
61
62
  end
62
- resources :topics, path: '', except: [:index, :new, :show] do
63
+ resources :topics, path: '', except: %i[index new show] do
63
64
  collection do
64
65
  get '(page-:page)', action: :index, as: '', constraints: page_constraint
65
66
  get '/category/:category_id', action: :category, as: :categories
@@ -68,10 +69,10 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
68
69
  get '(page-:page)', action: :show, as: '', constraints: page_constraint
69
70
 
70
71
  # match (un)follow via get as well so that redirecting back to it after sign in works.
71
- match 'follow', via: [:post, :get]
72
- match 'unfollow', via: [:post, :get]
72
+ match 'follow', via: %i[post get]
73
+ match 'unfollow', via: %i[post get]
73
74
  end
74
- resources :posts, except: [:index, :show], path: '' do
75
+ resources :posts, except: %i[index show], path: '' do
75
76
  post :preview, on: :new, controller: 'post_previews'
76
77
  resource :preview, only: [:update], controller: 'post_previews'
77
78
  member do
@@ -1,32 +1,35 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require 'thredded/base_migration'
4
+
2
5
  # rubocop:disable Metrics/ClassLength
3
6
  # rubocop:disable Metrics/MethodLength
4
- class CreateThredded < ActiveRecord::Migration
7
+ class CreateThredded < Thredded::BaseMigration
5
8
  def change
6
9
  unless table_exists?(:friendly_id_slugs)
7
10
  # The user might have installed FriendlyId separately already.
8
11
  create_table :friendly_id_slugs do |t|
9
- t.string :slug, limit: 191, null: false
12
+ t.string :slug, null: false
10
13
  t.integer :sluggable_id, null: false
11
14
  t.string :sluggable_type, limit: 50
12
- t.string :scope, limit: 191
13
- t.datetime :created_at, null: false
14
- t.index [:slug, :sluggable_type, :scope],
15
- name: :index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope,
16
- unique: true
17
- t.index [:slug, :sluggable_type], name: :index_friendly_id_slugs_on_slug_and_sluggable_type
18
- t.index [:sluggable_id], name: :index_friendly_id_slugs_on_sluggable_id
19
- t.index [:sluggable_type], name: :index_friendly_id_slugs_on_sluggable_type
15
+ t.string :scope
16
+ t.datetime :created_at
20
17
  end
18
+ add_index :friendly_id_slugs, :sluggable_id
19
+ add_index :friendly_id_slugs, %i[slug sluggable_type], length: { slug: 140, sluggable_type: 50 }
20
+ add_index :friendly_id_slugs, %i[slug sluggable_type scope],
21
+ length: { slug: 70, sluggable_type: 50, scope: 70 },
22
+ unique: true
23
+ add_index :friendly_id_slugs, :sluggable_type
21
24
  end
22
25
 
23
26
  create_table :thredded_categories do |t|
24
- t.references :messageboard, null: false
27
+ t.references :messageboard, null: false, index: false
25
28
  t.string :name, limit: 191, null: false
26
29
  t.string :description, limit: 255
27
30
  t.timestamps null: false
28
31
  t.string :slug, limit: 191, null: false
29
- t.index [:messageboard_id, :slug], name: :index_thredded_categories_on_messageboard_id_and_slug, unique: true
32
+ t.index %i[messageboard_id slug], name: :index_thredded_categories_on_messageboard_id_and_slug, unique: true
30
33
  t.index [:messageboard_id], name: :index_thredded_categories_on_messageboard_id
31
34
  end
32
35
  DbTextSearch::CaseInsensitive.add_index connection, :thredded_categories, :name, name: :thredded_categories_name_ci
@@ -38,23 +41,23 @@ class CreateThredded < ActiveRecord::Migration
38
41
  t.integer :topics_count, default: 0
39
42
  t.integer :posts_count, default: 0
40
43
  t.integer :position, null: false
41
- t.references :last_topic
42
- t.references :messageboard_group
44
+ t.references :last_topic, index: false
45
+ t.references :messageboard_group, index: false
43
46
  t.timestamps null: false
44
47
  t.index [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
45
48
  t.index [:slug], name: :index_thredded_messageboards_on_slug
46
49
  end
47
50
 
48
51
  create_table :thredded_posts do |t|
49
- t.integer :user_id, limit: 4
52
+ t.references :user, type: user_id_type, index: false
50
53
  t.text :content, limit: 65_535
51
54
  t.string :ip, limit: 255
52
55
  t.string :source, limit: 255, default: 'web'
53
- t.references :postable, null: false
54
- t.references :messageboard, null: false
56
+ t.references :postable, null: false, index: false
57
+ t.references :messageboard, null: false, index: false
55
58
  t.integer :moderation_state, null: false
56
59
  t.timestamps null: false
57
- t.index [:moderation_state, :updated_at],
60
+ t.index %i[moderation_state updated_at],
58
61
  order: { updated_at: :asc },
59
62
  name: :index_thredded_posts_for_display
60
63
  t.index [:messageboard_id], name: :index_thredded_posts_on_messageboard_id
@@ -65,16 +68,16 @@ class CreateThredded < ActiveRecord::Migration
65
68
  DbTextSearch::FullText.add_index connection, :thredded_posts, :content, name: :thredded_posts_content_fts
66
69
 
67
70
  create_table :thredded_private_posts do |t|
68
- t.references :user
71
+ t.references :user, type: user_id_type, index: false
69
72
  t.text :content, limit: 65_535
70
- t.references :postable, null: false
73
+ t.references :postable, null: false, index: false
71
74
  t.string :ip, limit: 255
72
75
  t.timestamps null: false
73
76
  end
74
77
 
75
78
  create_table :thredded_private_topics do |t|
76
- t.references :user
77
- t.references :last_user
79
+ t.references :user, type: user_id_type, index: false
80
+ t.references :last_user, index: false
78
81
  t.string :title, limit: 255, null: false
79
82
  t.string :slug, limit: 191, null: false
80
83
  t.integer :posts_count, default: 0
@@ -86,26 +89,26 @@ class CreateThredded < ActiveRecord::Migration
86
89
  end
87
90
 
88
91
  create_table :thredded_private_users do |t|
89
- t.references :private_topic, limit: 4
90
- t.references :user, limit: 4
92
+ t.references :private_topic, index: false
93
+ t.references :user, type: user_id_type, index: false
91
94
  t.timestamps null: false
92
95
  t.index [:private_topic_id], name: :index_thredded_private_users_on_private_topic_id
93
96
  t.index [:user_id], name: :index_thredded_private_users_on_user_id
94
97
  end
95
98
 
96
99
  create_table :thredded_topic_categories do |t|
97
- t.references :topic, null: false
98
- t.references :category, null: false
100
+ t.references :topic, null: false, index: false
101
+ t.references :category, null: false, index: false
99
102
  t.index [:category_id], name: :index_thredded_topic_categories_on_category_id
100
103
  t.index [:topic_id], name: :index_thredded_topic_categories_on_topic_id
101
104
  end
102
105
 
103
106
  create_table :thredded_topics do |t|
104
- t.references :user
105
- t.references :last_user
107
+ t.references :user, type: user_id_type, index: false
108
+ t.references :last_user, index: false
106
109
  t.string :title, limit: 255, null: false
107
110
  t.string :slug, limit: 191, null: false
108
- t.references :messageboard, null: false
111
+ t.references :messageboard, null: false, index: false
109
112
  t.integer :posts_count, default: 0, null: false
110
113
  t.boolean :sticky, default: false, null: false
111
114
  t.boolean :locked, default: false, null: false
@@ -114,7 +117,7 @@ class CreateThredded < ActiveRecord::Migration
114
117
  t.integer :moderation_state, null: false
115
118
  t.datetime :last_post_at
116
119
  t.timestamps null: false
117
- t.index %i(moderation_state sticky updated_at),
120
+ t.index %i[moderation_state sticky updated_at],
118
121
  order: { sticky: :desc, updated_at: :desc },
119
122
  name: :index_thredded_topics_for_display
120
123
  t.index [:hash_id], name: :index_thredded_topics_on_hash_id
@@ -125,7 +128,7 @@ class CreateThredded < ActiveRecord::Migration
125
128
  DbTextSearch::FullText.add_index connection, :thredded_topics, :title, name: :thredded_topics_title_fts
126
129
 
127
130
  create_table :thredded_user_details do |t|
128
- t.references :user, null: false
131
+ t.references :user, type: user_id_type, null: false, index: false
129
132
  t.datetime :latest_activity_at
130
133
  t.integer :posts_count, default: 0
131
134
  t.integer :topics_count, default: 0
@@ -133,25 +136,29 @@ class CreateThredded < ActiveRecord::Migration
133
136
  t.integer :moderation_state, null: false, default: 0 # pending_moderation
134
137
  t.timestamp :moderation_state_changed_at
135
138
  t.timestamps null: false
136
- t.index %i(moderation_state moderation_state_changed_at),
139
+ t.index %i[moderation_state moderation_state_changed_at],
137
140
  order: { moderation_state_changed_at: :desc },
138
141
  name: :index_thredded_user_details_for_moderations
139
- t.index %i(latest_activity_at), name: :index_thredded_user_details_on_latest_activity_at
140
- t.index %i(user_id), name: :index_thredded_user_details_on_user_id
142
+ t.index %i[latest_activity_at], name: :index_thredded_user_details_on_latest_activity_at
143
+ t.index %i[user_id], name: :index_thredded_user_details_on_user_id
141
144
  end
142
145
 
143
146
  create_table :thredded_messageboard_users do |t|
144
- t.references :thredded_user_detail, foreign_key: { on_delete: :cascade }, null: false
145
- t.references :thredded_messageboard, foreign_key: { on_delete: :cascade }, null: false
147
+ t.references :thredded_user_detail, null: false, index: false
148
+ t.references :thredded_messageboard, null: false, index: false
146
149
  t.datetime :last_seen_at, null: false
147
- t.index [:thredded_messageboard_id, :thredded_user_detail_id],
150
+ t.index %i[thredded_messageboard_id thredded_user_detail_id],
148
151
  name: :index_thredded_messageboard_users_primary
149
- t.index [:thredded_messageboard_id, :last_seen_at],
152
+ t.index %i[thredded_messageboard_id last_seen_at],
150
153
  name: :index_thredded_messageboard_users_for_recently_active
151
154
  end
155
+ add_foreign_key :thredded_messageboard_users, :thredded_user_details,
156
+ column: :thredded_user_detail_id, on_delete: :cascade
157
+ add_foreign_key :thredded_messageboard_users, :thredded_messageboards,
158
+ column: :thredded_messageboard_id, on_delete: :cascade
152
159
 
153
160
  create_table :thredded_user_preferences do |t|
154
- t.references :user, null: false
161
+ t.references :user, type: user_id_type, null: false, index: false
155
162
  t.boolean :follow_topics_on_mention, default: true, null: false
156
163
  t.boolean :auto_follow_topics, default: false, null: false
157
164
  t.timestamps null: false
@@ -159,24 +166,24 @@ class CreateThredded < ActiveRecord::Migration
159
166
  end
160
167
 
161
168
  create_table :thredded_user_messageboard_preferences do |t|
162
- t.references :user, null: false
163
- t.references :messageboard, null: false
169
+ t.references :user, type: user_id_type, null: false, index: false
170
+ t.references :messageboard, null: false, index: false
164
171
  t.boolean :follow_topics_on_mention, default: true, null: false
165
172
  t.boolean :auto_follow_topics, default: false, null: false
166
173
  t.timestamps null: false
167
- t.index [:user_id, :messageboard_id],
174
+ t.index %i[user_id messageboard_id],
168
175
  name: :thredded_user_messageboard_preferences_user_id_messageboard_id,
169
176
  unique: true
170
177
  end
171
178
 
172
- %i(topic private_topic).each do |topics_table|
179
+ %i[topic private_topic].each do |topics_table|
173
180
  table_name = :"thredded_user_#{topics_table}_read_states"
174
181
  create_table table_name do |t|
175
- t.references :user, null: false
176
- t.integer :postable_id, null: false
182
+ t.references :user, type: user_id_type, null: false, index: false
183
+ t.references :postable, null: false, index: false
177
184
  t.integer :page, default: 1, null: false
178
185
  t.timestamp :read_at, null: false
179
- t.index [:user_id, :postable_id], name: :"#{table_name}_user_postable", unique: true
186
+ t.index %i[user_id postable_id], name: :"#{table_name}_user_postable", unique: true
180
187
  end
181
188
  end
182
189
 
@@ -187,60 +194,62 @@ class CreateThredded < ActiveRecord::Migration
187
194
  end
188
195
 
189
196
  create_table :thredded_user_topic_follows do |t|
190
- t.references :user, null: false
191
- t.integer :topic_id, null: false
197
+ t.references :user, type: user_id_type, null: false, index: false
198
+ t.references :topic, null: false, index: false
192
199
  t.datetime :created_at, null: false
193
200
  t.integer :reason, limit: 1
194
- t.index [:user_id, :topic_id], name: :thredded_user_topic_follows_user_topic, unique: true
201
+ t.index %i[user_id topic_id], name: :thredded_user_topic_follows_user_topic, unique: true
195
202
  end
196
203
 
197
204
  create_table :thredded_post_moderation_records do |t|
198
- t.references :post
199
- t.references :messageboard
205
+ t.references :post, index: false
206
+ t.references :messageboard, index: false
200
207
  t.text :post_content, limit: 65_535
201
- t.references :post_user
208
+ t.references :post_user, index: false
202
209
  t.text :post_user_name
203
- t.references :moderator
210
+ t.references :moderator, index: false
204
211
  t.integer :moderation_state, null: false
205
212
  t.integer :previous_moderation_state, null: false
206
213
  t.timestamp :created_at, null: false
207
- t.index [:messageboard_id, :created_at],
214
+ t.index %i[messageboard_id created_at],
208
215
  order: { created_at: :desc },
209
216
  name: :index_thredded_moderation_records_for_display
210
217
  end
211
218
 
212
219
  create_table :thredded_notifications_for_private_topics do |t|
213
- t.integer :user_id, null: false
220
+ t.references :user, null: false, index: false, type: user_id_type
214
221
  t.string :notifier_key, null: false, limit: 90
215
222
  t.boolean :enabled, default: true, null: false
216
- t.index [:user_id, :notifier_key],
223
+ t.index %i[user_id notifier_key],
217
224
  name: 'thredded_notifications_for_private_topics_unique', unique: true
218
225
  end
219
226
  create_table :thredded_notifications_for_followed_topics do |t|
220
- t.integer :user_id, null: false
227
+ t.references :user, null: false, index: false, type: user_id_type
221
228
  t.string :notifier_key, null: false, limit: 90
222
229
  t.boolean :enabled, default: true, null: false
223
- t.index [:user_id, :notifier_key],
230
+ t.index %i[user_id notifier_key],
224
231
  name: 'thredded_notifications_for_followed_topics_unique', unique: true
225
232
  end
226
233
  create_table :thredded_messageboard_notifications_for_followed_topics do |t|
227
- t.integer :user_id, null: false
228
- t.integer :messageboard_id, null: false
234
+ t.references :user, null: false, index: false, type: user_id_type
235
+ t.references :messageboard, null: false, index: false
229
236
  t.string :notifier_key, null: false, limit: 90
230
237
  t.boolean :enabled, default: true, null: false
231
- t.index [:user_id, :messageboard_id, :notifier_key],
238
+ t.index %i[user_id messageboard_id notifier_key],
232
239
  name: 'thredded_messageboard_notifications_for_followed_topics_unique', unique: true
233
240
  end
234
241
 
235
242
  create_table :thredded_user_post_notifications do |t|
236
- t.references :user, null: false
237
- t.foreign_key Thredded.user_class.table_name, column: :user_id, on_delete: :cascade
238
- t.references :post, null: false
239
- t.foreign_key :thredded_posts, column: :post_id, on_delete: :cascade
243
+ t.references :user, null: false, index: false, type: user_id_type
244
+ t.references :post, null: false, index: false
240
245
  t.datetime :notified_at, null: false
241
246
  t.index :post_id, name: :index_thredded_user_post_notifications_on_post_id
242
- t.index [:user_id, :post_id], name: :index_thredded_user_post_notifications_on_user_id_and_post_id, unique: true
247
+ t.index %i[user_id post_id], name: :index_thredded_user_post_notifications_on_user_id_and_post_id, unique: true
243
248
  end
249
+ add_foreign_key :thredded_user_post_notifications,
250
+ Thredded.user_class.table_name, column: :user_id, on_delete: :cascade
251
+ add_foreign_key :thredded_user_post_notifications,
252
+ :thredded_posts, column: :post_id, on_delete: :cascade
244
253
  end
245
254
  end
246
255
  # rubocop:enable Metrics/MethodLength