thredded 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -12
  3. data/app/assets/images/thredded/follow.svg +1 -0
  4. data/app/assets/images/thredded/unfollow.svg +1 -0
  5. data/app/assets/stylesheets/thredded/_thredded.scss +27 -28
  6. data/app/assets/stylesheets/thredded/components/_alerts.scss +5 -5
  7. data/app/assets/stylesheets/thredded/components/_base.scss +5 -5
  8. data/app/assets/stylesheets/thredded/components/_currently-online.scss +1 -1
  9. data/app/assets/stylesheets/thredded/components/_empty.scss +2 -2
  10. data/app/assets/stylesheets/thredded/components/_flash-message.scss +5 -5
  11. data/app/assets/stylesheets/thredded/components/_following.scss +17 -0
  12. data/app/assets/stylesheets/thredded/components/_form-list.scss +3 -3
  13. data/app/assets/stylesheets/thredded/components/_icons.scss +1 -1
  14. data/app/assets/stylesheets/thredded/components/_main-section.scss +1 -1
  15. data/app/assets/stylesheets/thredded/components/_messageboard.scss +6 -6
  16. data/app/assets/stylesheets/thredded/components/_pagination.scss +1 -1
  17. data/app/assets/stylesheets/thredded/components/_post-form.scss +1 -1
  18. data/app/assets/stylesheets/thredded/components/_post.scss +12 -11
  19. data/app/assets/stylesheets/thredded/components/_preferences.scss +1 -1
  20. data/app/assets/stylesheets/thredded/components/_select2.scss +4 -4
  21. data/app/assets/stylesheets/thredded/components/_topic-delete.scss +4 -8
  22. data/app/assets/stylesheets/thredded/components/_topic-header.scss +25 -11
  23. data/app/assets/stylesheets/thredded/components/_topics.scss +37 -15
  24. data/app/assets/stylesheets/thredded/layout/_main-container.scss +1 -1
  25. data/app/assets/stylesheets/thredded/layout/_main-navigation.scss +2 -2
  26. data/app/assets/stylesheets/thredded/layout/_moderation.scss +16 -15
  27. data/app/assets/stylesheets/thredded/layout/_navigation.scss +6 -6
  28. data/app/assets/stylesheets/thredded/layout/_search-navigation.scss +1 -1
  29. data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +13 -13
  30. data/app/assets/stylesheets/thredded/layout/_user.scss +1 -1
  31. data/app/assets/stylesheets/thredded/utilities/_is-compact.scss +1 -1
  32. data/app/assets/stylesheets/thredded/utilities/_is-expanded.scss +1 -1
  33. data/app/commands/thredded/notify_following_users.rb +1 -1
  34. data/app/controllers/thredded/messageboard_groups_controller.rb +3 -1
  35. data/app/controllers/thredded/messageboards_controller.rb +1 -3
  36. data/app/controllers/thredded/private_topics_controller.rb +1 -1
  37. data/app/controllers/thredded/topics_controller.rb +16 -9
  38. data/app/helpers/thredded/application_helper.rb +36 -0
  39. data/app/models/concerns/thredded/topic_common.rb +2 -2
  40. data/app/models/concerns/thredded/user_topic_read_state_common.rb +1 -1
  41. data/app/models/thredded/messageboard.rb +34 -7
  42. data/app/models/thredded/messageboard_group.rb +8 -1
  43. data/app/models/thredded/null_user.rb +4 -0
  44. data/app/models/thredded/post_moderation_record.rb +1 -1
  45. data/app/models/thredded/private_post.rb +5 -1
  46. data/app/models/thredded/stats.rb +1 -1
  47. data/app/models/thredded/topic.rb +5 -3
  48. data/app/models/thredded/user_detail.rb +2 -0
  49. data/app/models/thredded/user_extender.rb +4 -2
  50. data/app/models/thredded/user_topic_follow.rb +12 -1
  51. data/app/view_models/thredded/base_topic_view.rb +1 -1
  52. data/app/view_models/thredded/messageboard_group_view.rb +11 -0
  53. data/app/view_models/thredded/topic_view.rb +15 -2
  54. data/app/views/thredded/messageboards/_messageboard.html.erb +2 -2
  55. data/app/views/thredded/moderation/_post.html.erb +1 -1
  56. data/app/views/thredded/moderation/_post_moderation_record.html.erb +1 -1
  57. data/app/views/thredded/moderation/user.html.erb +1 -1
  58. data/app/views/thredded/moderation/users.html.erb +1 -1
  59. data/app/views/thredded/private_topic_mailer/message_notification.html.erb +1 -1
  60. data/app/views/thredded/private_topic_mailer/message_notification.text.erb +1 -1
  61. data/app/views/thredded/private_topics/_private_topic.html.erb +1 -1
  62. data/app/views/thredded/shared/_currently_online.html.erb +1 -1
  63. data/app/views/thredded/shared/_nav.html.erb +1 -1
  64. data/app/views/thredded/shared/_page.html.erb +2 -2
  65. data/app/views/thredded/topics/_followers.html.erb +12 -0
  66. data/app/views/thredded/topics/_header.html.erb +10 -9
  67. data/app/views/thredded/topics/_topic.html.erb +13 -2
  68. data/app/views/thredded/topics/index.html.erb +5 -0
  69. data/app/views/thredded/users/_link.html.erb +2 -2
  70. data/config/locales/en.yml +20 -18
  71. data/config/locales/pt-BR.yml +14 -9
  72. data/db/migrate/20160329231848_create_thredded.rb +4 -0
  73. data/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb +1 -1
  74. data/db/upgrade_migrations/20160723012349_upgrade_v0_6_to_v0_7.rb +43 -0
  75. data/lib/generators/thredded/install/templates/initializer.rb +15 -0
  76. data/lib/html/pipeline/at_mention_filter.rb +1 -1
  77. data/lib/thredded.rb +24 -0
  78. data/lib/thredded/database_seeder.rb +15 -5
  79. data/lib/thredded/version.rb +1 -1
  80. metadata +8 -9
  81. data/CHANGELOG.md +0 -399
  82. data/Procfile +0 -1
  83. data/config.ru +0 -3
  84. data/heroku.gemfile +0 -28
  85. data/heroku.gemfile.lock +0 -268
  86. data/thredded.gemspec +0 -78
@@ -1,4 +1,4 @@
1
- &--topic-header {
1
+ .thredded--topic-header {
2
2
  margin-bottom: $thredded-large-spacing;
3
3
  margin-top: $thredded-base-spacing;
4
4
  @include thredded-media-mobile {
@@ -7,14 +7,14 @@
7
7
  }
8
8
  }
9
9
 
10
- &--topic-header--title {
10
+ .thredded--topic-header--title {
11
11
  @extend %thredded--heading;
12
12
  font-size: 1.5rem; // 24px
13
13
  line-height: 1.2;
14
14
  margin-bottom: $thredded-small-spacing / 2;
15
15
  }
16
16
 
17
- &--topic-header--started-by {
17
+ .thredded--topic-header--started-by {
18
18
  font-size: $thredded-font-size-small;
19
19
  color: $thredded-secondary-text-color;
20
20
  font-style: normal;
@@ -23,20 +23,16 @@
23
23
  }
24
24
  }
25
25
 
26
- &--topic-header--edit-topic {
26
+ .thredded--topic-header--edit-topic {
27
27
  @extend %thredded--link;
28
28
  font-size: $thredded-font-size-small;
29
29
  margin-left: 0.4rem;
30
30
  }
31
- &--topic-follow-info {
31
+
32
+ .thredded--topic-header--follow-info {
32
33
  float: right;
33
34
  color: $thredded-secondary-text-color;
34
- &.thredded--following {
35
- font-size: 0.65rem;
36
- }
37
- &.thredded--notfollowing {
38
- font-size: $thredded-font-size-small;
39
- }
35
+ font-size: $thredded-font-size-small;
40
36
  font-style: normal;
41
37
  max-width: 60%;
42
38
  text-align: right;
@@ -55,3 +51,21 @@
55
51
  }
56
52
  }
57
53
  }
54
+
55
+ .thredded--topic-following {
56
+ .thredded--topic-header--follow-info {
57
+ position: relative;
58
+ }
59
+ .thredded--topic-header--follow-icon {
60
+ @extend %thredded--following-icon;
61
+ }
62
+ }
63
+
64
+ .thredded--topic-followers {
65
+ font-size: $thredded-font-size-small;
66
+ color: $thredded-secondary-text-color;
67
+ }
68
+
69
+ .thredded--svg-definitions {
70
+ display: none;
71
+ }
@@ -1,4 +1,4 @@
1
- &--topics--topic {
1
+ .thredded--topics--topic {
2
2
  margin-bottom: $thredded-base-spacing;
3
3
  position: relative;
4
4
 
@@ -7,7 +7,7 @@
7
7
  }
8
8
  }
9
9
 
10
- &--topics--title {
10
+ .thredded--topics--title {
11
11
  @extend %thredded--heading;
12
12
  display: inline;
13
13
  font-size: 1.125rem; // 18px
@@ -24,7 +24,7 @@
24
24
  }
25
25
  }
26
26
 
27
- &--topics--categories {
27
+ .thredded--topics--categories {
28
28
  list-style-type: none;
29
29
  margin: 0;
30
30
  padding: 0;
@@ -45,8 +45,8 @@
45
45
  }
46
46
  }
47
47
 
48
- &--topics--started-by,
49
- &--topics--updated-by {
48
+ .thredded--topics--started-by,
49
+ .thredded--topics--updated-by {
50
50
  color: $thredded-secondary-text-color;
51
51
  font-size: $thredded-font-size-small;
52
52
  font-style: normal;
@@ -68,7 +68,7 @@
68
68
  }
69
69
  }
70
70
 
71
- &--topics--updated-by {
71
+ .thredded--topics--updated-by {
72
72
  margin-right: $thredded-small-spacing;
73
73
 
74
74
  abbr {
@@ -78,7 +78,7 @@
78
78
  }
79
79
  }
80
80
 
81
- &--topics--started-by {
81
+ .thredded--topics--started-by {
82
82
  display: none;
83
83
 
84
84
  abbr {
@@ -88,13 +88,13 @@
88
88
  }
89
89
  }
90
90
 
91
- &--topics--moderation-state {
91
+ .thredded--topics--moderation-state {
92
92
  padding: 0.3em 0.5em;
93
93
  font-size: $thredded-font-size-small;
94
94
  font-style: normal;
95
95
  }
96
96
 
97
- &--topics--posts-count {
97
+ .thredded--topics--posts-count {
98
98
  border-radius: 50%;
99
99
  display: inline-block;
100
100
  font-weight: 900;
@@ -110,12 +110,34 @@
110
110
  transition: background 0.1s linear, color 0.1s linear;
111
111
  }
112
112
 
113
- &--topic-unread > &--topics--posts-count {
114
- background: $thredded-badge-active-background;
115
- color: $thredded-badge-active-color;
113
+ .thredded--topic-read {
114
+ > .thredded--topics--title a {
115
+ font-weight: lighter;
116
+ }
117
+ > .thredded--topics--posts-count {
118
+ background: $thredded-badge-inactive-background;
119
+ color: $thredded-badge-inactive-color;
120
+ }
121
+ }
122
+
123
+ .thredded--topic-unread {
124
+ > .thredded--topics--title a {
125
+ font-weight: bold;
126
+ }
127
+ > .thredded--topics--posts-count {
128
+ background: $thredded-badge-active-background;
129
+ color: $thredded-badge-active-color;
130
+ }
116
131
  }
117
132
 
118
- &--topic-read > &--topics--posts-count {
119
- background: $thredded-badge-inactive-background;
120
- color: $thredded-badge-inactive-color;
133
+ .thredded--topic-following {
134
+ .thredded--topics--follow-icon {
135
+ @extend %thredded--following-icon;
136
+ }
137
+ }
138
+
139
+ .thredded--topic-notfollowing {
140
+ .thredded--topics--follow-icon {
141
+ @extend %thredded--not-following-icon;
142
+ }
121
143
  }
@@ -1,4 +1,4 @@
1
- &--main-container {
1
+ .thredded--main-container {
2
2
  @include thredded--clearfix;
3
3
  -webkit-font-smoothing: antialiased;
4
4
  color: $thredded-text-color;
@@ -1,4 +1,4 @@
1
- &--main-navigation {
1
+ .thredded--main-navigation {
2
2
  @extend %thredded--list-unstyled;
3
3
  @include thredded--clearfix;
4
4
  display: block;
@@ -7,7 +7,7 @@
7
7
  }
8
8
  }
9
9
 
10
- &--navigation-breadcrumbs {
10
+ .thredded--navigation-breadcrumbs {
11
11
  @extend %thredded--list-unstyled;
12
12
 
13
13
  li {
@@ -1,4 +1,4 @@
1
- &--moderation-navigation {
1
+ .thredded--moderation-navigation {
2
2
  position: relative;
3
3
  &--items {
4
4
  @extend %thredded--nav-tabs;
@@ -8,31 +8,32 @@
8
8
  }
9
9
  }
10
10
 
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
- .thredded--moderation-activity &--moderation-navigation--activity {
11
+ .thredded--pending-moderation .thredded--moderation-navigation--pending,
12
+ .thredded--moderation-history .thredded--moderation-navigation--history,
13
+ .thredded--moderation-users .thredded--moderation-navigation--users,
14
+ .thredded--moderation-user .thredded--moderation-navigation--users,
15
+ .thredded--moderation-activity .thredded--moderation-navigation--activity {
16
16
  @extend %thredded--nav-tabs--item-current;
17
17
  }
18
18
 
19
- &--post-moderation-actions {
19
+ .thredded--post-moderation-actions {
20
20
  @extend %thredded--buttons-list;
21
21
  }
22
22
 
23
- &--moderated-notice {
23
+ .thredded--moderated-notice {
24
24
  margin-bottom: $thredded-base-spacing;
25
25
  padding: $thredded-small-spacing $thredded-base-spacing;
26
26
  background: $thredded-light-gray;
27
27
  }
28
28
 
29
- &--post-moderation, &--post-moderation-record {
29
+ .thredded--post-moderation,
30
+ .thredded--post-moderation-record {
30
31
  .thredded--post--user a {
31
32
  color: $thredded-action-color;
32
33
  }
33
34
  }
34
35
 
35
- &--post-moderation-record {
36
+ .thredded--post-moderation-record {
36
37
  .thredded--post {
37
38
  margin-bottom: 0;
38
39
  margin-left: 1rem;
@@ -60,26 +61,26 @@
60
61
  }
61
62
  }
62
63
 
63
- &--post-moderation-record + &--post-moderation-record {
64
+ .thredded--post-moderation-record + .thredded--post-moderation-record {
64
65
  margin-top: $thredded-large-spacing;
65
66
  }
66
67
 
67
- &--moderation--users-table {
68
+ .thredded--moderation--users-table {
68
69
  width: 100%;
69
70
  a {
70
71
  display: block;
71
72
  }
72
73
  }
73
74
 
74
- &--moderation--user--title {
75
+ .thredded--moderation--user--title {
75
76
  margin: 0;
76
77
  }
77
78
 
78
- &--moderation--user--info {
79
+ .thredded--moderation--user--info {
79
80
  margin-left: 2rem;
80
81
  }
81
82
 
82
- &--user--moderation-actions {
83
+ .thredded--user--moderation-actions {
83
84
  text-align: left;
84
85
  margin-left: 4rem;
85
86
  .button_to {
@@ -1,4 +1,4 @@
1
- &--navigation {
1
+ .thredded--navigation {
2
2
  margin-bottom: $thredded-small-spacing;
3
3
  position: relative;
4
4
  .thredded--icon {
@@ -8,23 +8,23 @@
8
8
 
9
9
  @include thredded-media-tablet-and-down {
10
10
  $icon-nav-item-width: 2.625rem;
11
- &--navigation {
11
+ .thredded--navigation {
12
12
  display: table;
13
13
  position: relative;
14
14
  width: 100%;
15
15
  }
16
- &--main-navigation {
16
+ .thredded--main-navigation {
17
17
  position: relative;
18
18
  border: none;
19
19
  }
20
- &--navigation-breadcrumbs {
20
+ .thredded--navigation-breadcrumbs {
21
21
  font-size: $thredded-font-size-small;
22
22
  padding-right: $icon-nav-item-width * 2;
23
23
  .thredded--is-moderator & {
24
24
  padding-right: $icon-nav-item-width * 3;
25
25
  }
26
26
  }
27
- &--navigation--search-topics {
27
+ .thredded--navigation--search-topics {
28
28
  display: none;
29
29
  .thredded--messageboards-index &,
30
30
  .thredded--topics-index &,
@@ -32,7 +32,7 @@
32
32
  display: block;
33
33
  }
34
34
  }
35
- &--user-navigation {
35
+ .thredded--user-navigation {
36
36
  display: table-footer-group;
37
37
  &-standalone {
38
38
  display: block;
@@ -1,4 +1,4 @@
1
- &--navigation--search {
1
+ .thredded--navigation--search {
2
2
  margin-right: 0;
3
3
  padding: 0;
4
4
  position: absolute;
@@ -1,24 +1,24 @@
1
- &--user-navigation {
1
+ .thredded--user-navigation {
2
2
  @extend %thredded--nav-tabs;
3
3
  }
4
4
 
5
- &--user-navigation--item {
5
+ .thredded--user-navigation--item {
6
6
  @extend %thredded--nav-tabs--item;
7
7
  }
8
8
 
9
- .thredded--preferences &--user-navigation--settings,
10
- .thredded--new-private-topic &--user-navigation--private-topics,
11
- .thredded--private-topics-index &--user-navigation--private-topics,
12
- .thredded--private-topic-show &--user-navigation--private-topics,
13
- .thredded--pending-moderation &--user-navigation--moderation,
14
- .thredded--moderation-history &--user-navigation--moderation,
15
- .thredded--moderation-users &--user-navigation--moderation,
16
- .thredded--moderation-user &--user-navigation--moderation,
17
- .thredded--moderation-activity &--user-navigation--moderation {
9
+ .thredded--preferences .thredded--user-navigation--settings,
10
+ .thredded--new-private-topic .thredded--user-navigation--private-topics,
11
+ .thredded--private-topics-index .thredded--user-navigation--private-topics,
12
+ .thredded--private-topic-show .thredded--user-navigation--private-topics,
13
+ .thredded--pending-moderation .thredded--user-navigation--moderation,
14
+ .thredded--moderation-history .thredded--user-navigation--moderation,
15
+ .thredded--moderation-users .thredded--user-navigation--moderation,
16
+ .thredded--moderation-user .thredded--user-navigation--moderation,
17
+ .thredded--moderation-activity .thredded--user-navigation--moderation {
18
18
  @extend %thredded--nav-tabs--item-current;
19
19
  }
20
20
 
21
- &--user-navigation--private-topics--unread,
22
- &--user-navigation--moderation--pending-count {
21
+ .thredded--user-navigation--private-topics--unread,
22
+ .thredded--user-navigation--moderation--pending-count {
23
23
  @extend %thredded--nav-tabs--item--badge;
24
24
  }
@@ -1,4 +1,4 @@
1
- &--user--avatar {
1
+ .thredded--user--avatar {
2
2
  border-radius: 50%;
3
3
  display: inline-block;
4
4
  height: 1.75em;
@@ -1,4 +1,4 @@
1
- &--is-compact {
1
+ .thredded--is-compact {
2
2
 
3
3
  input[type="submit"],
4
4
  label {
@@ -1,4 +1,4 @@
1
- &--is-expanded {
1
+ .thredded--is-expanded {
2
2
  label {
3
3
  height: auto;
4
4
  margin-bottom: $thredded-small-spacing / 2;
@@ -12,7 +12,7 @@ module Thredded
12
12
  end
13
13
 
14
14
  def targeted_users
15
- @targeted_users ||= @post.postable.following_users.reject { |u| u == @post.user }
15
+ @targeted_users ||= @post.postable.followers.reject { |u| u == @post.user }
16
16
  end
17
17
  end
18
18
  end
@@ -12,8 +12,10 @@ module Thredded
12
12
  authorize @messageboard_group, :create?
13
13
 
14
14
  if @messageboard_group.save
15
- redirect_to root_path, notice: I18n.t('thredded.messageboard_group.created_notice')
15
+ redirect_to root_path, notice: I18n.t('thredded.messageboard_group.saved', name: @messageboard_group.name)
16
16
  else
17
+ flash.now[:notice] = @messageboard_group.errors.full_messages.to_sentence
18
+
17
19
  render action: :new
18
20
  end
19
21
  end
@@ -7,9 +7,7 @@ module Thredded
7
7
  after_action :verify_policy_scoped, except: %i(new create edit update)
8
8
 
9
9
  def index
10
- @groups = policy_scope(Messageboard.all)
11
- .preload(:group, last_topic: [:last_user]).group_by(&:group)
12
- .map { |(group, messageboards)| MessageboardGroupView.new(group, messageboards) }
10
+ @groups = MessageboardGroupView.grouped(policy_scope(Messageboard.all))
13
11
  end
14
12
 
15
13
  def new
@@ -11,7 +11,7 @@ module Thredded
11
11
  PrivateTopic
12
12
  .distinct
13
13
  .for_user(thredded_current_user)
14
- .order_recently_updated_first
14
+ .order_recently_posted_first
15
15
  .includes(:last_user, :user)
16
16
  .page(params[:page])
17
17
  )
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require_dependency 'thredded/posts_page_view'
3
3
  require_dependency 'thredded/topics_page_view'
4
+ # rubocop:disable Metrics/ClassLength
4
5
  module Thredded
5
6
  class TopicsController < Thredded::ApplicationController
6
7
  before_action :thredded_require_login!,
@@ -16,7 +17,7 @@ module Thredded
16
17
  @topics = Thredded::TopicsPageView.new(
17
18
  thredded_current_user,
18
19
  policy_scope(messageboard.topics)
19
- .order_sticky_first.order_recently_updated_first
20
+ .order_sticky_first.order_recently_posted_first
20
21
  .includes(:categories, :last_user, :user)
21
22
  .page(current_page)
22
23
  )
@@ -52,7 +53,7 @@ module Thredded
52
53
  thredded_current_user,
53
54
  topics_scope
54
55
  .search_query(@query)
55
- .order_recently_updated_first
56
+ .order_recently_posted_first
56
57
  .includes(:categories, :last_user, :user)
57
58
  .page(current_page)
58
59
  )
@@ -70,7 +71,7 @@ module Thredded
70
71
  thredded_current_user,
71
72
  policy_scope(@category.topics)
72
73
  .unstuck
73
- .order_recently_updated_first
74
+ .order_recently_posted_first
74
75
  .page(current_page)
75
76
  )
76
77
  render :index
@@ -110,20 +111,25 @@ module Thredded
110
111
  def follow
111
112
  authorize topic, :read?
112
113
  UserTopicFollow.create_unless_exists(thredded_current_user.id, topic.id)
113
- redirect_to messageboard_topic_url(messageboard, topic),
114
- notice: t('thredded.topics.followed_notice')
114
+ follow_change_response(following: true)
115
115
  end
116
116
 
117
117
  def unfollow
118
118
  authorize topic, :read?
119
- follow = thredded_current_user.following?(topic)
120
- follow.destroy if follow
121
- redirect_to messageboard_topic_url(messageboard, topic),
122
- notice: t('thredded.topics.unfollowed_notice')
119
+ UserTopicFollow.find_by(topic_id: topic.id, user_id: thredded_current_user.id).try(:destroy)
120
+ follow_change_response(following: false)
123
121
  end
124
122
 
125
123
  private
126
124
 
125
+ def follow_change_response(following:)
126
+ notice = following ? t('thredded.topics.followed_notice') : t('thredded.topics.unfollowed_notice')
127
+ respond_to do |format|
128
+ format.html { redirect_to messageboard_topic_url(messageboard, topic), notice: notice }
129
+ format.json { render(json: { follow: following }) }
130
+ end
131
+ end
132
+
127
133
  def topic
128
134
  @topic ||= messageboard.topics.find_by_slug!(params[:id])
129
135
  end
@@ -150,3 +156,4 @@ module Thredded
150
156
  end
151
157
  end
152
158
  end
159
+ # rubocop:enable Metrics/ClassLength