thredded 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -17
  3. data/app/assets/images/thredded/three-dot-menu.svg +3 -0
  4. data/app/assets/stylesheets/thredded/base/_tables.scss +1 -0
  5. data/app/assets/stylesheets/thredded/base/_variables.scss +24 -1
  6. data/app/assets/stylesheets/thredded/components/_currently-online.scss +1 -0
  7. data/app/assets/stylesheets/thredded/components/_messageboard.scss +18 -10
  8. data/app/assets/stylesheets/thredded/components/_post.scss +84 -13
  9. data/app/assets/stylesheets/thredded/components/_topics.scss +7 -1
  10. data/app/assets/stylesheets/thredded/layout/_main-container.scss +1 -0
  11. data/app/assets/stylesheets/thredded/layout/_search-navigation.scss +15 -6
  12. data/app/controllers/thredded/application_controller.rb +6 -3
  13. data/app/controllers/thredded/moderation_controller.rb +1 -1
  14. data/app/controllers/thredded/posts_controller.rb +19 -22
  15. data/app/controllers/thredded/preferences_controller.rb +1 -2
  16. data/app/controllers/thredded/private_posts_controller.rb +77 -0
  17. data/app/controllers/thredded/private_topics_controller.rb +1 -1
  18. data/app/controllers/thredded/read_states_controller.rb +1 -1
  19. data/app/controllers/thredded/topics_controller.rb +1 -1
  20. data/app/forms/thredded/private_topic_form.rb +3 -3
  21. data/app/forms/thredded/topic_form.rb +1 -1
  22. data/app/helpers/thredded/application_helper.rb +12 -1
  23. data/app/helpers/thredded/render_helper.rb +14 -0
  24. data/app/helpers/thredded/urls_helper.rb +8 -0
  25. data/app/models/concerns/thredded/post_common.rb +20 -0
  26. data/app/models/concerns/thredded/user_topic_read_state_common.rb +6 -0
  27. data/app/models/thredded/null_user_topic_read_state.rb +4 -0
  28. data/app/policies/thredded/post_policy.rb +4 -0
  29. data/app/policies/thredded/private_post_policy.rb +4 -0
  30. data/app/view_hooks/thredded/all_view_hooks.rb +15 -0
  31. data/app/view_models/thredded/base_topic_view.rb +1 -1
  32. data/app/view_models/thredded/post_view.rb +23 -21
  33. data/app/view_models/thredded/posts_page_view.rb +4 -2
  34. data/app/view_models/thredded/topic_posts_page_view.rb +1 -1
  35. data/app/view_models/thredded/topic_view.rb +1 -1
  36. data/app/view_models/thredded/topics_page_view.rb +1 -0
  37. data/app/views/thredded/moderation/_post.html.erb +2 -2
  38. data/app/views/thredded/moderation/_user_post.html.erb +2 -2
  39. data/app/views/thredded/moderation/activity.html.erb +3 -1
  40. data/app/views/thredded/moderation/pending.html.erb +3 -1
  41. data/app/views/thredded/moderation/user.html.erb +3 -1
  42. data/app/views/thredded/posts/_content.html.erb +1 -0
  43. data/app/views/thredded/posts/_post.html.erb +11 -12
  44. data/app/views/thredded/posts/edit.html.erb +3 -4
  45. data/app/views/thredded/posts_common/_actions.html.erb +21 -8
  46. data/app/views/thredded/posts_common/actions/_delete.html.erb +4 -0
  47. data/app/views/thredded/posts_common/actions/_edit.html.erb +2 -0
  48. data/app/views/thredded/posts_common/actions/_mark_as_unread.html.erb +2 -0
  49. data/app/views/thredded/private_posts/_content.html.erb +1 -0
  50. data/app/views/thredded/private_posts/_private_post.html.erb +5 -6
  51. data/app/views/thredded/private_posts/edit.html.erb +18 -0
  52. data/app/views/thredded/private_topics/show.html.erb +3 -1
  53. data/app/views/thredded/shared/_nav.html.erb +1 -1
  54. data/app/views/thredded/shared/nav/_standalone.html.erb +1 -1
  55. data/app/views/thredded/topics/_sticky_topics_divider.html.erb +1 -0
  56. data/app/views/thredded/topics/_topic.html.erb +4 -0
  57. data/app/views/thredded/topics/index.html.erb +1 -1
  58. data/app/views/thredded/topics/show.html.erb +1 -1
  59. data/app/views/thredded/users/_post.html.erb +2 -2
  60. data/app/views/thredded/users/_posts.html.erb +1 -1
  61. data/config/locales/en.yml +1 -0
  62. data/config/locales/es.yml +1 -0
  63. data/config/locales/pl.yml +1 -0
  64. data/config/locales/pt-BR.yml +1 -0
  65. data/config/routes.rb +9 -4
  66. data/lib/generators/thredded/install/templates/initializer.rb +7 -0
  67. data/lib/thredded.rb +4 -0
  68. data/lib/thredded/collection_to_strings_with_cache_renderer.rb +62 -0
  69. data/lib/thredded/version.rb +1 -1
  70. metadata +15 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e08209cc4846d358cb9cf977e394ab14e553571
4
- data.tar.gz: dc0b3eb3302a5fd5b9a3d7d01abfcb25af8635a9
3
+ metadata.gz: 584af3429d4903d4e71c2a9c6ade98a1ce121505
4
+ data.tar.gz: 0c4a78eaeb21357be674af2a152bf0e72a35ad9c
5
5
  SHA512:
6
- metadata.gz: 7f14c1568bc33b5264b04c97e1ac8500d2215c6dd5f9e0002fd052baff8e722b7f691960db5ac47f85f45a828988762ba8f4eb09b2eb9a82ec8fa5c78a5c7f18
7
- data.tar.gz: 1e41c3ff6c705a77a5a9856a5c2cb1216d0ccb291796562fd0ca2be87a5a45877e08c7972f39f6c2d2a56ff4c3ffa05f944119d3bf1a78b086a6e400af2d0383
6
+ metadata.gz: 4fca75e1a3052d79bb58f55202add9746e393418a04d5afca1e07cfa95fd90301eaced3f63189493f94639722d1a689f06170e586388a06ba12fadbee65c0a72
7
+ data.tar.gz: 4bb3d36a5fa56b0180e5f73c6c4de8cd5130805e07d0057dabef25d580d1a1de178441b96df0321c8f9c5cd700759a72caf006b7abe7783e51dc2be77fa16501
data/README.md CHANGED
@@ -56,7 +56,7 @@ Then, see the rest of this Readme for more information about using and customizi
56
56
  Add the gem to your Gemfile:
57
57
 
58
58
  ```ruby
59
- gem 'thredded', '~> 0.10.0'
59
+ gem 'thredded', '~> 0.10.1'
60
60
  ```
61
61
 
62
62
  Add the Thredded [initializer] to your parent app by running the install generator.
@@ -105,27 +105,14 @@ rails g thredded:install
105
105
 
106
106
  But then compare this with the previous version to decide what to keep.
107
107
 
108
- 2) To upgrade the database:
109
-
110
- Latest version (in this example from v0.6 to v0.7):
108
+ 2) To upgrade the database (in this example from v0.9 to v0.10):
111
109
 
112
110
  ```console
113
- # Note that for guaranteed best results you will want to run this with the gem checked out with v0.7.0
114
- cp `bundle show thredded`/db/upgrade_migrations/20160723012349_upgrade_v0_6_to_v0_7.rb db/migrate
111
+ # Note that for guaranteed best results you will want to run this with the gem checked out with v0.10.0
112
+ cp `bundle show thredded`/db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb db/migrate
115
113
  rake db:migrate
116
114
  ```
117
115
 
118
-
119
- To upgrade the database (in this example from v0.7 to v0.8):
120
-
121
- ```console
122
- # Note that for guaranteed best results you will want to run this with the gem checked out with v0.8.0.
123
- cp `bundle show thredded`/db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb db/migrate
124
- rake db:migrate
125
- ```
126
-
127
-
128
-
129
116
  ### Migrating from Forem
130
117
 
131
118
  Are you currently using [Forem]? Thredded provides [a migration][forem-to-thredded] to copy all of your existing data from Forem over
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="408px" height="408px" viewBox="0 0 408 408">
2
+ <path d="M204,102c28.05,0,51-22.95,51-51S232.05,0,204,0s-51,22.95-51,51S175.95,102,204,102z M204,153c-28.05,0-51,22.95-51,51 s22.95,51,51,51s51-22.95,51-51S232.05,153,204,153z M204,306c-28.05,0-51,22.95-51,51s22.95,51,51,51s51-22.95,51-51 S232.05,306,204,306z"/>
3
+ </svg>
@@ -8,6 +8,7 @@
8
8
  padding: 0.5rem 0.75rem;
9
9
  border-bottom: $thredded-base-border;
10
10
  vertical-align: middle;
11
+ word-break: break-word;
11
12
  }
12
13
 
13
14
  th {
@@ -31,6 +31,8 @@ $thredded-action-transition: color 0.1s linear !default;
31
31
  $thredded-nav-color: $thredded-text-color !default;
32
32
  $thredded-nav-hover-color: $thredded-action-color !default;
33
33
  $thredded-nav-current-color: $thredded-action-color !default;
34
+ $thredded-overlay-background-color: $thredded-background-color !default;
35
+ $thredded-overlay-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12) !default;
34
36
  $thredded-secondary-nav-color: $thredded-secondary-text-color !default;
35
37
  $thredded-spoiler-hidden-color: $thredded-light-gray !default;
36
38
  $thredded-spoiler-shown-color: black !default;
@@ -85,7 +87,28 @@ $thredded-badge-inactive-color: $thredded-button-color !default;
85
87
  $thredded-badge-inactive-background: rgba($thredded-text-color, 0.3) !default;
86
88
 
87
89
  // Layout features
90
+
91
+ // Messageboards grid
88
92
  // Whether to display messageboards as a grid on the desktop screen sizes.
89
93
  $thredded-messageboards-grid: true !default;
94
+ // Paddings within a grid item
95
+ $thredded-messageboards-grid-item-padding-x: ($thredded-base-spacing * 0.8) !default;
96
+ $thredded-messageboards-grid-item-padding-y: $thredded-base-spacing !default;
97
+ // Spacing between grid items, must be set in the same unit as the border width
98
+ $thredded-messageboards-grid-item-gutter-x: 0 !default;
99
+ $thredded-messageboards-grid-item-gutter-y: 0 !default;
100
+ // The width of the border around a grid item
101
+ $thredded-messageboards-grid-item-border-width: 1px !default;
102
+ $thredded-messageboards-grid-item-border-color:
103
+ // If one of the gutters is 0 the borders will be collapsed by overlap.
104
+ // Ensure their color does not have and alpha component:
105
+ if($thredded-messageboards-grid-item-gutter-x == 0 or $thredded-messageboards-grid-item-gutter-y == 0,
106
+ // Use the closest non-transparent color
107
+ mix(opacify($thredded-base-border-color, 1), $thredded-background-color,
108
+ percentage(alpha($thredded-base-border-color))),
109
+ $thredded-base-border-color) !default;
90
110
  // Minimum width of a grid item
91
- $thredded-messageboards-grid-item-flex-basis: map-get($thredded-grid-breakpoint-max-widths, tablet) / 3 !default;
111
+ $thredded-messageboards-grid-item-flex-basis: 21.5rem !default;
112
+
113
+ // Topics list
114
+ $thredded-topics-list-gutter-y: $thredded-base-spacing !default;
@@ -1,6 +1,7 @@
1
1
  .thredded--currently-online {
2
2
  background-color: $thredded-base-border-color;
3
3
  bottom: -1.25rem;
4
+ box-sizing: content-box;
4
5
  padding: $thredded-base-spacing;
5
6
  position: fixed;
6
7
  right: 0;
@@ -1,16 +1,18 @@
1
1
  .thredded--messageboards-group {
2
+ box-sizing: border-box;
2
3
  margin-bottom: $thredded-base-spacing;
3
4
  }
4
5
 
5
6
  .thredded--messageboard {
6
7
  @extend %thredded--link;
8
+ box-sizing: border-box;
7
9
  display: block;
8
- margin-bottom: 1px;
10
+ margin-bottom: -$thredded-messageboards-grid-item-border-width;
9
11
  padding: $thredded-base-spacing;
10
12
  position: relative;
11
13
 
12
14
  &, &:focus, &:hover, &:active {
13
- outline: 1px solid $thredded-base-border-color;
15
+ border: $thredded-messageboards-grid-item-border-width solid $thredded-messageboards-grid-item-border-color;
14
16
  }
15
17
 
16
18
  &:hover {
@@ -95,13 +97,18 @@
95
97
 
96
98
  @if $thredded-messageboards-grid {
97
99
  @include thredded-media-desktop-and-up {
98
- $item-border-width: 1px;
99
- $item-padding-x: ($thredded-base-spacing * 0.8);
100
- $item-padding-y: $thredded-base-spacing;
100
+ $gutter-x: $thredded-messageboards-grid-item-gutter-x;
101
+ $gutter-y: $thredded-messageboards-grid-item-gutter-y;
102
+ $border-width: $thredded-messageboards-grid-item-border-width;
103
+ // Collapse borders when there is no gutter
104
+ $margin-x: $gutter-x / 2 - if($gutter-x == 0, $border-width / 2, 0);
105
+ $margin-y: $gutter-y / 2 - if($gutter-y == 0, $border-width / 2, 0);
101
106
 
102
107
  %thredded--messageboards-cell-flex {
103
108
  flex-basis: $thredded-messageboards-grid-item-flex-basis;
104
109
  flex-grow: 1;
110
+ margin-left: $margin-x;
111
+ margin-right: $margin-x;
105
112
  }
106
113
 
107
114
  .thredded--messageboards-group {
@@ -109,14 +116,14 @@
109
116
  flex-direction: row;
110
117
  flex-wrap: wrap;
111
118
  justify-content: space-between;
112
- margin-left: $item-border-width;
119
+ margin: (-$margin-y) (-$margin-x);
113
120
 
114
121
  // Size incomplete last rows with up to two missing items.
115
122
  &::after, &::before {
116
123
  @extend %thredded--messageboards-cell-flex;
124
+ box-sizing: border-box;
117
125
  content: "";
118
- margin-right: $item-border-width;
119
- padding: 0 $item-padding-x;
126
+ padding: 0 $thredded-messageboards-grid-item-padding-x;
120
127
  }
121
128
 
122
129
  &::before {
@@ -126,8 +133,9 @@
126
133
 
127
134
  .thredded--messageboard {
128
135
  @extend %thredded--messageboards-cell-flex;
129
- margin-left: 1px;
130
- padding: $item-padding-y $item-padding-x;
136
+ margin-top: $margin-y;
137
+ margin-bottom: $margin-y;
138
+ padding: $thredded-messageboards-grid-item-padding-y $thredded-messageboards-grid-item-padding-x;
131
139
  }
132
140
 
133
141
  }
@@ -6,6 +6,90 @@
6
6
  }
7
7
  }
8
8
 
9
+ .thredded--post--dropdown--toggle {
10
+ fill: currentColor;
11
+ color: $thredded-action-color;
12
+ display: inline-block;
13
+ width: 1rem;
14
+ height: 1rem;
15
+ padding: 0.875rem 0.875rem 0.875rem 1.5rem;
16
+ margin-right: -0.875rem;
17
+ -webkit-tap-highlight-color: transparent;
18
+ }
19
+
20
+ .thredded--post--dropdown {
21
+ position: relative;
22
+ display: inline-block;
23
+ float: right;
24
+ cursor: pointer;
25
+ @media print {
26
+ display: none;
27
+ }
28
+ }
29
+
30
+ .thredded--post--dropdown--actions {
31
+ position: absolute;
32
+ margin-top: -0.875rem;
33
+ right: 0;
34
+ background-color: $thredded-overlay-background-color;
35
+ border-radius: 2px;
36
+ overflow: hidden;
37
+ min-width: 10rem;
38
+ z-index: 1;
39
+ cursor: pointer;
40
+ box-shadow: $thredded-overlay-box-shadow;
41
+ transform: scale(0);
42
+ opacity: 0;
43
+ transform-origin: 100% 0;
44
+ transition: transform .3s cubic-bezier(.4, 0, .2, 1), opacity .2s cubic-bezier(.4, 0, .2, 1);
45
+ will-change: transform;
46
+ }
47
+
48
+ .thredded--post--dropdown--actions--item,
49
+ // This specific selector protects from global button rules
50
+ form.button_to > .thredded--post--dropdown--actions--item {
51
+ // Override potential global rules
52
+ background: none;
53
+ border-radius: 0;
54
+ border: 0;
55
+ box-sizing: border-box;
56
+ font: inherit;
57
+ margin: 0;
58
+ text-align: left;
59
+ transition: none;
60
+ width: 100%;
61
+
62
+ font-size: $thredded-font-size-small;
63
+ color: $thredded-text-color;
64
+ text-decoration: none;
65
+ padding: 1rem 0.75rem;
66
+ display: block;
67
+ white-space: nowrap;
68
+
69
+ &:active,
70
+ &:focus,
71
+ &:hover {
72
+ background-color: $thredded-action-color;
73
+ color: $thredded-background-color;
74
+ text-decoration: none;
75
+ cursor: pointer;
76
+ }
77
+
78
+ &:active,
79
+ &:focus {
80
+ outline: none;
81
+ }
82
+ }
83
+
84
+ .thredded--post--dropdown:hover .thredded--post--dropdown--actions {
85
+ transform: scale(1);
86
+ opacity: 1;
87
+ }
88
+
89
+ .thredded--post--dropdown:hover .thredded--post--dropdown--toggle {
90
+ color: $thredded-action-hover-color;
91
+ }
92
+
9
93
  .thredded--post--avatar {
10
94
  border-radius: 50%;
11
95
  display: inline-block;
@@ -59,19 +143,6 @@
59
143
  display: inline-block;
60
144
  }
61
145
 
62
- .thredded--post--edit,
63
- .thredded--post--delete {
64
- font-size: $thredded-font-size-small;
65
- @extend %thredded--link;
66
- @media print {
67
- display: none;
68
- }
69
- }
70
-
71
- .thredded--post--delete {
72
- margin-left: 0.4rem;
73
- }
74
-
75
146
  .thredded--post--content {
76
147
  font-size: 1.063rem; // 17px
77
148
  line-height: 1.65;
@@ -1,5 +1,5 @@
1
1
  .thredded--topics--topic {
2
- margin-bottom: $thredded-base-spacing;
2
+ margin-bottom: $thredded-topics-list-gutter-y;
3
3
  position: relative;
4
4
 
5
5
  @media (max-width: $thredded-grid-container-max-width) {
@@ -8,7 +8,13 @@
8
8
  @include thredded-media-mobile {
9
9
  margin-right: 2rem;
10
10
  }
11
+ }
11
12
 
13
+ .thredded--topics--sticky-topics-divider {
14
+ margin-top: -$thredded-topics-list-gutter-y / 2;
15
+ margin-bottom: $thredded-topics-list-gutter-y / 2;
16
+ border: 0;
17
+ border-top: $thredded-base-border;
12
18
  }
13
19
 
14
20
  .thredded--topics--title {
@@ -1,6 +1,7 @@
1
1
  .thredded--main-container {
2
2
  @include thredded--clearfix;
3
3
  -webkit-font-smoothing: antialiased;
4
+ box-sizing: content-box;
4
5
  color: $thredded-text-color;
5
6
  font-family: $thredded-base-font-family;
6
7
  font-size: $thredded-base-font-size;
@@ -30,18 +30,15 @@
30
30
  width: auto;
31
31
  padding: 0.9375rem 0.75rem 0.875rem 0.75rem;
32
32
  margin: -1px (-$padding-x) 0 0;
33
- // Webkit adds an extra padding that we need to remove.
34
- -webkit-margin-end: -($padding-x + 0.75rem);
35
33
 
36
34
  &, &:focus {
37
35
  transition: background, border-color, box-shadow, min-width 0.15s ease-out 0s;
38
36
  }
39
37
 
40
- &:focus {
38
+ &:focus, &:not(:placeholder-shown) {
41
39
  background: $thredded-background-color;
42
40
  box-shadow: none;
43
41
  margin-right: 0;
44
- -webkit-margin-end: 0;
45
42
  min-width: 16rem;
46
43
  text-align: left;
47
44
  }
@@ -59,6 +56,16 @@
59
56
  max-height: $line-height;
60
57
  }
61
58
 
59
+ &:placeholder-shown, &:not(:focus) {
60
+ // On Chrome, the search [x] takes up space even when invisible,
61
+ // breaking the placeholder positioning. Remove it:
62
+ &::-webkit-search-cancel-button,
63
+ &::-webkit-search-decoration {
64
+ -webkit-appearance: none;
65
+ margin: 0;
66
+ }
67
+ }
68
+
62
69
  &::placeholder {
63
70
  color: $thredded-secondary-nav-color;
64
71
  transition: $thredded-action-transition;
@@ -70,13 +77,15 @@
70
77
  }
71
78
 
72
79
  &:hover:not(:focus) {
73
- cursor: pointer;
80
+ &:placeholder-shown {
81
+ cursor: pointer;
82
+ }
74
83
  &::placeholder {
75
84
  color: $thredded-nav-hover-color;
76
85
  }
77
86
  }
78
87
 
79
- &:focus {
88
+ &:focus, &:not(:placeholder-shown) {
80
89
  border-color: $thredded-base-border-color;
81
90
  }
82
91
  }
@@ -12,7 +12,7 @@ module Thredded
12
12
  :messageboard,
13
13
  :messageboard_or_nil,
14
14
  :preferences,
15
- :signed_in?
15
+ :thredded_signed_in?
16
16
 
17
17
  rescue_from Thredded::Errors::MessageboardNotFound,
18
18
  Thredded::Errors::PrivateTopicNotFound,
@@ -40,11 +40,14 @@ module Thredded
40
40
 
41
41
  protected
42
42
 
43
+ # The `current_user` and `signed_in?` methods are prefixed with `thredded_`
44
+ # to avoid conflicts with methods from the parent controller.
45
+
43
46
  def thredded_current_user
44
47
  send(Thredded.current_user_method) || NullUser.new
45
48
  end
46
49
 
47
- def signed_in?
50
+ def thredded_signed_in?
48
51
  !thredded_current_user.thredded_anonymous?
49
52
  end
50
53
 
@@ -76,7 +79,7 @@ module Thredded
76
79
  end
77
80
 
78
81
  def update_user_activity
79
- return if !messageboard_or_nil || !signed_in?
82
+ return if !messageboard_or_nil || !thredded_signed_in?
80
83
 
81
84
  Thredded::ActivityUpdaterJob.perform_later(
82
85
  thredded_current_user.id,
@@ -76,7 +76,7 @@ module Thredded
76
76
 
77
77
  def maybe_set_last_moderated_record_flash
78
78
  return unless flash[:last_moderated_record_id]
79
- @last_moderated_record = accessible_post_moderation_records.find(flash[:last_moderated_record_id].to_i)
79
+ @last_moderated_record = accessible_post_moderation_records.find(flash[:last_moderated_record_id].to_s)
80
80
  end
81
81
 
82
82
  def moderatable_posts
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Thredded
3
- # This currently handles both {Post}s and {PrivatePost}s.
4
- # TODO: split up the PrivatePost functionality into a separate controller.
3
+ # A controller for managing {Post}s.
5
4
  class PostsController < Thredded::ApplicationController
6
5
  include ActionView::RecordIdentifier
7
6
 
@@ -37,40 +36,38 @@ module Thredded
37
36
  notice: I18n.t('thredded.posts.deleted_notice')
38
37
  end
39
38
 
39
+ def mark_as_unread
40
+ authorize post, :read?
41
+ page = post.page(user: thredded_current_user)
42
+ post.mark_as_unread(thredded_current_user, page)
43
+ after_mark_as_unread # customization hook
44
+ end
45
+
40
46
  private
41
47
 
48
+ def after_mark_as_unread
49
+ redirect_to messageboard_topics_path(messageboard)
50
+ end
51
+
42
52
  def topic
43
53
  post.postable
44
54
  end
45
55
 
46
56
  def post_params
47
- p = params.require(:post)
57
+ params.require(:post)
48
58
  .permit(:content)
49
- .merge(user: thredded_current_user, ip: request.remote_ip)
50
- p = p.merge(messageboard: messageboard) unless for_a_private_topic?
51
- p
59
+ .merge(user: thredded_current_user, ip: request.remote_ip, messageboard: messageboard)
52
60
  end
53
61
 
54
62
  def parent_topic
55
- if for_a_private_topic?
56
- PrivateTopic
57
- .includes(:private_users)
58
- .friendly
59
- .find(params[:private_topic_id])
60
- else
61
- Topic
62
- .where(messageboard: messageboard)
63
- .friendly
64
- .find(params[:topic_id])
65
- end
66
- end
67
-
68
- def for_a_private_topic?
69
- params[:private_topic_id].present?
63
+ Topic
64
+ .where(messageboard: messageboard)
65
+ .friendly
66
+ .find(params[:topic_id])
70
67
  end
71
68
 
72
69
  def post
73
- @post ||= (for_a_private_topic? ? Thredded::PrivatePost : Thredded::Post).find(params[:id])
70
+ @post ||= Thredded::Post.find(params[:id])
74
71
  end
75
72
 
76
73
  def current_page