thredded 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.mkdn +21 -0
  3. data/README.mkdn +17 -1
  4. data/app/assets/stylesheets/thredded/_thredded.scss +1 -0
  5. data/app/assets/stylesheets/thredded/base/_grid.scss +6 -0
  6. data/app/assets/stylesheets/thredded/base/_nav.scss +51 -0
  7. data/app/assets/stylesheets/thredded/base/_variables.scss +1 -0
  8. data/app/assets/stylesheets/thredded/components/_base.scss +4 -0
  9. data/app/assets/stylesheets/thredded/components/_post.scss +19 -6
  10. data/app/assets/stylesheets/thredded/components/_topics.scss +6 -0
  11. data/app/assets/stylesheets/thredded/layout/_moderation.scss +53 -8
  12. data/app/assets/stylesheets/thredded/layout/_navigation.scss +1 -1
  13. data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +7 -47
  14. data/app/assets/stylesheets/thredded/layout/_user.scss +10 -0
  15. data/app/commands/thredded/moderate_post.rb +1 -1
  16. data/app/controllers/thredded/messageboards_controller.rb +1 -1
  17. data/app/controllers/thredded/moderation_controller.rb +39 -5
  18. data/app/helpers/thredded/application_helper.rb +4 -2
  19. data/app/models/concerns/thredded/content_moderation_state.rb +15 -8
  20. data/app/models/concerns/thredded/post_common.rb +1 -0
  21. data/app/models/concerns/thredded/topic_common.rb +0 -1
  22. data/app/models/thredded/messageboard.rb +4 -4
  23. data/app/models/thredded/post.rb +2 -0
  24. data/app/models/thredded/post_moderation_record.rb +3 -1
  25. data/app/models/thredded/topic.rb +17 -0
  26. data/app/models/thredded/user_extender.rb +7 -0
  27. data/app/policies/thredded/post_policy.rb +2 -0
  28. data/app/policies/thredded/topic_policy.rb +6 -6
  29. data/app/view_models/thredded/post_view.rb +19 -1
  30. data/app/view_models/thredded/posts_page_view.rb +1 -0
  31. data/app/view_models/thredded/topic_view.rb +5 -1
  32. data/app/views/thredded/messageboards/_messageboard.html.erb +3 -3
  33. data/app/views/thredded/moderation/_nav.html.erb +16 -0
  34. data/app/views/thredded/moderation/_post.html.erb +9 -2
  35. data/app/views/thredded/moderation/_post_moderation_record.html.erb +22 -19
  36. data/app/views/thredded/moderation/_user_moderation_state.html.erb +3 -0
  37. data/app/views/thredded/moderation/_user_post.html.erb +7 -0
  38. data/app/views/thredded/moderation/_users_search_form.html.erb +10 -0
  39. data/app/views/thredded/moderation/history.html.erb +2 -8
  40. data/app/views/thredded/moderation/pending.html.erb +3 -10
  41. data/app/views/thredded/moderation/user.html.erb +42 -0
  42. data/app/views/thredded/moderation/users.html.erb +38 -0
  43. data/app/views/thredded/posts/_post.html.erb +4 -0
  44. data/app/views/thredded/posts_common/_header.html.erb +1 -0
  45. data/app/views/thredded/posts_common/_header_with_topic.html.erb +15 -0
  46. data/app/views/thredded/posts_common/_header_with_user_and_topic.html.erb +18 -0
  47. data/app/views/thredded/search/_form.html.erb +3 -1
  48. data/app/views/thredded/shared/_content_moderation_blocked_state.html.erb +8 -0
  49. data/app/views/thredded/shared/_nav.html.erb +8 -4
  50. data/app/views/thredded/topics/_topic.html.erb +6 -0
  51. data/app/views/thredded/users/_post.html.erb +6 -0
  52. data/app/views/thredded/users/_posts.html.erb +7 -0
  53. data/config/locales/en.yml +29 -3
  54. data/config/locales/pt-BR.yml +34 -9
  55. data/config/routes.rb +7 -2
  56. data/db/migrate/20160329231848_create_thredded.rb +22 -21
  57. data/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb +25 -0
  58. data/heroku.gemfile.lock +2 -2
  59. data/lib/thredded.rb +17 -5
  60. data/lib/thredded/version.rb +1 -1
  61. metadata +15 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc3545dd645f403b5ae3ca2bed2d5a6ab6b3f627
4
- data.tar.gz: ca8d375aa187a223f7a250415c36e4749328074c
3
+ metadata.gz: b89649352c4f5481a4e2ad05a885e21a2bb9a5d0
4
+ data.tar.gz: 4b7bf4007f49a57fbf4a00b176750cb700a8a801
5
5
  SHA512:
6
- metadata.gz: 9cf1df595f1f50cea1c495adc89ad1049024a702af881632799a9a0ea8305087a4ce1c51a55c9419465b33fb7f1af4313d979da93da5fab27ee9fcb477ba4e1c
7
- data.tar.gz: e52bed5a33b9852a5bebcff13484ffe9ff97c7cbe93f4b0e5f470152beafc99f15c4eb6a4acf483cc5e0375b1aa3216e0a48ed5d7bc547572bb8d8eea5a12029
6
+ metadata.gz: d2e4a2b77cd7495e279b80e910c20a28f236e1103974410ec3572cb0b99c482ec662f3eb5951f4f7cda7b4e88f5a8f6cdf4c430c363bcd63cc78384a58a5fae1
7
+ data.tar.gz: d36788984d19723bb7607042e2675d3da6a9103b76d2e550a8797e557e53ac4493fc2f6aee8d6496920e0dc24cbbffcd3b6bd9e96357ec3d07eb0dfb0fdc9fb7
@@ -1,3 +1,24 @@
1
+ # 0.6.0 - 2016-06-12
2
+
3
+ **NB:** If updating to this version from 0.5.x, you will need to copy and run [this migration](https://github.com/thredded/thredded/blob/66f64068b9501ff4e8686c95894b6795aae6082f/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb).
4
+
5
+ ## Added
6
+
7
+ * Adds a Users tab to moderation, where individual users can be moderated.
8
+ * Improves the display of posts in the moderation, showing the topic and
9
+ whether the post started the topic.
10
+ * Thredded now provides a way to render a user's recent posts in the main_app.
11
+
12
+ ## Changed
13
+
14
+ * Moderators are now shown all content, including blocked content. A notice is shown on blocked content.
15
+
16
+ ## Fixed
17
+
18
+ * Fixed a bug that prevented user deletion in main_app if they had posted on the forums.
19
+
20
+ See the full list of changes here: https://github.com/thredded/thredded/compare/v0.5.1...v0.6.0.
21
+
1
22
  # 0.5.1
2
23
 
3
24
  This is a minor bugfix release.
@@ -44,7 +44,7 @@ application and not an engine like Thredded.
44
44
  Add the gem to your Gemfile:
45
45
 
46
46
  ```ruby
47
- gem 'thredded', '~> 0.5.1'
47
+ gem 'thredded', '~> 0.6.0'
48
48
  ```
49
49
 
50
50
  Add the Thredded [initializer] to your parent app by running the install generator.
@@ -148,6 +148,22 @@ Include thredded JavaScripts in your `application.js`:
148
148
  Thredded views also provide two `content_tag`s available to yield - `:thredded_page_title` and `:thredded_page_id`.
149
149
  The views within Thredded pass those up through to your layout if you would like to use them.
150
150
 
151
+ ### User profile page
152
+
153
+ Thredded does not provide a user's profile page, but it provides a helper for rendering the user's recent posts
154
+ in your app's user profile page.
155
+
156
+ To use it:
157
+ 1. Include `Thredded::ApplicationHelper` in the app's helpers module.
158
+ 2. Render the partial like this:
159
+
160
+ ```erb
161
+ <%= render 'thredded/users/_posts',
162
+ posts: Thredded.posts_page_view(
163
+ scope: user.thredded_posts.order_newest_first.limit(5),
164
+ current_user: current_user) %>
165
+ ```
166
+
151
167
  ### Customizing views
152
168
 
153
169
  You can also override any views and assets by placing them in the same path in your application as they are in the gem.
@@ -10,6 +10,7 @@
10
10
  @import "layout/user-navigation";
11
11
  @import "layout/navigation";
12
12
  @import "layout/moderation";
13
+ @import "layout/user";
13
14
 
14
15
  @import "components/base";
15
16
  @import "components/alerts";
@@ -22,6 +22,12 @@
22
22
  }
23
23
  }
24
24
 
25
+ @mixin thredded-media-avatar-breakout {
26
+ @media (min-width: $thredded-grid-container-max-width + 4rem) {
27
+ @content;
28
+ }
29
+ }
30
+
25
31
  @mixin thredded--clearfix {
26
32
  &::after {
27
33
  clear: both;
@@ -19,3 +19,54 @@
19
19
  %thredded--nav-link-current {
20
20
  color: $thredded-nav-current-color;
21
21
  }
22
+
23
+
24
+ %thredded--nav-tabs {
25
+ @extend %thredded--list-unstyled;
26
+ @include thredded--clearfix;
27
+ border-bottom: $thredded-base-border;
28
+ font-size: $thredded-font-size-small;
29
+ margin-left: 0;
30
+ margin-bottom: 1rem;
31
+ text-align: left;
32
+ list-style-type: none;
33
+
34
+ @include thredded-media-tablet-and-up {
35
+ margin-bottom: 0;
36
+ }
37
+ }
38
+
39
+ %thredded--nav-tabs--item {
40
+ display: inline-block;
41
+ margin-right: 1rem;
42
+
43
+ a {
44
+ @extend %thredded--nav-link;
45
+ display: inline-block;
46
+ color: $thredded-secondary-nav-color;
47
+ padding: $thredded-small-spacing 0;
48
+ }
49
+
50
+ &:last-child {
51
+ margin-right: 0;
52
+ }
53
+ }
54
+
55
+ %thredded--nav-tabs--item-current {
56
+ border-bottom: 1px solid $thredded-action-color;
57
+ margin-bottom: -1px;
58
+
59
+ a {
60
+ @extend %thredded--nav-link-current;
61
+ }
62
+ }
63
+
64
+ %thredded--nav-tabs--item--badge {
65
+ background: $thredded-badge-active-background;
66
+ border-radius: 10px;
67
+ color: $thredded-badge-active-color;
68
+ font-size: 0.75rem; // 12px
69
+ line-height: 1;
70
+ margin-left: 0.4rem;
71
+ padding: 2px 6px;
72
+ }
@@ -14,6 +14,7 @@ $thredded-heading-line-height: 1.2 !default;
14
14
  $thredded-large-spacing: $thredded-base-line-height * 2rem !default;
15
15
  $thredded-base-spacing: $thredded-base-line-height * 1rem !default;
16
16
  $thredded-small-spacing: $thredded-base-spacing / 2 !default;
17
+ $thredded-inline-spacing: 0.4375em !default;
17
18
 
18
19
  // Named colors
19
20
  $thredded-brand: #4a90e2 !default;
@@ -15,3 +15,7 @@
15
15
  &--blockquote {
16
16
  @extend %thredded--blockquote;
17
17
  }
18
+
19
+ &--table {
20
+ @extend %thredded--table;
21
+ }
@@ -10,13 +10,13 @@
10
10
  border-radius: 50%;
11
11
  display: inline-block;
12
12
  height: 1.75rem; // 28px
13
- margin-right: $thredded-small-spacing;
13
+ margin-right: $thredded-inline-spacing;
14
14
  position: relative;
15
15
  top: 6px;
16
16
  vertical-align: baseline;
17
17
  width: 1.75rem; // 28px
18
18
 
19
- @media (min-width: $thredded-grid-container-max-width + 4rem) {
19
+ @include thredded-media-avatar-breakout {
20
20
  height: 2.25rem; // 36px
21
21
  left: -3rem;
22
22
  position: absolute;
@@ -25,16 +25,29 @@
25
25
  }
26
26
  }
27
27
 
28
- &--post--user {
28
+ &--post--topic {
29
29
  @extend %thredded--heading;
30
- display: inline-block;
30
+ font-size: $thredded-base-font-size * 1.25; // 24px
31
+ line-height: 1.2;
32
+ margin-bottom: $thredded-small-spacing / 2;
33
+ }
34
+
35
+ &--post--user,
36
+ &--post--topic,
37
+ &--post--user-and-topic {
38
+ @extend %thredded--heading;
39
+ display: inline;
31
40
  font-size: 1.125rem; // 18px
32
41
  line-height: 1.2;
33
- margin-right: $thredded-small-spacing;
34
- margin-bottom: 1.25rem; // 20px
42
+ margin-right: $thredded-inline-spacing;
35
43
 
36
44
  a {
37
45
  @extend %thredded--link;
46
+ }
47
+ }
48
+
49
+ &--post--user {
50
+ a {
38
51
  color: $thredded-text-color;
39
52
  }
40
53
  }
@@ -88,6 +88,12 @@
88
88
  }
89
89
  }
90
90
 
91
+ &--topics--moderation-state {
92
+ padding: 0.3em 0.5em;
93
+ font-size: $thredded-font-size-small;
94
+ font-style: normal;
95
+ }
96
+
91
97
  &--topics--posts-count {
92
98
  border-radius: 50%;
93
99
  display: inline-block;
@@ -1,12 +1,22 @@
1
- &--post-moderation-actions {
2
- @extend %thredded--buttons-list;
1
+ &--moderation-navigation {
2
+ position: relative;
3
+ &--items {
4
+ @extend %thredded--nav-tabs;
5
+ }
6
+ &--item {
7
+ @extend %thredded--nav-tabs--item;
8
+ }
3
9
  }
4
10
 
5
- &--moderation--history-link {
6
- float: right;
7
- margin: 0.4rem 0.6rem $thredded-small-spacing 0;
8
- position: relative;
9
- z-index: 1;
11
+ .thredded--pending-moderation &--moderation-navigation--pending,
12
+ .thredded--moderation-history &--moderation-navigation--history,
13
+ .thredded--moderation-users &--moderation-navigation--users,
14
+ .thredded--moderation-user &--moderation-navigation--users{
15
+ @extend %thredded--nav-tabs--item-current;
16
+ }
17
+
18
+ &--post-moderation-actions {
19
+ @extend %thredded--buttons-list;
10
20
  }
11
21
 
12
22
  &--moderated-notice {
@@ -15,10 +25,19 @@
15
25
  background: $thredded-light-gray;
16
26
  }
17
27
 
28
+ &--post-moderation, &--post-moderation-record {
29
+ .thredded--post--user a {
30
+ color: $thredded-action-color;
31
+ }
32
+ }
33
+
18
34
  &--post-moderation-record {
19
35
  .thredded--post {
20
36
  margin-bottom: 0;
21
- margin-left: 4rem;
37
+ margin-left: 1rem;
38
+ @include thredded-media-avatar-breakout {
39
+ margin-left: 4rem;
40
+ }
22
41
  }
23
42
  &--moderation-state-notice {
24
43
  margin-bottom: 1rem;
@@ -43,3 +62,29 @@
43
62
  &--post-moderation-record + &--post-moderation-record {
44
63
  margin-top: $thredded-large-spacing;
45
64
  }
65
+
66
+ &--moderation--users-table {
67
+ width: 100%;
68
+ a {
69
+ display: block;
70
+ }
71
+ }
72
+
73
+ &--moderation--user--title {
74
+ margin: 0;
75
+ }
76
+
77
+ &--moderation--user--info {
78
+ margin-left: 2rem;
79
+ }
80
+
81
+ &--user--moderation-actions {
82
+ text-align: left;
83
+ margin-left: 4rem;
84
+ .button_to {
85
+ display: inline-block;
86
+ }
87
+ .button_to + .button_to {
88
+ margin-left: $thredded-small-spacing;
89
+ }
90
+ }
@@ -24,7 +24,7 @@
24
24
  padding-right: $icon-nav-item-width * 3;
25
25
  }
26
26
  }
27
- &--navigation--search {
27
+ &--navigation--search-topics {
28
28
  display: none;
29
29
  .thredded--messageboards-index &,
30
30
  .thredded--topics-index &,
@@ -1,40 +1,9 @@
1
1
  &--user-navigation {
2
- @extend %thredded--list-unstyled;
3
- @include thredded--clearfix;
4
- border-bottom: $thredded-base-border;
5
- margin-bottom: 1rem;
6
- text-align: left;
7
-
8
- @include thredded-media-tablet-and-up {
9
- font-size: $thredded-font-size-small;
10
- margin-bottom: 0;
11
- }
12
-
13
- a {
14
- @extend %thredded--nav-link;
15
- color: $thredded-secondary-nav-color;
16
- }
17
-
18
- > ul {
19
- @extend %thredded--list-unstyled;
20
- }
2
+ @extend %thredded--nav-tabs;
21
3
  }
22
4
 
23
5
  &--user-navigation--item {
24
- display: inline-block;
25
- margin-right: 1rem;
26
-
27
- a {
28
- padding: $thredded-small-spacing 0;
29
- }
30
-
31
- &:last-child {
32
- margin-right: 0;
33
- }
34
-
35
- @include thredded-media-tablet-and-up {
36
- padding: $thredded-small-spacing 0;
37
- }
6
+ @extend %thredded--nav-tabs--item;
38
7
  }
39
8
 
40
9
  .thredded--preferences &--user-navigation--settings,
@@ -42,22 +11,13 @@
42
11
  .thredded--private-topics-index &--user-navigation--private-topics,
43
12
  .thredded--private-topic-show &--user-navigation--private-topics,
44
13
  .thredded--pending-moderation &--user-navigation--moderation,
45
- .thredded--moderation-history &--user-navigation--moderation {
46
- border-bottom: 1px solid $thredded-action-color;
47
- margin-bottom: -1px;
48
-
49
- a {
50
- @extend %thredded--nav-link-current;
51
- }
14
+ .thredded--moderation-history &--user-navigation--moderation,
15
+ .thredded--moderation-users &--user-navigation--moderation,
16
+ .thredded--moderation-user &--user-navigation--moderation {
17
+ @extend %thredded--nav-tabs--item-current;
52
18
  }
53
19
 
54
20
  &--user-navigation--private-topics--unread,
55
21
  &--user-navigation--moderation--pending-count {
56
- background: $thredded-badge-active-background;
57
- border-radius: 10px;
58
- color: $thredded-badge-active-color;
59
- font-size: 0.75rem; // 12px
60
- line-height: 1;
61
- margin-left: 0.4rem;
62
- padding: 2px 6px;
22
+ @extend %thredded--nav-tabs--item--badge;
63
23
  }
@@ -0,0 +1,10 @@
1
+ &--user--avatar {
2
+ border-radius: 50%;
3
+ display: inline-block;
4
+ height: 1.75em;
5
+ width: 1.75em;
6
+ margin-right: $thredded-inline-spacing;
7
+ vertical-align: baseline;
8
+ position: relative;
9
+ top: 0.5em;
10
+ }
@@ -15,7 +15,7 @@ module Thredded
15
15
  previous_moderation_state: post.moderation_state,
16
16
  moderation_state: moderation_state,
17
17
  )
18
- if post.user_detail.pending_moderation?
18
+ if post.user_id && post.user_detail.pending_moderation?
19
19
  post.user_detail.update!(moderation_state: moderation_state)
20
20
  end
21
21
  if post.postable.first_post == post
@@ -8,7 +8,7 @@ module Thredded
8
8
 
9
9
  def index
10
10
  @groups = policy_scope(Messageboard.all)
11
- .preload(:group).group_by(&:group)
11
+ .preload(:group, last_topic: [:last_user]).group_by(&:group)
12
12
  .map { |(group, messageboards)| MessageboardGroupView.new(group, messageboards) }
13
13
  end
14
14
 
@@ -12,17 +12,18 @@ module Thredded
12
12
  moderatable_posts
13
13
  .pending_moderation
14
14
  .order_oldest_first
15
- .page(params[:page] || 1)
15
+ .preload(:user, :postable)
16
+ .page(current_page)
16
17
  )
17
18
  if flash[:last_moderated_record_id]
18
- @last_moderated_record = accessible_moderation_records.find(flash[:last_moderated_record_id].to_i)
19
+ @last_moderated_record = accessible_post_moderation_records.find(flash[:last_moderated_record_id].to_i)
19
20
  end
20
21
  end
21
22
 
22
23
  def history
23
- @post_moderation_records = accessible_moderation_records
24
+ @post_moderation_records = accessible_post_moderation_records
24
25
  .order(created_at: :desc)
25
- .page(params[:page] || 1)
26
+ .page(current_page)
26
27
  end
27
28
 
28
29
  def moderate_post
@@ -35,13 +36,42 @@ module Thredded
35
36
  redirect_back fallback_location: pending_moderation_path
36
37
  end
37
38
 
39
+ def users
40
+ @users = Thredded.user_class
41
+ .left_join_thredded_user_details
42
+ .merge(Thredded::UserDetail.order(moderation_state_changed_at: :desc))
43
+ @query = params[:q].to_s
44
+ if @query.present?
45
+ @users = DbTextSearch::CaseInsensitive.new(@users, Thredded.user_name_column).prefix(@query)
46
+ end
47
+ @users = @users.page(current_page)
48
+ end
49
+
50
+ def user
51
+ @user = Thredded.user_class.find(params[:id])
52
+ # Do not apply policy_scope here, as we want to show blocked posts as well.
53
+ posts_scope = @user.thredded_posts
54
+ .where(messageboard_id: policy_scope(Messageboard.all).pluck(:id))
55
+ .order_newest_first
56
+ .includes(:postable)
57
+ .page(current_page)
58
+ @posts = PostsPageView.new(current_user, posts_scope)
59
+ end
60
+
61
+ def moderate_user
62
+ return head(:bad_request) unless Thredded::UserDetail.moderation_states.include?(params[:moderation_state])
63
+ user = Thredded.user_class.find(params[:id])
64
+ user.thredded_user_detail.update!(moderation_state: params[:moderation_state])
65
+ redirect_back fallback_location: user_moderation_path(user.id)
66
+ end
67
+
38
68
  private
39
69
 
40
70
  def moderatable_posts
41
71
  Thredded::Post.where(messageboard_id: @moderatable_messageboards)
42
72
  end
43
73
 
44
- def accessible_moderation_records
74
+ def accessible_post_moderation_records
45
75
  Thredded::PostModerationRecord
46
76
  .where(messageboard_id: @moderatable_messageboards)
47
77
  end
@@ -52,5 +82,9 @@ module Thredded
52
82
  fail Pundit::NotAuthorizedError, 'You are not authorized to perform this action.'
53
83
  end
54
84
  end
85
+
86
+ def current_page
87
+ (params[:page] || 1).to_i
88
+ end
55
89
  end
56
90
  end