thredded 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.mkdn +26 -0
  3. data/README.mkdn +52 -7
  4. data/app/assets/images/thredded/moderation.svg +4 -0
  5. data/app/assets/images/thredded/private-messages.svg +1 -1
  6. data/app/assets/images/thredded/settings.svg +1 -1
  7. data/app/assets/stylesheets/thredded/_base.scss +1 -1
  8. data/app/assets/stylesheets/thredded/_thredded.scss +1 -0
  9. data/app/assets/stylesheets/thredded/base/_buttons.scss +16 -0
  10. data/app/assets/stylesheets/thredded/base/_grid.scss +12 -0
  11. data/app/assets/stylesheets/thredded/components/_base.scss +4 -0
  12. data/app/assets/stylesheets/thredded/components/_messageboard.scss +1 -13
  13. data/app/assets/stylesheets/thredded/components/_topic-header.scss +27 -0
  14. data/app/assets/stylesheets/thredded/layout/_main-navigation.scss +1 -1
  15. data/app/assets/stylesheets/thredded/layout/_moderation.scss +45 -0
  16. data/app/assets/stylesheets/thredded/layout/_navigation.scss +20 -6
  17. data/app/assets/stylesheets/thredded/layout/_search-navigation.scss +2 -2
  18. data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +5 -3
  19. data/app/commands/thredded/autofollow_mentioned_users.rb +32 -0
  20. data/app/commands/thredded/moderate_post.rb +35 -0
  21. data/app/commands/thredded/notify_following_users.rb +18 -0
  22. data/app/commands/thredded/notify_private_topic_users.rb +4 -4
  23. data/app/controllers/thredded/application_controller.rb +6 -25
  24. data/app/controllers/thredded/messageboards_controller.rb +5 -3
  25. data/app/controllers/thredded/moderation_controller.rb +56 -0
  26. data/app/controllers/thredded/post_permalinks_controller.rb +1 -1
  27. data/app/controllers/thredded/posts_controller.rb +4 -2
  28. data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -1
  29. data/app/controllers/thredded/private_topics_controller.rb +2 -3
  30. data/app/controllers/thredded/theme_previews_controller.rb +3 -3
  31. data/app/controllers/thredded/topics_controller.rb +32 -11
  32. data/app/forms/thredded/topic_form.rb +1 -0
  33. data/app/helpers/thredded/application_helper.rb +26 -1
  34. data/app/helpers/thredded/urls_helper.rb +7 -5
  35. data/app/jobs/thredded/auto_follow_and_notify_job.rb +13 -0
  36. data/app/jobs/thredded/notify_private_topic_users_job.rb +3 -4
  37. data/app/mailer_previews/thredded/post_mailer_preview.rb +2 -2
  38. data/app/mailers/thredded/post_mailer.rb +2 -2
  39. data/app/models/concerns/thredded/content_moderation_state.rb +53 -0
  40. data/app/models/concerns/thredded/moderation_state.rb +13 -0
  41. data/app/models/concerns/thredded/post_common.rb +6 -71
  42. data/app/models/concerns/thredded/topic_common.rb +26 -11
  43. data/app/models/concerns/thredded/user_topic_read_state_common.rb +4 -0
  44. data/app/models/thredded/messageboard.rb +2 -0
  45. data/app/models/thredded/post.rb +24 -0
  46. data/app/models/thredded/post_moderation_record.rb +45 -0
  47. data/app/models/thredded/private_post.rb +15 -0
  48. data/app/models/thredded/private_topic.rb +8 -0
  49. data/app/models/thredded/topic.rb +39 -0
  50. data/app/models/thredded/user_detail.rb +11 -0
  51. data/app/models/thredded/user_extender.rb +14 -0
  52. data/app/models/thredded/user_topic_follow.rb +20 -0
  53. data/app/policies/thredded/messageboard_policy.rb +15 -0
  54. data/app/policies/thredded/post_policy.rb +17 -1
  55. data/app/policies/thredded/private_post_policy.rb +1 -1
  56. data/app/policies/thredded/private_topic_policy.rb +1 -1
  57. data/app/policies/thredded/topic_policy.rb +18 -1
  58. data/app/view_models/thredded/base_topic_view.rb +0 -13
  59. data/app/view_models/thredded/post_view.rb +8 -1
  60. data/app/view_models/thredded/posts_page_view.rb +6 -8
  61. data/app/view_models/thredded/private_topic_view.rb +8 -0
  62. data/app/view_models/thredded/private_topics_page_view.rb +24 -0
  63. data/app/view_models/thredded/topic_posts_page_view.rb +17 -0
  64. data/app/view_models/thredded/topic_view.rb +27 -1
  65. data/app/view_models/thredded/topics_page_view.rb +2 -4
  66. data/app/views/thredded/moderation/_post.html.erb +7 -0
  67. data/app/views/thredded/moderation/_post_moderation_actions.html.erb +12 -0
  68. data/app/views/thredded/moderation/_post_moderation_record.html.erb +43 -0
  69. data/app/views/thredded/moderation/history.html.erb +19 -0
  70. data/app/views/thredded/moderation/pending.html.erb +29 -0
  71. data/app/views/thredded/post_mailer/{at_notification.html.erb → post_notification.html.erb} +1 -1
  72. data/app/views/thredded/post_mailer/{at_notification.text.erb → post_notification.text.erb} +1 -1
  73. data/app/views/thredded/posts/_post.html.erb +8 -1
  74. data/app/views/thredded/posts_common/_actions.html.erb +11 -0
  75. data/app/views/thredded/posts_common/_content.html.erb +5 -0
  76. data/app/views/thredded/posts_common/_header.html.erb +5 -0
  77. data/app/views/thredded/private_posts/_private_post.html.erb +5 -1
  78. data/app/views/thredded/shared/_nav.html.erb +1 -0
  79. data/app/views/thredded/shared/_page.html.erb +1 -1
  80. data/app/views/thredded/shared/nav/_moderation.html.erb +13 -0
  81. data/app/views/thredded/shared/nav/_private_topics.html.erb +1 -2
  82. data/app/views/thredded/topics/_header.html.erb +15 -0
  83. data/app/views/thredded/topics/index.html.erb +2 -2
  84. data/app/views/thredded/topics/new.html.erb +1 -1
  85. data/config/locales/en.yml +26 -5
  86. data/config/locales/pt-BR.yml +23 -0
  87. data/config/routes.rb +7 -0
  88. data/db/migrate/20160329231848_create_thredded.rb +40 -5
  89. data/db/seeds.rb +5 -5
  90. data/db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb +1 -2
  91. data/db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb +56 -0
  92. data/heroku.gemfile.lock +20 -18
  93. data/lib/generators/thredded/install/templates/initializer.rb +15 -0
  94. data/lib/html/pipeline/at_mention_filter.rb +5 -2
  95. data/lib/thredded.rb +4 -0
  96. data/lib/thredded/at_users.rb +3 -2
  97. data/lib/thredded/content_formatter.rb +81 -0
  98. data/lib/thredded/version.rb +1 -1
  99. metadata +28 -10
  100. data/app/commands/thredded/notify_mentioned_users.rb +0 -55
  101. data/app/jobs/thredded/at_notifier_job.rb +0 -12
  102. data/app/mailer_previews/thredded/private_post_mailer_preview.rb +0 -12
  103. data/app/mailers/thredded/private_post_mailer.rb +0 -17
  104. data/app/views/thredded/posts_common/_post.html.erb +0 -26
  105. data/app/views/thredded/private_post_mailer/at_notification.html.erb +0 -13
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  require_dependency 'thredded/topic_view'
3
- require_dependency 'thredded/private_topic_view'
4
3
  module Thredded
5
4
  # A view model for a page of BaseTopicViews.
6
5
  class TopicsPageView
@@ -17,9 +16,8 @@ module Thredded
17
16
  # @param topics_page_scope [ActiveRecord::Relation<Thredded::Topic>]
18
17
  def initialize(user, topics_page_scope)
19
18
  @topics_page_scope = topics_page_scope
20
- topic_view_class = "#{topics_page_scope.klass}View".constantize
21
- @topic_views = @topics_page_scope.with_read_states(user).map do |(topic, read_state)|
22
- topic_view_class.new(topic, read_state, Pundit.policy!(user, topic))
19
+ @topic_views = @topics_page_scope.with_read_and_follow_states(user).map do |(topic, read_state, follow)|
20
+ TopicView.new(topic, read_state, follow, Pundit.policy!(user, topic))
23
21
  end
24
22
  end
25
23
  end
@@ -0,0 +1,7 @@
1
+ <%# @param post [Thredded::PostView] %>
2
+ <%= content_tag :article, id: dom_id(post), class: 'thredded--post' do %>
3
+ <%= render 'thredded/posts_common/header', post: post %>
4
+ <%= render 'thredded/posts_common/content', post: post %>
5
+ <%= render 'thredded/posts_common/actions', post: post %>
6
+ <%= render 'post_moderation_actions', post: post %>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <div class="thredded--post-moderation-actions">
2
+ <% unless post.approved? %>
3
+ <%= button_to t('thredded.moderation.approve_btn'), moderate_post_path,
4
+ class: 'thredded--button',
5
+ params: { id: post.to_model.id, moderation_state: 'approved' } %>
6
+ <% end %>
7
+ <% unless post.blocked? %>
8
+ <%= button_to t('thredded.moderation.block_btn'), moderate_post_path,
9
+ class: 'thredded--button',
10
+ params: { id: post.to_model.id, moderation_state: 'blocked' } %>
11
+ <% end %>
12
+ </div>
@@ -0,0 +1,43 @@
1
+ <%
2
+ post = post_moderation_record.post
3
+ moderation_state_notice_args = {
4
+ moderator: user_link(post_moderation_record.moderator),
5
+ time_ago: time_ago(post_moderation_record.created_at)
6
+ }
7
+ %>
8
+ <article class="thredded--post-moderation-record thredded--post-moderation-record-<%= post_moderation_record.moderation_state %>">
9
+ <header class="thredded--post-moderation-record--header">
10
+ <p class="thredded--post-moderation-record--moderation-state-notice">
11
+ <% if post_moderation_record.approved? %>
12
+ <%= t('thredded.moderation.post_approved_html', moderation_state_notice_args) %>
13
+ <% elsif post_moderation_record.blocked? %>
14
+ <%= t('thredded.moderation.post_blocked_html', moderation_state_notice_args) %>
15
+ <% end %>
16
+ </p>
17
+ <% if post && post.content != post_moderation_record.post_content %>
18
+ <p class="thredded--post-moderation-record--content-changed-notice">
19
+ <%= t('thredded.moderation.posts_content_changed_since_moderation_html', post_url: post_permalink_path(post)) %>
20
+ </p>
21
+ <% end %>
22
+ <%= t 'thredded.moderation.post_deleted_notice' unless post %>
23
+ </header>
24
+ <article class="thredded--post">
25
+ <header>
26
+ <% if post_moderation_record.post_user %>
27
+ <%= image_tag Thredded.avatar_url.call(post_moderation_record.post_user), class: 'thredded--post--avatar' %>
28
+ <h2 class="thredded--post--user"><%= user_link post_moderation_record.post_user %></h2>
29
+ <% else %>
30
+ <h2 class="thredded--post--user">
31
+ <%= post_moderation_record.post_user_name %>, <em><%= t 'thredded.null_user_name' %></em>
32
+ </h2>
33
+ <% end %>
34
+ <% if post %>
35
+ <p class="thredded--post--created-at"><%= time_ago post.created_at %></p>
36
+ <% end %>
37
+ </header>
38
+ <div class="thredded--post--content">
39
+ <%= Thredded::ContentFormatter.new(self).format_content(post_moderation_record.post_content) %>
40
+ </div>
41
+ </article>
42
+ <%= render 'post_moderation_actions', post: post if post %>
43
+ </article>
@@ -0,0 +1,19 @@
1
+ <% content_for :thredded_page_title,
2
+ safe_join([t('thredded.nav.moderation'), t('thredded.nav.moderation_history')], ': ') %>
3
+ <% content_for :thredded_page_id, 'thredded--pending-moderation' %>
4
+ <% content_for :thredded_breadcrumbs do %>
5
+ <ul class="thredded--navigation-breadcrumbs">
6
+ <li><%= link_to t('thredded.nav.all_messageboards'), messageboards_path %></li>
7
+ <li><%= link_to t('thredded.nav.moderation'), pending_moderation_path %></li>
8
+ <li><%= link_to t('thredded.nav.moderation_history'), moderation_history_path %></li>
9
+ </ul>
10
+ <% end %>
11
+
12
+ <%= thredded_page do %>
13
+ <%= content_tag :section, class: 'thredded--main-section' do %>
14
+ <% if @post_moderation_records.present? %>
15
+ <%= render partial: 'post_moderation_record', collection: @post_moderation_records %>
16
+ <%= paginate @post_moderation_records %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
@@ -0,0 +1,29 @@
1
+ <% content_for :thredded_page_title, t('thredded.nav.moderation') %>
2
+ <% content_for :thredded_page_id, 'thredded--pending-moderation' %>
3
+ <% content_for :thredded_breadcrumbs do %>
4
+ <ul class="thredded--navigation-breadcrumbs">
5
+ <li><%= link_to t('thredded.nav.all_messageboards'), messageboards_path %></li>
6
+ <li><%= link_to t('thredded.nav.moderation'), pending_moderation_path %></li>
7
+ </ul>
8
+ <% end %>
9
+
10
+ <%= thredded_page do %>
11
+ <%= content_tag :section, class: 'thredded--main-section' do %>
12
+ <%= link_to t('thredded.nav.moderation_history'), moderation_history_path,
13
+ class: 'thredded--link thredded--moderation--history-link' %>
14
+ <% if @last_moderated_record %>
15
+ <div class="thredded--moderated-notice">
16
+ <%= render 'post_moderation_record', post_moderation_record: @last_moderated_record %>
17
+ </div>
18
+ <% end %>
19
+ <% if @posts.present? %>
20
+ <%= render partial: 'post', collection: @posts %>
21
+ <%= paginate @posts %>
22
+ <% else %>
23
+ <div class="thredded--empty">
24
+ <h3 class="thredded--empty--title"><%= t 'thredded.moderation.pending_empty.title' %></h3>
25
+ <p><%= t 'thredded.moderation.pending_empty.content' %></p>
26
+ </div>
27
+ <% end %>
28
+ <% end %>
29
+ <% end %>
@@ -3,7 +3,7 @@
3
3
  <hr />
4
4
 
5
5
  <p>
6
- This email was sent to you because <%= @post.user %> mentioned you in
6
+ This email was sent to you because you are following this topic
7
7
  "<%= link_to @post.postable.title, post_permalink_url(@post.id) %>".
8
8
  <%= link_to 'View the conversation here', topic_url(@post.postable) %>.
9
9
  </p>
@@ -2,7 +2,7 @@
2
2
 
3
3
  ---
4
4
 
5
- This email was sent to you because <%= @post.user %> mentioned you in
5
+ This email was sent to you because you are following this topic
6
6
  "<%= @post.postable.title %>". Go here to view the conversation:
7
7
  <%= post_permalink_url @post %>
8
8
 
@@ -1,3 +1,10 @@
1
1
  <% cache(post, expires_in: 1.week) do %>
2
- <%= render 'thredded/posts_common/post', post: post %>
2
+ <%= content_tag :article, id: dom_id(post), class: 'thredded--post' do %>
3
+ <%= render 'thredded/posts_common/header', post: post %>
4
+ <%= render 'thredded/posts_common/content', post: post %>
5
+ <%= render 'thredded/posts_common/actions', post: post %>
6
+ <% if post.pending_moderation? && !Thredded.content_visible_while_pending_moderation %>
7
+ <p class="thredded--alert thredded--alert-warning"><%= t 'thredded.posts.pending_moderation_notice' %></p>
8
+ <% end %>
9
+ <% end %>
3
10
  <% end %>
@@ -0,0 +1,11 @@
1
+ <% if post.can_update? %>
2
+ <%= link_to t('thredded.posts.edit'), post.edit_path, class: 'thredded--post--edit' %>
3
+ <% end %>
4
+
5
+ <% if post.can_destroy? %>
6
+ <%= link_to t('thredded.posts.delete'), post.destroy_path,
7
+ method: :delete,
8
+ class: 'thredded--post--delete',
9
+ data: { confirm: I18n.t('thredded.posts.delete_confirm') }
10
+ %>
11
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <div class="thredded--post--content">
2
+ <% cache [post, 'content'], expires_in: 1.week do %>
3
+ <%= post.filtered_content(self) %>
4
+ <% end %>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <header>
2
+ <%= image_tag post.avatar_url, class: 'thredded--post--avatar' if post.user %>
3
+ <h2 class="thredded--post--user"><%= user_link post.user %></h2>
4
+ <p class="thredded--post--created-at"><%= time_ago post.created_at %></p>
5
+ </header>
@@ -1,3 +1,7 @@
1
1
  <% cache(private_post, expires_in: 1.week) do %>
2
- <%= render 'thredded/posts_common/post', post: private_post %>
2
+ <%= content_tag :article, id: dom_id(private_post), class: 'thredded--post' do %>
3
+ <%= render 'thredded/posts_common/header', post: private_post %>
4
+ <%= render 'thredded/posts_common/content', post: private_post %>
5
+ <%= render 'thredded/posts_common/actions', post: private_post %>
6
+ <% end %>
3
7
  <% end %>
@@ -6,6 +6,7 @@
6
6
  </li>
7
7
  <% end %>
8
8
 
9
+ <%= render 'thredded/shared/nav/moderation' %>
9
10
  <%= render 'thredded/shared/nav/notification_preferences', messageboard: messageboard_or_nil %>
10
11
  <%= render 'thredded/shared/nav/private_topics' %>
11
12
 
@@ -1,4 +1,4 @@
1
- <div id="thredded--container" class="thredded--main-container <%= yield(:thredded_page_id) %>" data-thredded-page-id="<%= yield(:thredded_page_id) %>">
1
+ <div id="thredded--container" class="thredded--main-container <%= yield(:thredded_page_id) %><%= ' thredded--is-moderator' if moderatable_messageboards_ids.present? %>" data-thredded-page-id="<%= yield(:thredded_page_id) %>">
2
2
  <%= render 'thredded/shared/header' %>
3
3
  <%= render 'thredded/shared/flash_messages' %>
4
4
  <%= yield :thredded_page_content %>
@@ -0,0 +1,13 @@
1
+ <% if moderatable_messageboards_ids.present? %>
2
+ <li class="thredded--user-navigation--item thredded--user-navigation--moderation">
3
+ <%= link_to pending_moderation_path, rel: 'nofollow' do %>
4
+ <%= inline_svg 'thredded/moderation.svg',
5
+ class: 'thredded--icon',
6
+ title: t('thredded.nav.moderation') %>
7
+ <span class="thredded--nav-text"><%= t 'thredded.nav.moderation' %></span>
8
+ <% if posts_pending_moderation_count > 0 %>
9
+ <span class="thredded--user-navigation--moderation--pending-count"><%= posts_pending_moderation_count %></span>
10
+ <% end %>
11
+ <% end %>
12
+ </li>
13
+ <% end %>
@@ -2,8 +2,7 @@
2
2
  <%= link_to private_topics_path, rel: 'nofollow' do %>
3
3
  <%= inline_svg 'thredded/private-messages.svg',
4
4
  class: 'thredded--icon',
5
- title: safe_join([t('thredded.nav.private_topics'),
6
- (unread_private_topics_count if unread_private_topics_count > 0)].compact, ' ') %>
5
+ title: t('thredded.nav.private_topics') %>
7
6
  <span class="thredded--nav-text"><%= t('thredded.nav.private_topics') %></span>
8
7
  <% if unread_private_topics_count > 0 -%>
9
8
  <span class="thredded--user-navigation--private-topics--unread"><%= unread_private_topics_count %></span>
@@ -9,4 +9,19 @@
9
9
  <%= link_to t('thredded.topics.edit'), topic.edit_path,
10
10
  class: 'thredded--topic-header--edit-topic' %>
11
11
  <% end %>
12
+ <% if current_user %>
13
+ <% if follow = current_user.following?(topic)%>
14
+ <div class="thredded--topic-follow-info thredded--following">
15
+ <p>
16
+ <% # i18n-tasks-use t('thredded.topics.following.manual') t('thredded.topics.following.posted') t('thredded.topics.following.mentioned') %>
17
+ <%= t("thredded.topics.following.#{follow.reason}") %></p>
18
+ <%= t('thredded.topics.following_will_receive_emails') %>
19
+ <%= button_to 'Stop following', topic.unfollow_path %>
20
+ </div>
21
+ <% else %>
22
+ <div class="thredded--topic-follow-info thredded--notfollowing">
23
+ <%= button_to 'Follow this topic', topic.follow_path %>
24
+ </div>
25
+ <% end %>
26
+ <% end %>
12
27
  </header>
@@ -1,4 +1,4 @@
1
- <% content_for :thredded_page_title, 'Topics' %>
1
+ <% content_for :thredded_page_title, messageboard.name %>
2
2
  <% content_for :thredded_page_id, 'thredded--topics-index' %>
3
3
  <% content_for :thredded_breadcrumbs, render('thredded/shared/breadcrumbs') %>
4
4
 
@@ -8,7 +8,7 @@
8
8
  messageboard: messageboard,
9
9
  topic: @new_topic,
10
10
  css_class: 'thredded--is-compact',
11
- placeholder: 'Start a New Topic' if @new_topic %>
11
+ placeholder: t('thredded.topics.form.title_placeholder_start') if @new_topic %>
12
12
  <%= render @topics %>
13
13
  <% end %>
14
14
 
@@ -7,5 +7,5 @@
7
7
  messageboard: messageboard,
8
8
  topic: @new_topic,
9
9
  css_class: 'thredded--is-expanded',
10
- placeholder: 'Start a New Topic' %>
10
+ placeholder: t('thredded.topics.form.title_placeholder_start') %>
11
11
  <% end %>
@@ -18,6 +18,16 @@ en:
18
18
  updated_notice: Messageboard has been updated
19
19
  messageboard_group:
20
20
  create: Create a New Messageboard Group
21
+ moderation:
22
+ approve_btn: Approve
23
+ block_btn: Block
24
+ pending_empty:
25
+ title: Good job!
26
+ content: All posts have been moderated.
27
+ post_approved_html: Post approved by %{moderator} %{time_ago}.
28
+ post_blocked_html: Post blocked by %{moderator} %{time_ago}.
29
+ post_deleted_notice: This post has been deleted.
30
+ posts_content_changed_since_moderation_html: The <a href="%{post_url}">post's</a> content change since it was moderated. Below is the content at the time it was moderated.
21
31
  nav:
22
32
  all_messageboards: All Messageboards
23
33
  edit_messageboard: Edit Messageboard
@@ -26,8 +36,11 @@ en:
26
36
  edit_topic: Edit
27
37
  private_topics: Private Messages
28
38
  settings: Notification Settings
39
+ moderation: Moderation
40
+ moderation_history: History
29
41
  null_user_name: Deleted user
30
42
  posts:
43
+ pending_moderation_notice: Your post will be published when it has been reviewed by a moderator.
31
44
  delete: Delete Post
32
45
  delete_confirm: Are you sure you want to delete this post?
33
46
  deleted_notice: Your post has been deleted.
@@ -43,15 +56,15 @@ en:
43
56
  global_preferences_label: Global Settings
44
57
  messageboard_notify_on_mention:
45
58
  hint: >-
46
- When someone mentions you by your username (eg: @sam) in this messageboard you will receive an email
47
- with the contents of that post.
59
+ When someone mentions you by your username (eg: @sam) in this messageboard you will follow
60
+ the topic. You will receive emails with the contents of that post and any replies.
48
61
  label: :thredded.preferences.form.notify_on_mention.label
49
62
  messageboard_preferences_label_html: Notification Settings for <em>%{messageboard}</em>
50
63
  notify_on_mention:
51
64
  hint: >-
52
- When someone mentions you by your username (eg: @sam) you will receive an email with the contents of
53
- that post.
54
- label: "@ Notifications"
65
+ When someone mentions you by your username (eg: @sam) you will follow the topic.
66
+ You will receive emails with the contents of that post and any replies.
67
+ label: "Follow topics you are mentioned in"
55
68
  notify_on_message:
56
69
  hint: When you are added to a private conversation you will receive an email with its content.
57
70
  label: Private Message Notifications
@@ -92,6 +105,7 @@ en:
92
105
  content_label: :thredded.posts.form.content_label
93
106
  title_label: Title
94
107
  title_placeholder: :thredded.topics.form.title_label
108
+ title_placeholder_start: Start a New Topic
95
109
  update_btn: Update Topic
96
110
  search:
97
111
  no_results_message: There are no results for your search - %{query}
@@ -99,3 +113,10 @@ en:
99
113
  results_message: Search Results for %{query}
100
114
  started_by_html: Started %{time_ago} by %{user}
101
115
  updated_notice: Topic updated
116
+ followed_notice: You are now following this topic
117
+ unfollowed_notice: You are no longer following this topic
118
+ following:
119
+ manual: You are following this topic.
120
+ posted: You are following this topic because you posted to it.
121
+ mentioned: You are following this topic because you were mentioned on it.
122
+ following_will_receive_emails: You will receive email updates.
@@ -18,12 +18,26 @@ pt-BR:
18
18
  updated_notice: Fórum de mensagem foi atualizado
19
19
  messageboard_group:
20
20
  create: Criar um novo grupo de mensagens
21
+ moderation:
22
+ approve_btn: Aprovar
23
+ block_btn: Quadra
24
+ pending_empty:
25
+ content: Todas as mensagens têm sido moderadas.
26
+ title: Bom trabalho!
27
+ post_approved_html: Pós aprovado por %{moderator} %{time_ago}.
28
+ post_blocked_html: Pós bloqueado por %{moderator} %{time_ago}.
29
+ post_deleted_notice: Este post foi apagado.
30
+ posts_content_changed_since_moderation_html: >-
31
+ O <a href="%{post_url}">de pós</a> alteração de conteúdo, uma vez que foi moderado. Abaixo está o conteúdo
32
+ no momento em que foi moderado.
21
33
  nav:
22
34
  all_messageboards: Todos os Fóruns de Mensagens
23
35
  edit_messageboard: Editar Fórum de Mensagem
24
36
  edit_post: Editar Post
25
37
  edit_private_topic: :thredded.nav.edit_topic
26
38
  edit_topic: Editar
39
+ moderation: Moderação
40
+ moderation_history: História
27
41
  private_topics: Mensagens Privadas
28
42
  settings: Configurações de Notificação
29
43
  null_user_name: Usuário deletado
@@ -36,6 +50,7 @@ pt-BR:
36
50
  content_label: Conteúdo
37
51
  create_btn: Enviar Resposta
38
52
  update_btn: Atualizar Post
53
+ pending_moderation_notice: O envio da mensagem será publicada quando foi revisado por um moderador.
39
54
  preferences:
40
55
  edit:
41
56
  page_title: :thredded.nav.settings
@@ -93,6 +108,7 @@ pt-BR:
93
108
  content_label: :thredded.posts.form.content_label
94
109
  title_label: Título
95
110
  title_placeholder: :thredded.topics.form.title_label
111
+ title_placeholder_start: Iniciar um novo tópico
96
112
  update_btn: Atualizar Tópico
97
113
  search:
98
114
  no_results_message: Nenhum resultado encontrado para sua busca - %{query}
@@ -100,3 +116,10 @@ pt-BR:
100
116
  results_message: Resultados de Busca para %{query}
101
117
  started_by_html: Iniciado %{time_ago} por %{user}
102
118
  updated_notice: Tópico atualizado
119
+ followed_notice: You are now following this topic
120
+ unfollowed_notice: You are no longer following this topic
121
+ following:
122
+ manual: You are following this topic.
123
+ posted: You are following this topic because you posted to it.
124
+ mentioned: You are following this topic because you were mentioned on it.
125
+ following_will_receive_emails: You will receive email updates.
data/config/routes.rb CHANGED
@@ -29,6 +29,11 @@ Thredded::Engine.routes.draw do
29
29
 
30
30
  scope path: 'admin' do
31
31
  resources :messageboard_groups, only: [:new, :create]
32
+ scope controller: :moderation, path: 'moderation' do
33
+ get '(/page-:page)', action: :pending, as: :pending_moderation, constraints: page_constraint
34
+ post '', action: :moderate_post, as: :moderate_post
35
+ get '/history(/page-:page)', action: :history, as: :moderation_history, constraints: page_constraint
36
+ end
32
37
  end
33
38
 
34
39
  resource :preferences, only: [:edit, :update]
@@ -44,6 +49,8 @@ Thredded::Engine.routes.draw do
44
49
  end
45
50
  member do
46
51
  get '(page-:page)', action: :show, as: '', constraints: page_constraint
52
+ post 'follow'
53
+ post 'unfollow'
47
54
  end
48
55
  resources :posts, except: [:index, :show], path: ''
49
56
  end
@@ -37,7 +37,9 @@ class CreateThredded < ActiveRecord::Migration
37
37
  t.integer :topics_count, default: 0
38
38
  t.integer :posts_count, default: 0
39
39
  t.boolean :closed, default: false, null: false
40
+ t.references :messageboard_group
40
41
  t.timestamps null: false
42
+ t.index [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
41
43
  end
42
44
  add_index :thredded_messageboards, [:closed], name: :index_thredded_messageboards_on_closed
43
45
  add_index :thredded_messageboards, [:slug], name: :index_thredded_messageboards_on_slug
@@ -57,7 +59,11 @@ class CreateThredded < ActiveRecord::Migration
57
59
  t.string :source, limit: 255, default: 'web'
58
60
  t.integer :postable_id, limit: 4
59
61
  t.integer :messageboard_id, null: false
62
+ t.integer :moderation_state, null: false
60
63
  t.timestamps null: false
64
+ t.index [:moderation_state, :updated_at],
65
+ order: { updated_at: :asc },
66
+ name: :index_thredded_posts_for_display
61
67
  end
62
68
  add_index :thredded_posts, [:messageboard_id], name: :index_thredded_posts_on_messageboard_id
63
69
  add_index :thredded_posts, [:postable_id], name: :index_thredded_posts_on_postable_id
@@ -111,7 +117,11 @@ class CreateThredded < ActiveRecord::Migration
111
117
  t.boolean :locked, default: false, null: false
112
118
  t.string :hash_id, limit: 191, null: false
113
119
  t.string :type, limit: 191
120
+ t.integer :moderation_state, null: false
114
121
  t.timestamps null: false
122
+ t.index %i(moderation_state sticky updated_at),
123
+ order: { sticky: :desc, updated_at: :desc },
124
+ name: :index_thredded_topics_for_display
115
125
  end
116
126
  add_index :thredded_topics, [:hash_id], name: :index_thredded_topics_on_hash_id
117
127
  add_index :thredded_topics, [:messageboard_id, :slug], name: :index_thredded_topics_on_messageboard_id_and_slug, unique: true
@@ -124,11 +134,16 @@ class CreateThredded < ActiveRecord::Migration
124
134
  t.datetime :latest_activity_at
125
135
  t.integer :posts_count, default: 0
126
136
  t.integer :topics_count, default: 0
127
- t.timestamps null: false
128
137
  t.datetime :last_seen_at
138
+ t.integer :moderation_state, null: false, default: 0 # pending_moderation
139
+ t.timestamp :moderation_state_changed_at
140
+ t.timestamps null: false
141
+ t.index %i(moderation_state moderation_state_changed_at),
142
+ order: { moderation_state_changed_at: :desc },
143
+ name: :index_thredded_user_details_for_moderations
144
+ t.index %i(latest_activity_at), name: :index_thredded_user_details_on_latest_activity_at
145
+ t.index %i(user_id), name: :index_thredded_user_details_on_user_id
129
146
  end
130
- add_index :thredded_user_details, [:latest_activity_at], name: :index_thredded_user_details_on_latest_activity_at
131
- add_index :thredded_user_details, [:user_id], name: :index_thredded_user_details_on_user_id
132
147
 
133
148
  create_table :thredded_messageboard_users do |t|
134
149
  t.references :thredded_user_detail, foreign_key: true, null: false
@@ -174,8 +189,28 @@ class CreateThredded < ActiveRecord::Migration
174
189
  t.timestamps null: false
175
190
  end
176
191
 
177
- add_column :thredded_messageboards, :messageboard_group_id, :integer
178
- add_index :thredded_messageboards, [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
192
+ create_table :thredded_user_topic_follows do |t|
193
+ t.integer :user_id, null: false
194
+ t.integer :topic_id, null: false
195
+ t.datetime :created_at, null: false
196
+ t.integer :reason, limit: 1
197
+ end
198
+ add_index :thredded_user_topic_follows, [:user_id, :topic_id], name: :thredded_user_topic_follows_user_topic, unique: true
199
+
200
+ create_table :thredded_post_moderation_records do |t|
201
+ t.references :post
202
+ t.references :messageboard
203
+ t.text :post_content, limit: 65_535
204
+ t.references :post_user
205
+ t.text :post_user_name
206
+ t.references :moderator
207
+ t.integer :moderation_state, null: false
208
+ t.integer :previous_moderation_state, null: false
209
+ t.timestamp :created_at, null: false
210
+ t.index [:messageboard_id, :created_at],
211
+ order: { created_at: :desc },
212
+ name: :index_thredded_moderation_records_for_display
213
+ end
179
214
  end
180
215
  end
181
216
  # rubocop:enable Metrics/LineLength