thredded-workgroup 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +42 -25
  4. data/.travis.yml +9 -8
  5. data/CHANGELOG.md +11 -0
  6. data/Gemfile +1 -1
  7. data/README.md +7 -6
  8. data/app/controllers/concerns/thredded/workgroup/application_controller_retaining.rb +19 -0
  9. data/app/controllers/concerns/thredded/workgroup/posts_controller_which_redirects.rb +48 -0
  10. data/app/view_hooks/thredded/workgroup/view_hooks.rb +2 -5
  11. data/app/view_models/thredded/workgroup/paginator.rb +41 -0
  12. data/app/view_models/thredded/workgroup/topics_page_view_with_last_post.rb +13 -0
  13. data/app/views/thredded/workgroup/topics/_topics_with_last_post.html.erb +2 -2
  14. data/bin/rubocop +29 -0
  15. data/lib/overrides/thredded/all_view_hooks_override.rb +5 -0
  16. data/lib/overrides/thredded/application_controller_override.rb +8 -0
  17. data/lib/overrides/thredded/posts_controller_override.rb +5 -0
  18. data/lib/overrides/thredded/topic_view_override.rb +29 -0
  19. data/lib/overrides/thredded/topics_page_view_override.rb +5 -0
  20. data/lib/thredded/workgroup/engine.rb +9 -6
  21. data/lib/thredded/workgroup/version.rb +1 -1
  22. data/shared.gemfile +3 -1
  23. metadata +13 -12
  24. data/app/controllers/thredded/application_controller.rb +0 -23
  25. data/app/controllers/thredded/posts_controller.rb +0 -51
  26. data/app/helpers/thredded/application_helper.rb +0 -10
  27. data/app/helpers/thredded/workgroup/application_helper.rb +0 -8
  28. data/app/view_hooks/thredded/all_view_hooks.rb +0 -9
  29. data/app/view_models/thredded/topic_view.rb +0 -32
  30. data/app/view_models/thredded/topics_page_view.rb +0 -16
  31. data/lib/thredded/workgroup/route_delegator.rb +0 -25
  32. data/lib/thredded/workgroup/thredded_route_delegator.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5efefc1d7010c94166f28b7c5eef2f1068aed1e7695b7b322e39a51456b6b46b
4
- data.tar.gz: 7557fd4b245b16ccabfc6e2c1bacd5d93e2688ba222ddb424330774cbe38d9a8
3
+ metadata.gz: 5a4b87b36c16619b50e64a3279c978938cc4656be82573b6b86b65e3fec7ea9c
4
+ data.tar.gz: 531f7e1814b3f671b74040ab78002da8ce237c948fe9a6ad89162339fa1aa510
5
5
  SHA512:
6
- metadata.gz: b7c4da998f27f48915f3cc3c55fb85d34f62d754d9adb14e579faa9a88cf24b5932a2d270521955968a8557e3bb33f573f9f75f8fadce867248040a699075ec5
7
- data.tar.gz: 4f596f4e2fe49ac827056557a7ec902f7686684ccde0db38c21470726118d12d6ecada6d0857e8906aaad26f00e66c59c4e29a8775b8aef21f726579c5de5342
6
+ metadata.gz: a60532df9ba718818df6a18903cef78f3b9d269c36ba361296d57db7b13ff5a6de2297961855f98507e4ae00a5672ed22a4f4e784688efe9af560e029d1a6971
7
+ data.tar.gz: 1dff132aea3c5179bb706327d4f4c6f988492d6a197ba4045778e75f89cb83de73eacaa8fdc7e0915e6a5f81eb505510d0c01026ec9812009fcd689bef1df1a5
data/.gitignore CHANGED
@@ -8,6 +8,8 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ /node_modules
12
+ yarn.lock
11
13
  log/*.log
12
14
  spec/dummy/db/*.sqlite3
13
15
  spec/dummy/log/*.log
data/.rubocop.yml CHANGED
@@ -15,6 +15,15 @@ AllCops:
15
15
  CacheRootDirectory: tmp # ie. tmp/rubocop_cache
16
16
  UseCache: true
17
17
 
18
+ Layout/EndAlignment:
19
+ AutoCorrect: true
20
+
21
+ Layout/LineLength:
22
+ Max: 120
23
+
24
+ Layout/MultilineMethodCallIndentation:
25
+ EnforcedStyle: indented
26
+
18
27
  Metrics/AbcSize:
19
28
  Enabled: false
20
29
 
@@ -22,10 +31,23 @@ Metrics/ClassLength:
22
31
  Max: 125
23
32
 
24
33
  Metrics/BlockLength:
34
+ CountComments: false # count full line comments?
35
+ IgnoredMethods:
36
+ - 'context'
37
+ - 'configure'
38
+ - 'describe'
39
+ - 'namespace'
40
+ - 'shared_examples_for'
41
+ - 'shared_examples'
42
+ - 'pending'
43
+ - 'shared_context'
44
+ - 'xcontext'
45
+ - 'xdescribe'
46
+ - 'it'
25
47
  Exclude:
26
- - 'spec/factories/*'
27
- Layout/LineLength:
28
- Max: 120
48
+ - 'db/schema.rb'
49
+ - 'spec/factories/**/*'
50
+ - '*.gemspec'
29
51
 
30
52
  Metrics/MethodLength:
31
53
  Max: 25
@@ -37,19 +59,29 @@ Metrics/ModuleLength:
37
59
  Metrics/PerceivedComplexity:
38
60
  Enabled: false
39
61
 
62
+ Naming/PredicateName:
63
+ Exclude:
64
+ - spec/**/*.rb
65
+
66
+ Rails:
67
+ Enabled: true
68
+
69
+ Rails/Date:
70
+ EnforcedStyle: strict
71
+
72
+ Rails/FindBy:
73
+ Enabled: true
74
+ Include:
75
+ - app/commands/**/*.rb
76
+ - app/models/**/*.rb
77
+ - app/view_models/**/*.rb
78
+
40
79
  Style/CollectionMethods:
41
80
  Enabled: true
42
81
 
43
82
  Style/Documentation:
44
83
  Enabled: false
45
84
 
46
- Layout/MultilineMethodCallIndentation:
47
- EnforcedStyle: indented
48
-
49
- Naming/PredicateName:
50
- Exclude:
51
- - spec/**/*.rb
52
-
53
85
  Style/SignalException:
54
86
  EnforcedStyle: semantic
55
87
 
@@ -65,18 +97,3 @@ Style/TrailingCommaInHashLiteral:
65
97
  Style/TrailingCommaInArguments:
66
98
  Enabled: false
67
99
 
68
- Rails:
69
- Enabled: true
70
-
71
- Rails/Date:
72
- EnforcedStyle: strict
73
-
74
- Rails/FindBy:
75
- Enabled: true
76
- Include:
77
- - app/commands/**/*.rb
78
- - app/models/**/*.rb
79
- - app/view_models/**/*.rb
80
-
81
- Layout/EndAlignment:
82
- AutoCorrect: true
data/.travis.yml CHANGED
@@ -2,11 +2,9 @@ dist: bionic
2
2
 
3
3
  language: ruby
4
4
  rvm:
5
- - 2.6
5
+ - 2.7
6
6
  cache: bundler
7
7
  bundler_args: --path ../../vendor/bundle --without debug
8
- gemfile:
9
- - spec/gemfiles/rails_5_2.gemfile
10
8
 
11
9
  jobs:
12
10
  fast_finish: true
@@ -14,21 +12,24 @@ jobs:
14
12
  - env: DB=sqlite3 DBC_VERBOSE=true
15
13
  include:
16
14
  - name: audit
17
- gemfile: spec/gemfiles/rails_5_2.gemfile
15
+ gemfile: spec/gemfiles/rails_6_0.gemfile
18
16
  before_script: ""
19
17
  script:
20
18
  - bundle show rubocop
21
19
  - bundle exec rubocop
22
20
  - cp $BUNDLE_GEMFILE Gemfile.lock
23
21
  - bundle exec bundle-audit check --update -v
24
- - gemfile: spec/gemfiles/rails_5_2.gemfile
25
- rvm: 2.6
22
+ - gemfile: spec/gemfiles/rails_6_0.gemfile
23
+ rvm: 2.7
26
24
  env: DB=postgresql DB_USERNAME=postgres DB_PASSWORD=""
27
25
  services: postgresql
28
- - gemfile: spec/gemfiles/rails_5_2.gemfile
29
- rvm: 2.6
26
+ - gemfile: spec/gemfiles/rails_6_0.gemfile
27
+ rvm: 2.7
30
28
  env: DB=sqlite3 DBC_VERBOSE=true
31
29
 
30
+ env:
31
+ global:
32
+ - THREDDED_TESTAPP_SPROCKETS_JS=1
32
33
 
33
34
  before_script:
34
35
  - RAILS_ENV=test bundle exec rake db:create db:migrate
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # v0.4.1
2
+
3
+ * Fix for a bug with pagination
4
+
5
+ # v0.4.0
6
+
7
+ This version supports:
8
+
9
+ * thredded v1.0 +
10
+ * rails 6.0 (with zeitwerk)
11
+
1
12
  # v0.3.0, v0.3.1
2
13
 
3
14
  This version supports:
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  # if you switch rails version gemfile:
6
6
  # bundle update rails json rails-i18n
7
- eval_gemfile File.expand_path("spec/gemfiles/rails_5_2.gemfile", File.dirname(__FILE__))
7
+ eval_gemfile File.expand_path("spec/gemfiles/rails_6_0.gemfile", File.dirname(__FILE__))
data/README.md CHANGED
@@ -38,7 +38,7 @@ So you need to include jquery and its ujs file, for example in your Gemfile:
38
38
  gem "jquery-rails"
39
39
  ```
40
40
 
41
- __NB: (see below for using master vs a released version)__
41
+ __NB: (see below for using main branch vs a released version)__
42
42
 
43
43
  And then execute:
44
44
 
@@ -89,15 +89,16 @@ To see the extra view hooks provided by Thredded::Workgroup (with their argument
89
89
  ```bash
90
90
  grep view_hooks -R --include '*.html.erb' "$(bundle show thredded-workgroup)"
91
91
  ```
92
- ## Master vs Released versions
93
92
 
94
- NB: if you are using the master version rather than a release version
93
+ ## Main vs Released versions
94
+
95
+ NB: if you are using the main branch rather than a release version
95
96
  (and as no release has been made yet you must be! :) ) then you may well need
96
- also to use the latest master release of thredded. So your gem file may need to say:
97
+ also to use the latest main branch of thredded. So your gem file may need to say:
97
98
 
98
99
  ```ruby
99
- gem 'thredded', github: 'thredded/thredded', branch: 'master'
100
- gem 'thredded-workgroup', github: 'red56/thredded-workgroup', branch: 'master'
100
+ gem 'thredded', github: 'thredded/thredded', branch: 'main'
101
+ gem 'thredded-workgroup', github: 'red56/thredded-workgroup', branch: 'main'
101
102
  ```
102
103
 
103
104
  and you need to update both at the same time: `gem update thredded thredded-workgroup`
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thredded
4
+ module Workgroup
5
+ module ApplicationControllerRetaining
6
+ def topics_scope
7
+ return super if messageboard_or_nil
8
+
9
+ all_topics_scope
10
+ end
11
+
12
+ def unread_followed_topics_count
13
+ return super if messageboard_or_nil
14
+
15
+ all_unread_followed_topics_count
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thredded
4
+ module Workgroup
5
+ module PostsControllerWhichRedirects
6
+ def create
7
+ @post_form = Thredded::PostForm.new(
8
+ user: thredded_current_user, topic: parent_topic, post_params: new_post_params
9
+ )
10
+ authorize_creating @post_form.post
11
+
12
+ if @post_form.save
13
+ # TODO: extract as a hook on thredded#posts_controller `after_create(post)`
14
+ redirect_after_create(@post_form.post)
15
+ else
16
+ render :new
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def after_mark_as_unread
23
+ if post.private_topic_post?
24
+ redirect_to private_topics_path
25
+ else
26
+ redirect_to thredded_workgroup.unread_nav_path
27
+ end
28
+ end
29
+
30
+ def redirect_after_create(post)
31
+ UserTopicReadState.touch!(thredded_current_user.id, post)
32
+ if params[:post_referer].present?
33
+ redirect_to params[:post_referer], notice: generate_flash_for(post)
34
+ else
35
+ redirect_to thredded_workgroup.unread_nav_path, notice: generate_flash_for(post)
36
+ end
37
+ end
38
+
39
+ def generate_flash_for(post)
40
+ path_to_post = thredded.messageboard_topic_path(parent_topic.messageboard, parent_topic,
41
+ anchor: "post_#{post.id}")
42
+ # rubocop:disable Rails/OutputSafety
43
+ "Successfully replied to #{view_context.link_to(parent_topic.title, path_to_post)}".html_safe
44
+ # rubocop:enable Rails/OutputSafety
45
+ end
46
+ end
47
+ end
48
+ end
@@ -3,11 +3,8 @@
3
3
  module Thredded
4
4
  module Workgroup
5
5
  module ViewHooks
6
- attr_reader :topic_with_last_post
7
-
8
- def initialize
9
- super
10
- @topic_with_last_post = TopicWithLastPost.new
6
+ def topic_with_last_post
7
+ @topic_with_last_post ||= TopicWithLastPost.new
11
8
  end
12
9
 
13
10
  # View hooks for a Topic when displaying last post.
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thredded
4
+ module Workgroup
5
+ class Paginator < Kaminari::Helpers::Paginator
6
+ module UrlFixer
7
+ def page_url_for(page)
8
+ params = params_for(page)
9
+ params[:only_path] = true
10
+ @template.thredded_workgroup.url_for params
11
+ end
12
+ end
13
+
14
+ # Override the Kaminari::Helpers::Paginator methods as of kaminari v1.2.2 (fragile)
15
+ def page_tag(page)
16
+ @last = Thredded::Workgroup::Paginator::Page.new @template, **@options.merge(page: page)
17
+ end
18
+
19
+ # rubocop:disable Security/Eval
20
+ # rubocop:disable Style/DocumentDynamicEvalDefinition
21
+ %w[first_page prev_page next_page last_page gap].each do |tag|
22
+ eval <<-DEF, nil, __FILE__, __LINE__ + 1
23
+ def #{tag}_tag
24
+ @last = Thredded::Workgroup::Paginator::#{tag.classify}.new @template, **@options
25
+ end
26
+ DEF
27
+ end
28
+
29
+ # Create the relevant classes with the URL overrides
30
+ %w[page first_page prev_page next_page last_page gap].each do |tag|
31
+ eval <<-DEF, nil, __FILE__, __LINE__ + 1
32
+ class #{tag.classify} < ::Kaminari::Helpers:: #{tag.classify}
33
+ include UrlFixer
34
+ end
35
+ DEF
36
+ end
37
+ # rubocop:enable Security/Eval
38
+ # rubocop:enable Style/DocumentDynamicEvalDefinition
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thredded
4
+ module Workgroup
5
+ module TopicsPageViewWithLastPost
6
+ protected
7
+
8
+ def refine_scope(topics_page_scope)
9
+ super.includes(:last_post)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -6,11 +6,11 @@
6
6
  <% end %>
7
7
 
8
8
  <%= button_to t("thredded.nav.mark_all_read"),
9
- mark_all_topics_read_path,
9
+ thredded_workgroup.mark_all_topics_read_path,
10
10
  class: 'thredded--button thredded--button-light thredded--button-wide',
11
11
  method: :put -%>
12
12
 
13
13
  <footer>
14
- <%= paginate @topics %>
14
+ <%= paginate(@topics, paginator_class: Thredded::Workgroup::Paginator) %>
15
15
  </footer>
16
16
  <% end %>
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Thredded::AllViewHooks.class_eval do
4
+ include Thredded::Workgroup::ViewHooks
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Thredded::ApplicationController.class_eval do
4
+ Rails.logger.debug "I am being evaled Thredded::ApplicationController"
5
+ include Thredded::Workgroup::AllUnreadFollowedTopics
6
+
7
+ prepend ::Thredded::Workgroup::ApplicationControllerRetaining
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Thredded::PostsController.class_eval do
4
+ prepend ::Thredded::Workgroup::PostsControllerWhichRedirects
5
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ Thredded::TopicView.class_eval do
4
+ def path
5
+ anchor = if @read_state.first_unread_post_page
6
+ "unread"
7
+ elsif @topic.last_post
8
+ "post_#{@topic.last_post.id}"
9
+ end
10
+ page = @read_state.first_unread_post_page || @read_state.last_read_post_page
11
+ Thredded::UrlsHelper.topic_path(@topic, page: page, anchor: anchor)
12
+ end
13
+
14
+ def reply_path
15
+ Thredded::UrlsHelper.topic_path(@topic, page: last_page, anchor: "new_post")
16
+ end
17
+
18
+ def mark_as_unread_path
19
+ Thredded::UrlsHelper.mark_as_unread_post_path(id: last_post.id, format: :json)
20
+ end
21
+
22
+ def mark_as_read_path
23
+ Thredded::UrlsHelper.mark_as_read_post_path(id: last_post.id, format: :json)
24
+ end
25
+
26
+ def last_page
27
+ (@topic.posts_count / Thredded.posts_per_page.to_f).ceil # TODO: doesn't account for visibility
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Thredded::TopicsPageView.class_eval do
4
+ prepend ::Thredded::Workgroup::TopicsPageViewWithLastPost
5
+ end
@@ -1,21 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "thredded/engine"
4
- require "thredded/workgroup/thredded_route_delegator"
5
- require "thredded/workgroup/route_delegator"
4
+
6
5
  module Thredded
7
6
  module Workgroup
8
7
  class Engine < ::Rails::Engine
9
8
  isolate_namespace Thredded::Workgroup
10
9
 
11
- %w(app/controllers app/jobs app/view_models lib).each do |path|
12
- config.autoload_paths << File.expand_path("../../#{path}", File.dirname(__FILE__))
10
+ # https://guides.rubyonrails.org/engines.html#overriding-models-and-controllers
11
+ overrides = root.join("lib/overrides")
12
+ # Rails::autoloaders.main.ignore(overrides)
13
+ config.to_prepare do
14
+ Dir.glob("#{overrides}/**/*_override.rb").each do |override|
15
+ Rails.logger.debug { "overriding: #{override}" }
16
+ load override
17
+ end
13
18
  end
14
19
 
15
20
  config.to_prepare do
16
21
  Rails.application.reload_routes!
17
- ::Thredded::Workgroup::ThreddedRouteDelegator.add_thredded_proxies
18
- ::Thredded::Workgroup::RouteDelegator.add_my_proxies_to_thredded
19
22
 
20
23
  Thredded::ApplicationController.module_eval do
21
24
  Thredded.view_hooks.post_form.content_text_area.config.before do |form:, **_args|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Thredded
4
4
  module Workgroup
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
data/shared.gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  gem "rake"
4
- gem "thredded", github: "thredded/thredded", branch: "master"
4
+ gem "thredded", github: "thredded/thredded", branch: "main"
5
5
 
6
6
  unless ENV["TRAVIS"]
7
7
  group :development do
@@ -9,6 +9,8 @@ unless ENV["TRAVIS"]
9
9
  gem "guard-rails"
10
10
  gem "guard-livereload"
11
11
  gem "rack-livereload"
12
+ # TODO: drop this when launchy 2.5.2 is released (needed to get to Addressable 2.8)
13
+ gem "launchy", github: "copiousfreetime/launchy", branch: "main"
12
14
  end
13
15
  end
14
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded-workgroup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Diggins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-26 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thredded
@@ -440,19 +440,16 @@ files:
440
440
  - app/assets/stylesheets/thredded/workgroup/_overflow.scss
441
441
  - app/assets/stylesheets/thredded/workgroup/_topics.scss
442
442
  - app/controllers/concerns/thredded/workgroup/all_unread_followed_topics.rb
443
- - app/controllers/thredded/application_controller.rb
444
- - app/controllers/thredded/posts_controller.rb
443
+ - app/controllers/concerns/thredded/workgroup/application_controller_retaining.rb
444
+ - app/controllers/concerns/thredded/workgroup/posts_controller_which_redirects.rb
445
445
  - app/controllers/thredded/workgroup/application_controller.rb
446
446
  - app/controllers/thredded/workgroup/navs_controller.rb
447
447
  - app/controllers/thredded/workgroup/read_states_controller.rb
448
448
  - app/controllers/thredded/workgroup/topics_controller.rb
449
- - app/helpers/thredded/application_helper.rb
450
- - app/helpers/thredded/workgroup/application_helper.rb
451
449
  - app/jobs/thredded/workgroup/mark_all_topics_read_job.rb
452
- - app/view_hooks/thredded/all_view_hooks.rb
453
450
  - app/view_hooks/thredded/workgroup/view_hooks.rb
454
- - app/view_models/thredded/topic_view.rb
455
- - app/view_models/thredded/topics_page_view.rb
451
+ - app/view_models/thredded/workgroup/paginator.rb
452
+ - app/view_models/thredded/workgroup/topics_page_view_with_last_post.rb
456
453
  - app/views/layouts/thredded/workgroup/application.html.erb
457
454
  - app/views/thredded/posts_common/form/_after_content.html.erb
458
455
  - app/views/thredded/shared/_header.html.erb
@@ -473,16 +470,20 @@ files:
473
470
  - bin/dummy-rails
474
471
  - bin/rails.rb
475
472
  - bin/rspec
473
+ - bin/rubocop
476
474
  - bin/setup
477
475
  - bin/update_from_thredded
478
476
  - config/locales/en.yml
479
477
  - config/routes.rb
480
478
  - docs/followers-above-post.png
481
479
  - docs/navbar.png
480
+ - lib/overrides/thredded/all_view_hooks_override.rb
481
+ - lib/overrides/thredded/application_controller_override.rb
482
+ - lib/overrides/thredded/posts_controller_override.rb
483
+ - lib/overrides/thredded/topic_view_override.rb
484
+ - lib/overrides/thredded/topics_page_view_override.rb
482
485
  - lib/thredded/workgroup.rb
483
486
  - lib/thredded/workgroup/engine.rb
484
- - lib/thredded/workgroup/route_delegator.rb
485
- - lib/thredded/workgroup/thredded_route_delegator.rb
486
487
  - lib/thredded/workgroup/version.rb
487
488
  - script/create-db-users
488
489
  - script/dummy-console
@@ -507,7 +508,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
507
508
  - !ruby/object:Gem::Version
508
509
  version: '0'
509
510
  requirements: []
510
- rubygems_version: 3.0.9
511
+ rubygems_version: 3.1.6
511
512
  signing_key:
512
513
  specification_version: 4
513
514
  summary: Extension to Thredded with features for workgroup messaging (Unread, Unreplied,
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency File.expand_path("../../app/controllers/thredded/application_controller",
4
- Thredded::Engine.called_from)
5
-
6
- module Thredded
7
- module ApplicationControllerRetaining
8
- def topics_scope
9
- return super if messageboard_or_nil
10
- all_topics_scope
11
- end
12
-
13
- def unread_followed_topics_count
14
- return super if messageboard_or_nil
15
- all_unread_followed_topics_count
16
- end
17
- end
18
- class ApplicationController
19
- include Thredded::Workgroup::AllUnreadFollowedTopics
20
-
21
- prepend ::Thredded::ApplicationControllerRetaining
22
- end
23
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency File.expand_path("../../app/controllers/thredded/posts_controller", Thredded::Engine.called_from)
4
-
5
- module Thredded
6
- module PostsControllerWhichRedirects
7
- def create
8
- @post_form = Thredded::PostForm.new(
9
- user: thredded_current_user, topic: parent_topic, post_params: new_post_params
10
- )
11
- authorize_creating @post_form.post
12
-
13
- if @post_form.save
14
- # TODO: extract as a hook on thredded#posts_controller `after_create(post)`
15
- redirect_after_create(@post_form.post)
16
- else
17
- render :new
18
- end
19
- end
20
-
21
- private
22
-
23
- def after_mark_as_unread
24
- if post.private_topic_post?
25
- redirect_to private_topics_path
26
- else
27
- redirect_to thredded_workgroup.unread_nav_path
28
- end
29
- end
30
-
31
- def redirect_after_create(post)
32
- UserTopicReadState.touch!(thredded_current_user.id, post)
33
- if params[:post_referer].present?
34
- redirect_to params[:post_referer], notice: generate_flash_for(post)
35
- else
36
- redirect_to unread_nav_path, notice: generate_flash_for(post)
37
- end
38
- end
39
-
40
- def generate_flash_for(post)
41
- path_to_post = messageboard_topic_path(parent_topic.messageboard, parent_topic, anchor: "post_#{post.id}")
42
- # rubocop:disable Rails/OutputSafety
43
- "Successfully replied to #{view_context.link_to(parent_topic.title, path_to_post)}".html_safe
44
- # rubocop:enable Rails/OutputSafety
45
- end
46
- end
47
-
48
- class PostsController
49
- prepend ::Thredded::PostsControllerWhichRedirects
50
- end
51
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency File.expand_path("../../app/helpers/thredded/application_helper", Thredded::Engine.called_from)
4
- module Thredded
5
- module ApplicationHelper
6
- # include Thredded::Engine.routes.url_helpers
7
- # include Thredded::Workgroup::Engine.routes.url_helpers
8
- #
9
- end
10
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Thredded
4
- module Workgroup
5
- module ApplicationHelper
6
- end
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency File.expand_path("../../app/view_hooks/thredded/all_view_hooks", Thredded::Engine.called_from)
4
-
5
- module Thredded
6
- class AllViewHooks
7
- prepend ::Thredded::Workgroup::ViewHooks
8
- end
9
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency File.expand_path("../../app/view_models/thredded/topic_view", Thredded::Engine.called_from)
4
- module Thredded
5
- class TopicView < Thredded::BaseTopicView
6
- def path
7
- anchor = if @read_state.first_unread_post_page
8
- "unread"
9
- elsif @topic.last_post
10
- "post_#{@topic.last_post.id}"
11
- end
12
- page = @read_state.first_unread_post_page || @read_state.last_read_post_page
13
- Thredded::UrlsHelper.topic_path(@topic, page: page, anchor: anchor)
14
- end
15
-
16
- def reply_path
17
- Thredded::UrlsHelper.topic_path(@topic, page: last_page, anchor: "new_post")
18
- end
19
-
20
- def mark_as_unread_path
21
- Thredded::UrlsHelper.mark_as_unread_post_path(id: last_post.id, format: :json)
22
- end
23
-
24
- def mark_as_read_path
25
- Thredded::UrlsHelper.mark_as_read_post_path(id: last_post.id, format: :json)
26
- end
27
-
28
- def last_page
29
- (@topic.posts_count / Thredded.posts_per_page.to_f).ceil # TODO: doesn't account for visibility
30
- end
31
- end
32
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency File.expand_path("../../app/view_models/thredded/topics_page_view", Thredded::Engine.called_from)
4
- module Thredded
5
- module TopicsPageViewWithLastPost
6
- protected
7
-
8
- def refine_scope(topics_page_scope)
9
- super.includes(:last_post)
10
- end
11
- end
12
-
13
- class TopicsPageView
14
- prepend ::Thredded::TopicsPageViewWithLastPost
15
- end
16
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This includes this module into Thredded Application Controller so we can use
4
- # url helpers from Thredded PN like unread_nav_path in controllers.
5
- module Thredded
6
- module Workgroup
7
- module RouteDelegator
8
- def self.add_my_proxies_to_thredded
9
- thredded_methods = Thredded::Engine.routes.url_helpers.methods
10
- my_route_helpers = Thredded::Workgroup::Engine.routes.url_helpers
11
- path_methods = my_route_helpers.methods.select { |s| s.to_s.ends_with?("_path", "_url") }
12
- .reject { |s| thredded_methods.include?(s) }
13
- path_methods.each do |method_name|
14
- send(:define_method, method_name) do |*args|
15
- my_route_helpers.send(method_name, *args)
16
- end
17
- end
18
- ::Thredded::ApplicationController.send(:include,
19
- ::Thredded::Workgroup::RouteDelegator)
20
- # if we need to use in views, then we add
21
- # ::Thredded::ApplicationController.helper(::Thredded::Workgroup::RouteDelegator)
22
- end
23
- end
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Thredded
4
- module Workgroup
5
- module ThreddedRouteDelegator
6
- def self.add_thredded_proxies
7
- thredded = Thredded::Engine.routes.url_helpers
8
- path_methods = thredded.methods.select { |s| s.to_s.ends_with?("_path", "_url") }
9
- path_methods.each do |method_name|
10
- send(:define_method, method_name) do |*args|
11
- thredded.send(method_name, *args)
12
- end
13
- end
14
- ::Thredded::Workgroup::ApplicationController.helper(
15
- ::Thredded::Workgroup::ThreddedRouteDelegator
16
- )
17
- end
18
- end
19
- end
20
- end