thredded 0.7.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +119 -17
  3. data/app/assets/javascripts/thredded/components/currently_online.es6 +3 -3
  4. data/app/assets/javascripts/thredded/components/flash_messages.es6 +11 -0
  5. data/app/assets/javascripts/thredded/components/post_form.es6 +21 -4
  6. data/app/assets/javascripts/thredded/components/time_stamps.es6 +8 -6
  7. data/app/assets/javascripts/thredded/components/topic_form.es6 +14 -3
  8. data/app/assets/javascripts/thredded/components/topics.es6 +3 -3
  9. data/app/assets/javascripts/thredded/components/turboforms.es6 +15 -0
  10. data/app/assets/javascripts/thredded/components/user_preferences_form.es6 +47 -20
  11. data/app/assets/javascripts/thredded/components/users_select.es6 +25 -9
  12. data/app/assets/javascripts/thredded/core/hide_soft_keyboard.es6 +6 -0
  13. data/app/assets/javascripts/thredded/core/mention_autocompletion.es6 +54 -0
  14. data/app/assets/javascripts/thredded/core/on_page_load.es6 +46 -0
  15. data/app/assets/javascripts/thredded/dependencies.js +2 -1
  16. data/app/assets/javascripts/thredded/dependencies/jquery.js +1 -0
  17. data/app/assets/javascripts/thredded/thredded.es6 +1 -0
  18. data/app/assets/stylesheets/thredded/_thredded.scss +1 -0
  19. data/app/assets/stylesheets/thredded/base/_alerts.scss +5 -1
  20. data/app/assets/stylesheets/thredded/base/_grid.scss +8 -0
  21. data/app/assets/stylesheets/thredded/base/_nav.scss +0 -5
  22. data/app/assets/stylesheets/thredded/components/_following.scss +0 -3
  23. data/app/assets/stylesheets/thredded/components/_mention-autocomplete.scss +35 -0
  24. data/app/assets/stylesheets/thredded/components/_topic-header.scss +37 -17
  25. data/app/assets/stylesheets/thredded/components/_topics.scss +13 -0
  26. data/app/assets/stylesheets/thredded/layout/_main-navigation.scss +57 -14
  27. data/app/assets/stylesheets/thredded/layout/_moderation.scss +5 -0
  28. data/app/assets/stylesheets/thredded/layout/_navigation.scss +14 -17
  29. data/app/assets/stylesheets/thredded/layout/_search-navigation.scss +15 -3
  30. data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +3 -11
  31. data/app/commands/thredded/at_notification_extractor.rb +2 -2
  32. data/app/commands/thredded/autofollow_mentioned_users.rb +2 -2
  33. data/app/commands/thredded/create_messageboard.rb +45 -0
  34. data/app/commands/thredded/notify_following_users.rb +10 -0
  35. data/app/controllers/thredded/autocomplete_users_controller.rb +2 -3
  36. data/app/controllers/thredded/messageboards_controller.rb +1 -24
  37. data/app/controllers/thredded/moderation_controller.rb +1 -1
  38. data/app/controllers/thredded/post_permalinks_controller.rb +1 -1
  39. data/app/controllers/thredded/preferences_controller.rb +4 -2
  40. data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -1
  41. data/app/controllers/thredded/theme_previews_controller.rb +1 -1
  42. data/app/controllers/thredded/topics_controller.rb +0 -1
  43. data/app/forms/thredded/user_preferences_form.rb +4 -2
  44. data/app/helpers/thredded/application_helper.rb +5 -0
  45. data/app/helpers/thredded/nav_helper.rb +41 -0
  46. data/app/mailer_previews/thredded/base_mailer_preview.rb +0 -1
  47. data/app/mailers/thredded/post_mailer.rb +0 -1
  48. data/app/mailers/thredded/private_topic_mailer.rb +0 -1
  49. data/app/models/concerns/thredded/user_topic_read_state_common.rb +2 -2
  50. data/app/models/thredded/messageboard.rb +0 -1
  51. data/app/models/thredded/null_preference.rb +5 -1
  52. data/app/models/thredded/private_post.rb +2 -2
  53. data/app/policies/thredded/messageboard_group_policy.rb +1 -1
  54. data/app/view_hooks/thredded/all_view_hooks.rb +68 -0
  55. data/app/view_models/thredded/post_view.rb +3 -3
  56. data/app/view_models/thredded/topic_email_view.rb +0 -4
  57. data/app/view_models/thredded/topics_page_view.rb +12 -1
  58. data/app/views/layouts/thredded/application.html.erb +5 -2
  59. data/app/views/thredded/messageboard_groups/new.html.erb +3 -1
  60. data/app/views/thredded/messageboards/edit.html.erb +3 -1
  61. data/app/views/thredded/messageboards/new.html.erb +3 -1
  62. data/app/views/thredded/moderation/_users_search_form.html.erb +4 -1
  63. data/app/views/thredded/moderation/user.html.erb +34 -28
  64. data/app/views/thredded/posts_common/_form.html.erb +6 -1
  65. data/app/views/thredded/posts_common/form/_content_field.html.erb +5 -3
  66. data/app/views/thredded/preferences/_form.html.erb +30 -12
  67. data/app/views/thredded/private_topics/_form.html.erb +4 -3
  68. data/app/views/thredded/private_topics/index.html.erb +5 -5
  69. data/app/views/thredded/search/_form.html.erb +2 -1
  70. data/app/views/thredded/shared/_flash_messages.html.erb +1 -1
  71. data/app/views/thredded/shared/_page.html.erb +10 -1
  72. data/app/views/thredded/shared/nav/_moderation.html.erb +3 -2
  73. data/app/views/thredded/shared/nav/_notification_preferences.html.erb +5 -3
  74. data/app/views/thredded/shared/nav/_private_topics.html.erb +3 -2
  75. data/app/views/thredded/topics/_form.html.erb +6 -1
  76. data/app/views/thredded/topics/_header.html.erb +8 -5
  77. data/config/locales/en.yml +15 -7
  78. data/config/locales/pt-BR.yml +21 -13
  79. data/config/routes.rb +4 -2
  80. data/db/migrate/20160329231848_create_thredded.rb +5 -5
  81. data/db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb +31 -0
  82. data/lib/generators/thredded/install/templates/initializer.rb +20 -8
  83. data/lib/tasks/thredded_tasks.rake +0 -7
  84. data/lib/thredded.rb +19 -5
  85. data/lib/thredded/content_formatter.rb +43 -8
  86. data/lib/thredded/database_seeder.rb +7 -1
  87. data/lib/thredded/engine.rb +2 -21
  88. data/lib/{html/pipeline → thredded/html_pipeline}/at_mention_filter.rb +4 -4
  89. data/lib/thredded/html_pipeline/autolink_filter.rb +14 -0
  90. data/lib/thredded/html_pipeline/kramdown_filter.rb +34 -0
  91. data/lib/thredded/version.rb +1 -1
  92. data/lib/thredded/view_hooks/config.rb +36 -0
  93. data/lib/thredded/view_hooks/renderer.rb +29 -0
  94. data/vendor/assets/javascripts/jquery.textcomplete.js +1488 -0
  95. metadata +65 -52
  96. data/app/commands/thredded/messageboard_destroyer.rb +0 -65
  97. data/lib/html/pipeline/bbcode_filter.rb +0 -33
  98. data/lib/thredded/main_app_route_delegator.rb +0 -25
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.7.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Oliveira
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-13 00:00:00.000000000 Z
12
+ date: 2016-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bbcoder
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '1.0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: pundit
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +68,7 @@ dependencies:
82
68
  - !ruby/object:Gem::Version
83
69
  version: '0'
84
70
  - !ruby/object:Gem::Dependency
85
- name: html-pipeline
71
+ name: htmlentities
86
72
  requirement: !ruby/object:Gem::Requirement
87
73
  requirements:
88
74
  - - ">="
@@ -96,7 +82,7 @@ dependencies:
96
82
  - !ruby/object:Gem::Version
97
83
  version: '0'
98
84
  - !ruby/object:Gem::Dependency
99
- name: html-pipeline-vimeo
85
+ name: kaminari
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
88
  - - ">="
@@ -110,7 +96,7 @@ dependencies:
110
96
  - !ruby/object:Gem::Version
111
97
  version: '0'
112
98
  - !ruby/object:Gem::Dependency
113
- name: html-pipeline-youtube
99
+ name: nokogiri
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
102
  - - ">="
@@ -124,7 +110,21 @@ dependencies:
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
112
  - !ruby/object:Gem::Dependency
127
- name: htmlentities
113
+ name: rails
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 4.2.0
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 4.2.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: rb-gravatar
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
@@ -138,7 +138,7 @@ dependencies:
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
- name: kaminari
141
+ name: inline_svg
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
@@ -152,7 +152,7 @@ dependencies:
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  - !ruby/object:Gem::Dependency
155
- name: nokogiri
155
+ name: kramdown
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
@@ -166,21 +166,21 @@ dependencies:
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  - !ruby/object:Gem::Dependency
169
- name: rails
169
+ name: html-pipeline
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 4.2.0
174
+ version: '0'
175
175
  type: :runtime
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - ">="
180
180
  - !ruby/object:Gem::Version
181
- version: 4.2.0
181
+ version: '0'
182
182
  - !ruby/object:Gem::Dependency
183
- name: rb-gravatar
183
+ name: html-pipeline-vimeo
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="
@@ -194,7 +194,7 @@ dependencies:
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  - !ruby/object:Gem::Dependency
197
- name: inline_svg
197
+ name: html-pipeline-youtube
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - ">="
@@ -208,7 +208,7 @@ dependencies:
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  - !ruby/object:Gem::Dependency
211
- name: gemoji
211
+ name: rinku
212
212
  requirement: !ruby/object:Gem::Requirement
213
213
  requirements:
214
214
  - - ">="
@@ -222,7 +222,7 @@ dependencies:
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  - !ruby/object:Gem::Dependency
225
- name: github-markdown
225
+ name: gemoji
226
226
  requirement: !ruby/object:Gem::Requirement
227
227
  requirements:
228
228
  - - ">="
@@ -339,14 +339,14 @@ dependencies:
339
339
  requirements:
340
340
  - - ">="
341
341
  - !ruby/object:Gem::Version
342
- version: '0'
342
+ version: 4.2.1
343
343
  type: :runtime
344
344
  prerelease: false
345
345
  version_requirements: !ruby/object:Gem::Requirement
346
346
  requirements:
347
347
  - - ">="
348
348
  - !ruby/object:Gem::Version
349
- version: '0'
349
+ version: 4.2.1
350
350
  - !ruby/object:Gem::Dependency
351
351
  name: capybara
352
352
  requirement: !ruby/object:Gem::Requirement
@@ -432,33 +432,33 @@ dependencies:
432
432
  - !ruby/object:Gem::Version
433
433
  version: 3.5.0
434
434
  - !ruby/object:Gem::Dependency
435
- name: rubocop
435
+ name: simplecov
436
436
  requirement: !ruby/object:Gem::Requirement
437
437
  requirements:
438
- - - '='
438
+ - - ">="
439
439
  - !ruby/object:Gem::Version
440
- version: 0.42.0
440
+ version: '0'
441
441
  type: :development
442
442
  prerelease: false
443
443
  version_requirements: !ruby/object:Gem::Requirement
444
444
  requirements:
445
- - - '='
445
+ - - ">="
446
446
  - !ruby/object:Gem::Version
447
- version: 0.42.0
447
+ version: '0'
448
448
  - !ruby/object:Gem::Dependency
449
- name: test-unit
449
+ name: rubocop
450
450
  requirement: !ruby/object:Gem::Requirement
451
451
  requirements:
452
- - - ">="
452
+ - - '='
453
453
  - !ruby/object:Gem::Version
454
- version: '0'
454
+ version: 0.42.0
455
455
  type: :development
456
456
  prerelease: false
457
457
  version_requirements: !ruby/object:Gem::Requirement
458
458
  requirements:
459
- - - ">="
459
+ - - '='
460
460
  - !ruby/object:Gem::Version
461
- version: '0'
461
+ version: 0.42.0
462
462
  - !ruby/object:Gem::Dependency
463
463
  name: rails-i18n
464
464
  requirement: !ruby/object:Gem::Requirement
@@ -572,7 +572,7 @@ dependencies:
572
572
  - !ruby/object:Gem::Version
573
573
  version: '0'
574
574
  - !ruby/object:Gem::Dependency
575
- name: jquery-turbolinks
575
+ name: turbolinks
576
576
  requirement: !ruby/object:Gem::Requirement
577
577
  requirements:
578
578
  - - ">="
@@ -586,19 +586,19 @@ dependencies:
586
586
  - !ruby/object:Gem::Version
587
587
  version: '0'
588
588
  - !ruby/object:Gem::Dependency
589
- name: turbolinks
589
+ name: coffee-rails
590
590
  requirement: !ruby/object:Gem::Requirement
591
591
  requirements:
592
- - - "~>"
592
+ - - ">="
593
593
  - !ruby/object:Gem::Version
594
- version: '2.5'
594
+ version: '0'
595
595
  type: :development
596
596
  prerelease: false
597
597
  version_requirements: !ruby/object:Gem::Requirement
598
598
  requirements:
599
- - - "~>"
599
+ - - ">="
600
600
  - !ruby/object:Gem::Version
601
- version: '2.5'
601
+ version: '0'
602
602
  description: |-
603
603
  The best Rails 4.2+ forums engine ever. Its goal is to be as simple and feature rich as possible.
604
604
  Thredded works with SQLite, MySQL (v5.6.4+), and PostgreSQL. See the demo at https://thredded.org/.
@@ -619,13 +619,19 @@ files:
619
619
  - app/assets/images/thredded/unfollow.svg
620
620
  - app/assets/javascripts/thredded.es6
621
621
  - app/assets/javascripts/thredded/components/currently_online.es6
622
+ - app/assets/javascripts/thredded/components/flash_messages.es6
622
623
  - app/assets/javascripts/thredded/components/post_form.es6
623
624
  - app/assets/javascripts/thredded/components/time_stamps.es6
624
625
  - app/assets/javascripts/thredded/components/topic_form.es6
625
626
  - app/assets/javascripts/thredded/components/topics.es6
627
+ - app/assets/javascripts/thredded/components/turboforms.es6
626
628
  - app/assets/javascripts/thredded/components/user_preferences_form.es6
627
629
  - app/assets/javascripts/thredded/components/users_select.es6
630
+ - app/assets/javascripts/thredded/core/hide_soft_keyboard.es6
631
+ - app/assets/javascripts/thredded/core/mention_autocompletion.es6
632
+ - app/assets/javascripts/thredded/core/on_page_load.es6
628
633
  - app/assets/javascripts/thredded/dependencies.js
634
+ - app/assets/javascripts/thredded/dependencies/jquery.js
629
635
  - app/assets/javascripts/thredded/thredded.es6
630
636
  - app/assets/stylesheets/thredded.scss
631
637
  - app/assets/stylesheets/thredded/_base.scss
@@ -649,6 +655,7 @@ files:
649
655
  - app/assets/stylesheets/thredded/components/_form-list.scss
650
656
  - app/assets/stylesheets/thredded/components/_icons.scss
651
657
  - app/assets/stylesheets/thredded/components/_main-section.scss
658
+ - app/assets/stylesheets/thredded/components/_mention-autocomplete.scss
652
659
  - app/assets/stylesheets/thredded/components/_messageboard.scss
653
660
  - app/assets/stylesheets/thredded/components/_pagination.scss
654
661
  - app/assets/stylesheets/thredded/components/_post-form.scss
@@ -669,9 +676,9 @@ files:
669
676
  - app/assets/stylesheets/thredded/utilities/_is-expanded.scss
670
677
  - app/commands/thredded/at_notification_extractor.rb
671
678
  - app/commands/thredded/autofollow_mentioned_users.rb
679
+ - app/commands/thredded/create_messageboard.rb
672
680
  - app/commands/thredded/mark_all_read.rb
673
681
  - app/commands/thredded/members_marked_notified.rb
674
- - app/commands/thredded/messageboard_destroyer.rb
675
682
  - app/commands/thredded/moderate_post.rb
676
683
  - app/commands/thredded/notify_following_users.rb
677
684
  - app/commands/thredded/notify_private_topic_users.rb
@@ -692,6 +699,7 @@ files:
692
699
  - app/forms/thredded/topic_form.rb
693
700
  - app/forms/thredded/user_preferences_form.rb
694
701
  - app/helpers/thredded/application_helper.rb
702
+ - app/helpers/thredded/nav_helper.rb
695
703
  - app/helpers/thredded/urls_helper.rb
696
704
  - app/jobs/thredded/activity_updater_job.rb
697
705
  - app/jobs/thredded/auto_follow_and_notify_job.rb
@@ -745,6 +753,7 @@ files:
745
753
  - app/policies/thredded/private_post_policy.rb
746
754
  - app/policies/thredded/private_topic_policy.rb
747
755
  - app/policies/thredded/topic_policy.rb
756
+ - app/view_hooks/thredded/all_view_hooks.rb
748
757
  - app/view_models/thredded/base_topic_view.rb
749
758
  - app/view_models/thredded/messageboard_group_view.rb
750
759
  - app/view_models/thredded/post_view.rb
@@ -855,21 +864,25 @@ files:
855
864
  - db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb
856
865
  - db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb
857
866
  - db/upgrade_migrations/20160723012349_upgrade_v0_6_to_v0_7.rb
867
+ - db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb
858
868
  - lib/generators/thredded/install/USAGE
859
869
  - lib/generators/thredded/install/install_generator.rb
860
870
  - lib/generators/thredded/install/templates/initializer.rb
861
- - lib/html/pipeline/at_mention_filter.rb
862
- - lib/html/pipeline/bbcode_filter.rb
863
871
  - lib/tasks/thredded_tasks.rake
864
872
  - lib/thredded.rb
865
873
  - lib/thredded/content_formatter.rb
866
874
  - lib/thredded/database_seeder.rb
867
875
  - lib/thredded/engine.rb
868
876
  - lib/thredded/errors.rb
869
- - lib/thredded/main_app_route_delegator.rb
877
+ - lib/thredded/html_pipeline/at_mention_filter.rb
878
+ - lib/thredded/html_pipeline/autolink_filter.rb
879
+ - lib/thredded/html_pipeline/kramdown_filter.rb
870
880
  - lib/thredded/search_parser.rb
871
881
  - lib/thredded/topics_search.rb
872
882
  - lib/thredded/version.rb
883
+ - lib/thredded/view_hooks/config.rb
884
+ - lib/thredded/view_hooks/renderer.rb
885
+ - vendor/assets/javascripts/jquery.textcomplete.js
873
886
  homepage: https://thredded.org
874
887
  licenses:
875
888
  - MIT
@@ -890,7 +903,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
890
903
  version: '0'
891
904
  requirements: []
892
905
  rubyforge_project:
893
- rubygems_version: 2.6.6
906
+ rubygems_version: 2.6.8
894
907
  signing_key:
895
908
  specification_version: 4
896
909
  summary: The best Rails forums engine ever.
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
- module Thredded
3
- class MessageboardDestroyer
4
- def initialize(messageboard_name)
5
- @messageboard = Thredded::Messageboard.friendly.find(messageboard_name)
6
- @connection = ActiveRecord::Base.connection
7
- rescue
8
- say "No messageboard with the name '#{messageboard_name}' found."
9
- end
10
-
11
- def run
12
- return unless messageboard
13
-
14
- ActiveRecord::Base.transaction do
15
- destroy_all_lower_dependencies
16
- destroy_all_posts
17
- destroy_all_topics
18
- destroy_messageboard_and_everything_else
19
- end
20
- end
21
-
22
- private
23
-
24
- attr_reader :messageboard, :connection
25
-
26
- def destroy_all_lower_dependencies
27
- say 'Destroying lower level dependencies ...'
28
- [PostNotification.joins(non_private_post: :postable), UserTopicReadState.joins(:postable)].each do |child_t|
29
- child_t.merge(Topic.where(messageboard_id: messageboard.id)).delete_all
30
- end
31
-
32
- Thredded::MessageboardUser
33
- .where(thredded_messageboard_id: messageboard.id)
34
- .delete_all
35
- end
36
-
37
- def destroy_all_posts
38
- say 'Destroying all posts ...'
39
-
40
- connection.execute <<-SQL
41
- DELETE FROM thredded_posts
42
- WHERE messageboard_id = #{messageboard.id}
43
- SQL
44
- end
45
-
46
- def destroy_all_topics
47
- say 'Destroying all topics ...'
48
-
49
- connection.execute <<-SQL
50
- DELETE FROM thredded_topics
51
- WHERE messageboard_id = #{messageboard.id}
52
- SQL
53
- end
54
-
55
- def destroy_messageboard_and_everything_else
56
- say 'Destroying messageboard and everything else. Sit tight ...'
57
-
58
- @messageboard.destroy!
59
- end
60
-
61
- def say(message)
62
- Rails.logger.info message unless Rails.env.test?
63
- end
64
- end
65
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'bbcoder'
3
-
4
- module HTML
5
- class Pipeline
6
- class BbcodeFilter < TextFilter
7
- def initialize(text, context = {}, result = nil)
8
- super text, context, result
9
- end
10
-
11
- def call
12
- html = BBCoder.new(@text).to_html
13
- html = remove_url_link_contents(html)
14
- html = preserve_mkdn_comments(html)
15
- html.delete('<br>')
16
- html.rstrip!
17
- html
18
- end
19
-
20
- def remove_url_link_contents(html)
21
- doc = Nokogiri::HTML::DocumentFragment.parse(html)
22
- doc.css('a').each do |link|
23
- link.content = link.content.gsub(%r{https?://}, '')
24
- end
25
- doc.to_html
26
- end
27
-
28
- def preserve_mkdn_comments(html)
29
- html.gsub(/^&gt; /, '> ')
30
- end
31
- end
32
- end
33
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
- module Thredded
3
- # If thredded is rendered within an application layout, this module allows
4
- # referring to the routes in the layout directly, without having to use `main_app.`.
5
- module MainAppRouteDelegator
6
- # delegate url helpers to main_app
7
- def method_missing(method, *args, &block)
8
- if main_app_route_method?(method)
9
- main_app.send(method, *args)
10
- else
11
- super
12
- end
13
- end
14
-
15
- def respond_to_missing?(method, *args)
16
- super || main_app_route_method?(method)
17
- end
18
-
19
- private
20
-
21
- def main_app_route_method?(method)
22
- method.to_s =~ /_(?:path|url)$/ && main_app.respond_to?(method)
23
- end
24
- end
25
- end