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
@@ -17,12 +17,12 @@
17
17
  placeholder: t('thredded.private_topics.form.title_placeholder_start') %>
18
18
 
19
19
  <%= render @private_topics %>
20
- <% end -%>
21
20
 
22
- <%= link_to t('thredded.nav.mark_all_read'),
23
- mark_all_private_topics_read_path,
24
- class: 'thredded--button thredded--button-light thredded--button-wide',
25
- method: :put -%>
21
+ <%= link_to t('thredded.nav.mark_all_read'),
22
+ mark_all_private_topics_read_path,
23
+ class: 'thredded--button thredded--button-light thredded--button-wide',
24
+ method: :put -%>
25
+ <% end -%>
26
26
  <% end %>
27
27
 
28
28
  <footer>
@@ -1,6 +1,7 @@
1
1
  <%= form_tag search_path(messageboard),
2
2
  method: 'get',
3
- class: 'thredded--form thredded--navigation--search thredded--navigation--search-topics' do %>
3
+ class: 'thredded--form thredded--navigation--search thredded--navigation--search-topics',
4
+ 'data-thredded-turboform' => true do %>
4
5
  <%= label_tag :q, t('thredded.search.form.label') %>
5
6
  <%= text_field_tag :q, @query,
6
7
  type: 'search',
@@ -1,6 +1,6 @@
1
1
  <% [:success, :error, :notice, :alert].each do |key| %>
2
2
  <% if flash[key] %>
3
- <div class="thredded--flash-message thredded--flash-message--<%= key %>" id="flash">
3
+ <div class="thredded--flash-message thredded--flash-message--<%= key %>" data-thredded-flash-message>
4
4
  <%= flash[key] %>
5
5
  </div>
6
6
  <% end %>
@@ -1,6 +1,15 @@
1
- <%= content_tag(:div, id: "thredded--container", class: thredded_container_classes, data: thredded_container_data) do %>
1
+ <%= content_tag(:div, id: 'thredded--container', class: thredded_container_classes, data: thredded_container_data) do %>
2
2
  <%= render 'thredded/shared/header' %>
3
3
  <%= render 'thredded/shared/flash_messages' %>
4
4
  <%= yield :thredded_page_content %>
5
5
  <%= render 'thredded/shared/currently_online' %>
6
6
  <%- end %>
7
+
8
+ <%# If thredded JS is loaded via an [async] script, the JS may
9
+ run before or after DOMContentLoaded. Expose a flag to Thredded
10
+ so it can initialize correctly. %>
11
+ <script data-turbolinks-eval="false">
12
+ document.addEventListener('DOMContentLoaded', function() {
13
+ (window.Thredded = window.Thredded || {}).DOMContentLoadedFired = true;
14
+ });
15
+ </script>
@@ -1,6 +1,7 @@
1
1
  <% if moderatable_messageboards_ids.present? %>
2
- <li class="thredded--user-navigation--item thredded--user-navigation--moderation">
3
- <%= link_to pending_moderation_path, rel: 'nofollow' do %>
2
+ <% current = current_page_moderation? %>
3
+ <li class="thredded--user-navigation--item thredded--user-navigation--moderation<%= ' thredded--is-current' if current %>">
4
+ <%= link_to (current ? messageboards_path : pending_moderation_path), rel: 'nofollow' do %>
4
5
  <%= inline_svg 'thredded/moderation.svg',
5
6
  class: 'thredded--icon',
6
7
  title: t('thredded.nav.moderation') %>
@@ -1,6 +1,8 @@
1
- <li class="thredded--user-navigation--settings thredded--user-navigation--item">
2
- <%= link_to edit_preferences_path(messageboard) do %>
1
+ <% current = current_page_preferences? %>
2
+ <li class="thredded--user-navigation--settings thredded--user-navigation--item<%= ' thredded--is-current' if current %>">
3
+ <%= link_to current ? (messageboard ? messageboard_topics_path(messageboard) : messageboards_path)
4
+ : edit_preferences_path(messageboard) do %>
3
5
  <%= inline_svg 'thredded/settings.svg', class: 'thredded--icon', title: t('thredded.nav.settings') %>
4
6
  <span class="thredded--nav-text"><%= t('thredded.nav.settings') %></span>
5
- <% end %>
7
+ <% end %>
6
8
  </li>
@@ -1,5 +1,6 @@
1
- <li class="thredded--user-navigation--item thredded--user-navigation--private-topics">
2
- <%= link_to private_topics_path, rel: 'nofollow' do %>
1
+ <% current = current_page_private_topics? %>
2
+ <li class="thredded--user-navigation--item thredded--user-navigation--private-topics<%= ' thredded--is-current' if current %>">
3
+ <%= link_to (current ? messageboards_path : private_topics_path), rel: 'nofollow' do %>
3
4
  <%= inline_svg 'thredded/private-messages.svg',
4
5
  class: 'thredded--icon',
5
6
  title: t('thredded.nav.private_topics') %>
@@ -1,5 +1,10 @@
1
1
  <%= form_for [messageboard, topic],
2
- html: { class: "thredded--form #{local_assigns[:css_class]}", 'data-thredded-topic-form' => true } do |form| %>
2
+ html: {
3
+ class: "thredded--form #{local_assigns[:css_class]}",
4
+ 'data-thredded-topic-form' => true,
5
+ 'data-autocomplete-url' => autocomplete_users_path,
6
+ 'data-autocomplete-min-length' => Thredded.autocomplete_min_length,
7
+ } do |form| %>
3
8
  <ul class="thredded--form-list on-top">
4
9
  <li class="title">
5
10
  <%= form.label :title, t('thredded.topics.form.title_label') %>
@@ -12,15 +12,18 @@
12
12
  <% if thredded_current_user %>
13
13
  <% if topic.followed? %>
14
14
  <div class="thredded--topic-header--follow-info">
15
- <%= inline_svg 'thredded/follow.svg', class: 'thredded--topic-header--follow-icon' %>
16
- <div>
15
+ <span class="thredded--topic-header--follow-info--reason">
17
16
  <%= topic_follow_reason_text topic.follow_reason %>
18
- <%= button_to 'Stop following', topic.unfollow_path %>
19
- </div>
17
+ </span>
18
+ <%= button_to topic.unfollow_path, form: {class: 'thredded--topic-header--follow-info--unfollow'} do %>
19
+ <%= t('thredded.topics.unfollow') %>
20
+ <%= inline_svg 'thredded/follow.svg', class: 'thredded--topic-header--follow-icon' %>
21
+ <% end %>
20
22
  </div>
21
23
  <% else %>
22
24
  <div class="thredded--topic-header--follow-info">
23
- <%= button_to 'Follow this topic', topic.follow_path %>
25
+ <%= button_to t('thredded.topics.follow'), topic.follow_path,
26
+ form: {class: 'thredded--topic-header--follow-info--follow'} %>
24
27
  </div>
25
28
  <% end %>
26
29
  <% end %>
@@ -72,20 +72,26 @@ en:
72
72
  page_title: :thredded.nav.settings
73
73
  form:
74
74
  global_preferences_label: Global Settings
75
- messageboard_notify_on_mention:
75
+ messageboard_follow_topics_on_mention:
76
76
  hint: >-
77
77
  When someone mentions you by your username (eg: @sam) in this messageboard you will follow the topic.
78
- You will receive emails with the contents of that post and any replies.
79
- label: :thredded.preferences.form.notify_on_mention.label
78
+ label: :thredded.preferences.form.follow_topics_on_mention.label
79
+ messageboard_followed_topic_emails:
80
+ hint: >-
81
+ When there is a post in a topic you follow on this messageboard you will be sent an email.
82
+ label: Email notifications for followed topics
83
+ followed_topic_emails:
84
+ hint: >-
85
+ When there is a post in a topic you follow you will receive an email.
86
+ label: Email notifications for followed topics
80
87
  messageboard_preferences_label_html: Notification Settings for <em>%{messageboard}</em>
81
- notify_on_mention:
88
+ follow_topics_on_mention:
82
89
  hint: >-
83
- When someone mentions you by your username (eg: @sam) you will follow the topic. You will receive emails
84
- with the contents of that post and any replies.
90
+ When someone mentions you by your username (eg: @sam) you will follow the topic.
85
91
  label: Follow topics you are mentioned in
86
92
  notify_on_message:
87
93
  hint: When you are added to a private conversation you will receive an email with its content.
88
- label: Private Message Notifications
94
+ label: Email notifications for private messages
89
95
  submit_btn: Update Settings
90
96
  title: Settings
91
97
  updated_notice: Your settings have been updated.
@@ -124,6 +130,8 @@ en:
124
130
  followed_by: 'Followed by:'
125
131
  followed_by_noone: No one is following this topic
126
132
  followed_notice: You are now following this topic
133
+ follow: Follow this topic
134
+ unfollow: Stop following
127
135
  following:
128
136
  manual: You are following this topic.
129
137
  mentioned: You are following this topic because you were mentioned on it.
@@ -71,22 +71,28 @@ pt-BR:
71
71
  edit:
72
72
  page_title: :thredded.nav.settings
73
73
  form:
74
+ follow_topics_on_mention:
75
+ hint: >-
76
+ Quando alguém mencionar você através do seu usuário (ex.: @sam) você irá receber um e-mail com o conteúdo
77
+ deste post.
78
+ label: Siga os tópicos que são mencionados na
79
+ followed_topic_emails:
80
+ hint: Quando há um post em um tópico que você siga, você receberá um e-mail.
81
+ label: Notificações de e-mail para tópicos seguido
74
82
  global_preferences_label: Configurações Globais
75
- messageboard_notify_on_mention:
83
+ messageboard_follow_topics_on_mention:
76
84
  hint: >-
77
85
  Quando alguém mencionar você através do seu usuário (ex.: @sam) neste fórum de mensagens, você irá receber
78
86
  um e-mail com o conteúdo deste post.
79
- label: :thredded.preferences.form.notify_on_mention.label
87
+ label: :thredded.preferences.form.follow_topics_on_mention.label
88
+ messageboard_followed_topic_emails:
89
+ hint: Quando há um post em um tópico que você siga nesta messageboard será enviado um e-mail.
90
+ label: Notificações de e-mail para tópicos seguido
80
91
  messageboard_preferences_label_html: Configurações de Notificação para <em>%{messageboard}</em>
81
- notify_on_mention:
82
- hint: >-
83
- Quando alguém mencionar você através do seu usuário (ex.: @sam) você irá receber um e-mail com o conteúdo
84
- deste post.
85
- label: "@ Notificações"
86
92
  notify_on_message:
87
93
  hint: Quando você for adicionado a uma conversa privada, você receberá um e-mail com o conteúdo desta
88
94
  conversa.
89
- label: Notificação de Mensagens Privadas
95
+ label: E-mail notificações de mensagens privadas
90
96
  submit_btn: Atualizar Configurações
91
97
  title: Configurações
92
98
  updated_notice: Suas configurações foram atualizadas.
@@ -122,13 +128,14 @@ pt-BR:
122
128
  delete_topic: Remover Tópico
123
129
  deleted_notice: Tópico removido
124
130
  edit: Editar Tópico
131
+ follow: Siga este tópico
125
132
  followed_by: 'Seguido por:'
126
133
  followed_by_noone: Ninguém está seguindo este tópico
127
- followed_notice: Você agora está acompanhando este tópico
134
+ followed_notice: Você agora está seguindo este tópico
128
135
  following:
129
- manual: Você está acompanhando este tópico.
130
- mentioned: Você está acompanhando este tópico porque você foi mencionado nele.
131
- posted: Você está acompanhando este tópico porque foi você que o publicou.
136
+ manual: Você está seguindo este tópico.
137
+ mentioned: Você está seguindo este tópico porque você foi mencionado nele.
138
+ posted: Você está seguindo este tópico porque foi você que o publicou.
132
139
  form:
133
140
  categories_placeholder: Categorias
134
141
  content_label: :thredded.posts.form.content_label
@@ -142,7 +149,8 @@ pt-BR:
142
149
  page_title: Tópicos dos Resultados da Busca
143
150
  results_message: Resultados de Busca para %{query}
144
151
  started_by_html: Iniciado %{time_ago} por %{user}
145
- unfollowed_notice: Você não está mais acompanhando este tópico
152
+ unfollow: Pare de seguir
153
+ unfollowed_notice: Você não está mais seguindo este tópico
146
154
  updated_notice: Tópico atualizado
147
155
  users:
148
156
  last_active_html: Última %{time_ago} ativa
data/config/routes.rb CHANGED
@@ -56,8 +56,10 @@ Thredded::Engine.routes.draw do
56
56
  end
57
57
  member do
58
58
  get '(page-:page)', action: :show, as: '', constraints: page_constraint
59
- post 'follow'
60
- post 'unfollow'
59
+
60
+ # match (un)follow via get as well so that redirecting back to it after sign in works.
61
+ match 'follow', via: [:post, :get]
62
+ match 'unfollow', via: [:post, :get]
61
63
  end
62
64
  resources :posts, except: [:index, :show], path: ''
63
65
  end
@@ -32,18 +32,16 @@ class CreateThredded < ActiveRecord::Migration
32
32
  DbTextSearch::CaseInsensitive.add_index connection, :thredded_categories, :name, name: :thredded_categories_name_ci
33
33
 
34
34
  create_table :thredded_messageboards do |t|
35
- t.string :name, limit: 255, null: false
35
+ t.string :name, limit: 191, null: false
36
36
  t.string :slug, limit: 191
37
37
  t.text :description
38
38
  t.integer :topics_count, default: 0
39
39
  t.integer :posts_count, default: 0
40
40
  t.integer :position, null: false
41
- t.boolean :closed, default: false, null: false
42
41
  t.references :last_topic
43
42
  t.references :messageboard_group
44
43
  t.timestamps null: false
45
44
  t.index [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
46
- t.index [:closed], name: :index_thredded_messageboards_on_closed
47
45
  t.index [:slug], name: :index_thredded_messageboards_on_slug
48
46
  end
49
47
 
@@ -162,8 +160,9 @@ class CreateThredded < ActiveRecord::Migration
162
160
 
163
161
  create_table :thredded_user_preferences do |t|
164
162
  t.references :user, null: false
165
- t.boolean :notify_on_mention, default: true, null: false
163
+ t.boolean :follow_topics_on_mention, default: true, null: false
166
164
  t.boolean :notify_on_message, default: true, null: false
165
+ t.boolean :followed_topic_emails, default: true, null: false
167
166
  t.timestamps null: false
168
167
  t.index [:user_id], name: :index_thredded_user_preferences_on_user_id
169
168
  end
@@ -171,7 +170,8 @@ class CreateThredded < ActiveRecord::Migration
171
170
  create_table :thredded_user_messageboard_preferences do |t|
172
171
  t.references :user, null: false
173
172
  t.references :messageboard, null: false
174
- t.boolean :notify_on_mention, default: true, null: false
173
+ t.boolean :follow_topics_on_mention, default: true, null: false
174
+ t.boolean :followed_topic_emails, default: true, null: false
175
175
  t.timestamps null: false
176
176
  t.index [:user_id, :messageboard_id],
177
177
  name: :thredded_user_messageboard_preferences_user_id_messageboard_id,
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ class UpgradeV07ToV08 < ActiveRecord::Migration
3
+ def up
4
+ closed_messageboards = Thredded::Messageboard.unscoped.where(closed: true).to_a
5
+ if closed_messageboards.present?
6
+ fail ActiveRecord::MigrationError, <<-TEXT
7
+ There are #{closed_messageboards.length} closed Messageboards:
8
+ #{closed_messageboards.map { |m| "#{m.name} (id=#{m.id})" }.join("\n")}
9
+ Support for closed messageboards has been removed in thredded v0.8.0.
10
+ Delete or un-close these messageboards and consider using the "paranoia" gem to support soft deletion instead.
11
+ TEXT
12
+ end
13
+ remove_index :thredded_messageboards, name: :index_thredded_messageboards_on_closed
14
+ remove_column :thredded_messageboards, :closed
15
+ add_column :thredded_user_preferences, :followed_topic_emails, :boolean, default: true, null: false
16
+ add_column :thredded_user_messageboard_preferences, :followed_topic_emails, :boolean, default: true, null: false
17
+ rename_column :thredded_user_preferences, :notify_on_mention, :follow_topics_on_mention
18
+ rename_column :thredded_user_messageboard_preferences, :notify_on_mention, :follow_topics_on_mention
19
+ change_column :thredded_messageboards, :name, :string, limit: 191
20
+ end
21
+
22
+ def down
23
+ change_column :thredded_messageboards, :name, :string, limit: 255
24
+ rename_column :thredded_user_messageboard_preferences, :follow_topics_on_mention, :notify_on_mention
25
+ rename_column :thredded_user_preferences, :follow_topics_on_mention, :notify_on_mention
26
+ remove_column :thredded_user_messageboard_preferences, :followed_topic_emails
27
+ remove_column :thredded_user_preferences, :followed_topic_emails
28
+ add_column :thredded_messageboards, :closed, :boolean, default: false, null: false
29
+ add_index :thredded_messageboards, :closed, name: :index_thredded_messageboards_on_closed
30
+ end
31
+ end
@@ -59,15 +59,9 @@ Thredded.messageboards_order = :position
59
59
  # Email "From:" field will use the following
60
60
  # Thredded.email_from = 'no-reply@example.com'
61
61
 
62
- # Incoming email will be directed to this host
63
- # Thredded.email_incoming_host = 'example.com'
64
-
65
62
  # Emails going out will prefix the "Subject:" with the following string
66
63
  # Thredded.email_outgoing_prefix = '[My Forum] '
67
64
 
68
- # Reply to field for email notifications
69
- # Thredded.email_reply_to = -> postable { "#{postable.hash_id}@#{Thredded.email_incoming_host}" }
70
-
71
65
  # ==> View Configuration
72
66
  # Set the layout for rendering the thredded views.
73
67
  Thredded.layout = 'thredded/application'
@@ -76,14 +70,18 @@ Thredded.layout = 'thredded/application'
76
70
  # Customize the way Thredded handles post formatting.
77
71
 
78
72
  # Change the default html-pipeline filters used by thredded.
79
- # E.g. to remove BBCode support:
80
- # Thredded::ContentFormatter.pipeline_filters -= [HTML::Pipeline::BbcodeFilter]
73
+ # E.g. to replace default emoji filter with your own:
74
+ # Thredded::ContentFormatter.after_markup_filters[
75
+ # Thredded::ContentFormatter.after_markup_filters.index(HTML::Pipeline::EmojiFilter)] = MyEmojiFilter
81
76
 
82
77
  # Change the HTML sanitization settings used by Thredded.
83
78
  # See the Sanitize docs for more information on the underlying library: https://github.com/rgrove/sanitize/#readme
84
79
  # E.g. to allow a custom element <custom-element>:
85
80
  # Thredded::ContentFormatter.whitelist[:elements] += %w(custom-element)
86
81
 
82
+ # ==> User autocompletion (Private messages and @-mentions)
83
+ # Thredded.autocomplete_min_length = 2 lower to 1 if have 1-letter names -- increase if you want
84
+
87
85
  # ==> Error Handling
88
86
  # By default Thredded just renders a flash alert on errors such as Topic not found, or Login required.
89
87
  # Below is an example of overriding the default behavior on LoginRequired:
@@ -96,3 +94,17 @@ Thredded.layout = 'thredded/application'
96
94
  # end
97
95
  # end
98
96
  # end
97
+
98
+ # ==> View hooks
99
+ #
100
+ # Customize the UI before/after/replacing individual components.
101
+ # See the full list of view hooks and their arguments by running:
102
+ #
103
+ # $ grep view_hooks -R --include '*.html.erb' "$(bundle show thredded)"
104
+ #
105
+ # Rails.application.config.to_prepare do
106
+ # Thredded.view_hooks.post_form.content_text_area.config.before do |form:, **args|
107
+ # # This is called in the Thredded view context, so all Thredded helpers and URLs are accessible here directly.
108
+ # 'hi'
109
+ # end
110
+ # end
@@ -1,12 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  namespace :thredded do
3
- desc 'Destroy messageboard and all related data'
4
- task :destroy, [:slug] => :environment do |_, args|
5
- Thredded::MessageboardDestroyer.new(args.slug).run
6
- end
7
-
8
- task :nuke, [:slug] => :destroy
9
-
10
3
  namespace :install do
11
4
  desc 'Copy emoji to the Rails `public/emoji` directory'
12
5
  task :emoji do
data/lib/thredded.rb CHANGED
@@ -5,15 +5,21 @@ require 'active_record_union'
5
5
  require 'db_text_search'
6
6
  require 'friendly_id'
7
7
  require 'html/pipeline'
8
- require 'html/pipeline/at_mention_filter'
9
- require 'html/pipeline/bbcode_filter'
8
+ require 'html/pipeline/sanitization_filter'
10
9
  require 'html/pipeline/vimeo/vimeo_filter'
11
10
  require 'html/pipeline/youtube/youtube_filter'
11
+ require 'rinku'
12
12
  require 'kaminari'
13
13
  require 'rb-gravatar'
14
14
  require 'active_job'
15
15
  require 'inline_svg'
16
16
 
17
+ # Require these explictly to make sure they are not reloaded.
18
+ # This allows for configuring them by accessing class methods in the initializer.
19
+ require 'thredded/html_pipeline/at_mention_filter'
20
+ require 'thredded/html_pipeline/autolink_filter'
21
+ require 'thredded/html_pipeline/kramdown_filter'
22
+
17
23
  # Asset compilation
18
24
  require 'autoprefixer-rails'
19
25
  require 'autosize/rails'
@@ -26,12 +32,11 @@ require 'thredded/engine'
26
32
 
27
33
  module Thredded
28
34
  mattr_accessor \
35
+ :autocomplete_min_length,
29
36
  :active_user_threshold,
30
37
  :avatar_url,
31
38
  :email_from,
32
- :email_incoming_host,
33
39
  :email_outgoing_prefix,
34
- :email_reply_to,
35
40
  :layout,
36
41
  :messageboards_order,
37
42
  :user_class,
@@ -60,13 +65,22 @@ module Thredded
60
65
  self.active_user_threshold = 5.minutes
61
66
  self.admin_column = :admin
62
67
  self.avatar_url = ->(user) { Gravatar.src(user.email, 128, 'mm') }
63
- self.email_reply_to = -> (postable) { "#{postable.hash_id}@#{Thredded.email_incoming_host}" }
64
68
  self.layout = 'thredded/application'
65
69
  self.moderator_column = :admin
66
70
  self.user_name_column = :name
67
71
  self.content_visible_while_pending_moderation = true
68
72
  self.show_topic_followers = false
69
73
  self.messageboards_order = :position
74
+ self.autocomplete_min_length = 2
75
+
76
+ # @return [Thredded::AllViewHooks] View hooks configuration.
77
+ def self.view_hooks
78
+ instance = Thredded::AllViewHooks.instance
79
+ unless instance
80
+ fail '`Thredded.view_hooks` must be configured in a `Rails.application.config.to_prepare` block!'
81
+ end
82
+ instance
83
+ end
70
84
 
71
85
  def self.user_display_name_method
72
86
  @@user_display_name_method || user_name_column