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,55 +0,0 @@
1
- # frozen_string_literal: true
2
- module Thredded
3
- class NotifyMentionedUsers
4
- def initialize(post)
5
- @post = post
6
- end
7
-
8
- def run
9
- members = at_notifiable_members
10
- return unless members.present?
11
-
12
- user_emails = members.map(&:email)
13
- (post.private_topic_post? ? PrivatePostMailer : PostMailer)
14
- .at_notification(post.id, user_emails)
15
- .deliver_later
16
- MembersMarkedNotified.new(post, members).run
17
- end
18
-
19
- def at_notifiable_members
20
- user_names = AtNotificationExtractor.new(post.content).run
21
- members = post.readers_from_user_names(user_names).to_a
22
-
23
- members.delete post.user
24
- members = exclude_previously_notified(members)
25
- members = exclude_those_that_are_not_private(members)
26
- members = exclude_those_opting_out_of_at_notifications(members)
27
-
28
- members
29
- end
30
-
31
- private
32
-
33
- attr_reader :post
34
-
35
- def exclude_those_opting_out_of_at_notifications(members)
36
- members.select do |member|
37
- member.thredded_user_preference.notify_on_mention? &&
38
- (private_topic? || member.thredded_user_messageboard_preferences.in(post.messageboard).notify_on_mention?)
39
- end
40
- end
41
-
42
- def exclude_those_that_are_not_private(members)
43
- members.reject { |member| private_topic? && post.postable.users.exclude?(member) }
44
- end
45
-
46
- def exclude_previously_notified(members)
47
- emails_notified = Thredded::PostNotification.where(post: post).pluck(:email)
48
- members.reject { |member| emails_notified.include? member.email }
49
- end
50
-
51
- def private_topic?
52
- post.private_topic_post?
53
- end
54
- end
55
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- module Thredded
3
- class AtNotifierJob < ::ActiveJob::Base
4
- queue_as :default
5
-
6
- def perform(post_type, post_id)
7
- post = post_type.to_s.constantize.find(post_id)
8
-
9
- NotifyMentionedUsers.new(post).run
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- module Thredded
3
- # Previews for the PrivatePostMailer
4
- class PrivatePostMailerPreview < BaseMailerPreview
5
- def at_notification
6
- PrivatePostMailer.at_notification(
7
- mock_private_post(content: mock_content(mention_users: %w(glebm joel))),
8
- %w(glebm@test.com joel@test.com)
9
- )
10
- end
11
- end
12
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
- require_dependency 'thredded/topic_email_view'
3
- module Thredded
4
- class PrivatePostMailer < Thredded::BaseMailer
5
- def at_notification(post_id, emails)
6
- @post = find_record PrivatePost, post_id
7
- email_details = TopicEmailView.new(@post.postable)
8
- headers['X-SMTPAPI'] = email_details.smtp_api_tag('at_notification')
9
-
10
- mail from: email_details.no_reply,
11
- to: email_details.no_reply,
12
- bcc: emails,
13
- reply_to: email_details.reply_to,
14
- subject: email_details.subject
15
- end
16
- end
17
- end
@@ -1,26 +0,0 @@
1
- <%# @param post [Thredded::PostView] %>
2
- <%= content_tag :article, id: dom_id(post), class: 'thredded--post' do %>
3
- <header>
4
- <%= image_tag post.avatar_url, class: 'thredded--post--avatar' if post.user %>
5
- <h2 class="thredded--post--user"><%= user_link post.user %></h2>
6
- <p class="thredded--post--created-at"><%= time_ago post.created_at %></p>
7
- </header>
8
-
9
- <div class="thredded--post--content">
10
- <% cache [post, 'content'], expires_in: 1.week do %>
11
- <%= post.filtered_content(self) %>
12
- <% end %>
13
- </div>
14
-
15
- <% if post.can_update? %>
16
- <%= link_to t('thredded.posts.edit'), post.edit_path, class: 'thredded--post--edit' %>
17
- <% end %>
18
-
19
- <% if post.can_destroy? %>
20
- <%= link_to t('thredded.posts.delete'), post.destroy_path,
21
- method: :delete,
22
- class: 'thredded--post--delete',
23
- data: { confirm: I18n.t('thredded.posts.delete_confirm') }
24
- %>
25
- <% end %>
26
- <% end %>
@@ -1,13 +0,0 @@
1
- <blockquote><%= @post.filtered_content(self) %></blockquote>
2
-
3
- <hr />
4
-
5
- <p>
6
- This email was sent to you because <%= @post.user %> mentioned you in
7
- "<%= link_to @post.postable.title, private_post_permalink_url(@post.id) %>".
8
- <%= link_to 'View the conversation here', topic_url(@post.postable) %>.
9
- </p>
10
-
11
- <p>
12
- To unsubscribe from these emails, update your <%= link_to 'preferences', edit_preferences_url %>.
13
- </p>