thredded 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ class UpgradeV05ToV06 < ActiveRecord::Migration
3
+ def up
4
+ add_column :thredded_messageboards, :last_topic_id, :integer
5
+ Thredded::Messageboard.reset_column_information
6
+ Thredded::Messageboard.all.each do |messageboard|
7
+ messageboard.update!(last_topic_id: messageboard.topics.order_recently_updated_first.first.try(:id))
8
+ end
9
+ change_column_null :thredded_posts, :postable_id, false
10
+ # Allow null on user_id and last_user_id because users can get deleted.
11
+ change_column_null :thredded_topics, :user_id, true
12
+ change_column_null :thredded_topics, :last_user_id, true
13
+ change_column_null :thredded_private_topics, :user_id, true
14
+ change_column_null :thredded_private_topics, :last_user_id, true
15
+ end
16
+
17
+ def down
18
+ change_column_null :thredded_private_topics, :last_user_id, false
19
+ change_column_null :thredded_private_topics, :user_id, false
20
+ change_column_null :thredded_topics, :last_user_id, false
21
+ change_column_null :thredded_topics, :user_id, false
22
+ change_column_null :thredded_posts, :postable_id, true
23
+ remove_column :thredded_messageboards, :last_topic_id
24
+ end
25
+ end
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- thredded (0.5.1)
12
+ thredded (0.6.0)
13
13
  active_record_union (>= 1.1.1)
14
14
  autoprefixer-rails
15
15
  autosize-rails
@@ -208,7 +208,7 @@ GEM
208
208
  method_source
209
209
  rake (>= 0.8.7)
210
210
  thor (>= 0.18.1, < 2.0)
211
- rake (11.1.2)
211
+ rake (11.2.2)
212
212
  rb-gravatar (1.0.5)
213
213
  ref (2.0.0)
214
214
  request_store (1.3.1)
@@ -75,15 +75,27 @@ module Thredded
75
75
  # @param user [Thredded.user_class]
76
76
  # @return [String] path to the user evaluated in the specified context.
77
77
  def self.user_path(view_context, user)
78
- if @@user_path.respond_to? :call
79
- view_context.instance_exec(user, &@@user_path)
80
- else
81
- '/'
82
- end
78
+ view_context.instance_exec(user, &@@user_path)
83
79
  end
84
80
 
85
81
  # Whether the layout is a thredded layout as opposed to the application layout.
86
82
  def self.standalone_layout?
87
83
  layout.is_a?(String) && layout.start_with?('thredded/')
88
84
  end
85
+
86
+ # Returns a view for the given posts' scope, applying read permission filters to the scope.
87
+ # Can be used in main_app, e.g. for showing the recent user posts on the profile page.
88
+ #
89
+ # @param scope [ActiveRecord::Relation<Thredded::Post>] the posts scope for which to return the view.
90
+ # @param current_user [Thredded.user_class, nil] the user viewing the posts.
91
+ # @return [PostsPageView]
92
+ def self.posts_page_view(scope:, current_user:)
93
+ current_user ||= Thredded::NullUser.new
94
+ PostsPageView.new(
95
+ current_user,
96
+ Pundit.policy_scope!(current_user, scope)
97
+ .where(messageboard_id: Pundit.policy_scope!(current_user, Thredded::Messageboard.all).pluck(:id))
98
+ .includes(:postable)
99
+ )
100
+ end
89
101
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Thredded
3
- VERSION = '0.5.1'
3
+ VERSION = '0.6.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Oliveira
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-10 00:00:00.000000000 Z
12
+ date: 2016-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bbcoder
@@ -675,6 +675,7 @@ files:
675
675
  - app/assets/stylesheets/thredded/layout/_navigation.scss
676
676
  - app/assets/stylesheets/thredded/layout/_search-navigation.scss
677
677
  - app/assets/stylesheets/thredded/layout/_user-navigation.scss
678
+ - app/assets/stylesheets/thredded/layout/_user.scss
678
679
  - app/assets/stylesheets/thredded/utilities/_is-compact.scss
679
680
  - app/assets/stylesheets/thredded/utilities/_is-expanded.scss
680
681
  - app/commands/thredded/at_notification_extractor.rb
@@ -780,11 +781,17 @@ files:
780
781
  - app/views/thredded/messageboards/edit.html.erb
781
782
  - app/views/thredded/messageboards/index.html.erb
782
783
  - app/views/thredded/messageboards/new.html.erb
784
+ - app/views/thredded/moderation/_nav.html.erb
783
785
  - app/views/thredded/moderation/_post.html.erb
784
786
  - app/views/thredded/moderation/_post_moderation_actions.html.erb
785
787
  - app/views/thredded/moderation/_post_moderation_record.html.erb
788
+ - app/views/thredded/moderation/_user_moderation_state.html.erb
789
+ - app/views/thredded/moderation/_user_post.html.erb
790
+ - app/views/thredded/moderation/_users_search_form.html.erb
786
791
  - app/views/thredded/moderation/history.html.erb
787
792
  - app/views/thredded/moderation/pending.html.erb
793
+ - app/views/thredded/moderation/user.html.erb
794
+ - app/views/thredded/moderation/users.html.erb
788
795
  - app/views/thredded/post_mailer/post_notification.html.erb
789
796
  - app/views/thredded/post_mailer/post_notification.text.erb
790
797
  - app/views/thredded/posts/_form.html.erb
@@ -795,6 +802,8 @@ files:
795
802
  - app/views/thredded/posts_common/_content.html.erb
796
803
  - app/views/thredded/posts_common/_form.html.erb
797
804
  - app/views/thredded/posts_common/_header.html.erb
805
+ - app/views/thredded/posts_common/_header_with_topic.html.erb
806
+ - app/views/thredded/posts_common/_header_with_user_and_topic.html.erb
798
807
  - app/views/thredded/posts_common/form/_after_content.html.erb
799
808
  - app/views/thredded/posts_common/form/_before_content.html.erb
800
809
  - app/views/thredded/posts_common/form/_content_field.html.erb
@@ -816,6 +825,7 @@ files:
816
825
  - app/views/thredded/private_topics/show.html.erb
817
826
  - app/views/thredded/search/_form.html.erb
818
827
  - app/views/thredded/shared/_breadcrumbs.html.erb
828
+ - app/views/thredded/shared/_content_moderation_blocked_state.html.erb
819
829
  - app/views/thredded/shared/_currently_online.html.erb
820
830
  - app/views/thredded/shared/_flash_messages.html.erb
821
831
  - app/views/thredded/shared/_header.html.erb
@@ -838,6 +848,8 @@ files:
838
848
  - app/views/thredded/topics/search.html.erb
839
849
  - app/views/thredded/topics/show.html.erb
840
850
  - app/views/thredded/users/_link.html.erb
851
+ - app/views/thredded/users/_post.html.erb
852
+ - app/views/thredded/users/_posts.html.erb
841
853
  - bin/rails
842
854
  - config.ru
843
855
  - config/i18n-tasks.yml
@@ -849,6 +861,7 @@ files:
849
861
  - db/upgrade_migrations/20160410111522_upgrade_v0_2_to_v0_3.rb
850
862
  - db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb
851
863
  - db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb
864
+ - db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb
852
865
  - heroku.gemfile
853
866
  - heroku.gemfile.lock
854
867
  - lib/generators/thredded/install/USAGE