thredded 0.16.15 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -23
- data/app/assets/javascripts/thredded/components/preview_area.es6 +3 -1
- data/app/commands/thredded/create_messageboard.rb +2 -2
- data/app/controllers/concerns/thredded/render_preview.rb +6 -0
- data/app/controllers/thredded/application_controller.rb +5 -10
- data/app/controllers/thredded/topics_controller.rb +0 -6
- data/app/forms/thredded/private_topic_form.rb +1 -1
- data/app/helpers/thredded/application_helper.rb +3 -3
- data/app/helpers/thredded/urls_helper.rb +1 -1
- data/app/mailer_previews/thredded/base_mailer_preview.rb +5 -5
- data/app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb +1 -1
- data/app/models/concerns/thredded/notifier_preference.rb +1 -1
- data/app/models/concerns/thredded/post_common.rb +8 -7
- data/app/models/concerns/thredded/topic_common.rb +1 -1
- data/app/models/concerns/thredded/user_topic_read_state_common.rb +5 -5
- data/app/models/thredded/messageboard.rb +3 -4
- data/app/models/thredded/notifications_for_followed_topics.rb +1 -1
- data/app/models/thredded/post.rb +3 -2
- data/app/models/thredded/post_moderation_record.rb +12 -13
- data/app/models/thredded/private_post.rb +2 -2
- data/app/models/thredded/private_topic.rb +4 -2
- data/app/models/thredded/topic.rb +2 -2
- data/app/models/thredded/user_detail.rb +1 -1
- data/app/models/thredded/user_extender.rb +1 -1
- data/app/view_models/thredded/post_view.rb +1 -0
- data/app/view_models/thredded/posts_page_view.rb +10 -9
- data/app/view_models/thredded/private_topics_page_view.rb +10 -6
- data/app/view_models/thredded/topic_posts_page_view.rb +16 -3
- data/app/view_models/thredded/topics_page_view.rb +9 -6
- data/app/views/layouts/thredded/application.html.erb +2 -2
- data/app/views/thredded/messageboards/_form.html.erb +3 -3
- data/app/views/thredded/moderation/_post_moderation_record.html.erb +3 -3
- data/app/views/thredded/posts_common/_content.html.erb +1 -1
- data/app/views/thredded/posts_common/actions/_quote.html.erb +1 -1
- data/app/views/thredded/shared/_page.html.erb +1 -1
- data/app/views/thredded/shared/nav/_standalone.html.erb +2 -2
- data/bin/create_migration_fixture +23 -0
- data/bin/rubocop +11 -0
- data/config/i18n-tasks.yml +6 -1
- data/config/locales/de.yml +2 -0
- data/config/locales/en.yml +3 -1
- data/config/locales/es.yml +2 -0
- data/config/locales/fr.yml +2 -0
- data/config/locales/it.yml +4 -2
- data/config/locales/pl.yml +2 -0
- data/config/locales/pt-BR.yml +2 -0
- data/config/locales/ru.yml +2 -0
- data/config/locales/zh-CN.yml +2 -0
- data/db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb +5 -5
- data/db/upgrade_migrations/20180110200009_upgrade_thredded_v0_14_to_v0_15.rb +1 -1
- data/lib/generators/thredded/install/templates/initializer.rb +3 -3
- data/lib/thredded/arel_compat.rb +1 -42
- data/lib/thredded/base_migration.rb +2 -2
- data/lib/thredded/collection_to_strings_with_cache_renderer.rb +91 -28
- data/lib/thredded/compat.rb +35 -0
- data/lib/thredded/content_formatter.rb +30 -8
- data/lib/thredded/database_seeder.rb +11 -4
- data/lib/thredded/db_tools.rb +3 -5
- data/lib/thredded/email_transformer.rb +2 -2
- data/lib/thredded/engine.rb +1 -1
- data/lib/thredded/formatting_demo_content.rb +21 -21
- data/lib/thredded/html_pipeline/at_mention_filter.rb +1 -1
- data/lib/thredded/html_pipeline/onebox_filter.rb +3 -3
- data/lib/thredded/html_pipeline/utils.rb +1 -1
- data/lib/thredded/version.rb +1 -1
- data/lib/thredded.rb +3 -23
- metadata +56 -29
@@ -3,24 +3,25 @@
|
|
3
3
|
module Thredded
|
4
4
|
# A view model for a page of PostViews.
|
5
5
|
class PostsPageView
|
6
|
-
delegate :
|
6
|
+
delegate :each,
|
7
|
+
:each_with_index,
|
8
|
+
:map,
|
9
|
+
:size,
|
10
|
+
:to_a,
|
7
11
|
:to_ary,
|
8
12
|
:present?,
|
9
13
|
to: :@post_views
|
10
14
|
delegate :total_pages,
|
11
15
|
:current_page,
|
12
16
|
:limit_value,
|
13
|
-
to: :@
|
14
|
-
|
15
|
-
# @return [Thredded::BaseTopicView]
|
16
|
-
attr_reader :topic
|
17
|
+
to: :@posts_paginator
|
17
18
|
|
18
19
|
# @param user [Thredded.user_class] the user who is viewing the posts page
|
19
|
-
# @param paginated_scope [ActiveRecord::Relation<Thredded::PostCommon>]
|
20
|
-
def initialize(user, paginated_scope
|
21
|
-
@
|
20
|
+
# @param paginated_scope [ActiveRecord::Relation<Thredded::PostCommon>] a kaminari-decorated ".page" scope
|
21
|
+
def initialize(user, paginated_scope)
|
22
|
+
@posts_paginator = paginated_scope
|
22
23
|
@post_views = paginated_scope.map do |post|
|
23
|
-
Thredded::PostView.new(post, Pundit.policy!(user, post)
|
24
|
+
Thredded::PostView.new(post, Pundit.policy!(user, post))
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -3,7 +3,11 @@
|
|
3
3
|
module Thredded
|
4
4
|
# A view model for a page of BaseTopicViews.
|
5
5
|
class PrivateTopicsPageView
|
6
|
-
delegate :
|
6
|
+
delegate :each,
|
7
|
+
:each_with_index,
|
8
|
+
:map,
|
9
|
+
:size,
|
10
|
+
:to_a,
|
7
11
|
:to_ary,
|
8
12
|
:blank?,
|
9
13
|
:empty?,
|
@@ -11,13 +15,13 @@ module Thredded
|
|
11
15
|
delegate :total_pages,
|
12
16
|
:current_page,
|
13
17
|
:limit_value,
|
14
|
-
to: :@
|
18
|
+
to: :@topics_paginator
|
15
19
|
|
16
|
-
# @param user [Thredded.user_class] the user who is viewing the
|
17
|
-
# @param topics_page_scope [ActiveRecord::Relation<Thredded::
|
20
|
+
# @param user [Thredded.user_class] the user who is viewing the private topics page
|
21
|
+
# @param topics_page_scope [ActiveRecord::Relation<Thredded::PrivateTopic>] a kaminari-decorated ".page" scope
|
18
22
|
def initialize(user, topics_page_scope)
|
19
|
-
@
|
20
|
-
@topic_views = @
|
23
|
+
@topics_paginator = refine_scope(topics_page_scope)
|
24
|
+
@topic_views = @topics_paginator.with_read_states(user).map do |(topic, read_state)|
|
21
25
|
Thredded::PrivateTopicView.new(topic, read_state, Pundit.policy!(user, topic))
|
22
26
|
end
|
23
27
|
end
|
@@ -2,15 +2,28 @@
|
|
2
2
|
|
3
3
|
module Thredded
|
4
4
|
# A view model for a page of PostViews of a Topic.
|
5
|
-
class TopicPostsPageView
|
5
|
+
class TopicPostsPageView
|
6
|
+
delegate :each,
|
7
|
+
:each_with_index,
|
8
|
+
:map,
|
9
|
+
:size,
|
10
|
+
:to_a,
|
11
|
+
:to_ary,
|
12
|
+
:present?,
|
13
|
+
to: :@post_views
|
14
|
+
delegate :total_pages,
|
15
|
+
:current_page,
|
16
|
+
:limit_value,
|
17
|
+
to: :@posts_paginator
|
18
|
+
|
6
19
|
# @return [Thredded::BaseTopicView]
|
7
20
|
attr_reader :topic
|
8
21
|
|
9
22
|
# @param user [Thredded.user_class] the user who is viewing the posts page
|
10
23
|
# @param topic [Thredded::TopicCommon]
|
11
|
-
# @param paginated_scope [ActiveRecord::Relation<Thredded::PostCommon>]
|
24
|
+
# @param paginated_scope [ActiveRecord::Relation<Thredded::PostCommon>] a kaminari-decorated ".page" scope
|
12
25
|
def initialize(user, topic, paginated_scope)
|
13
|
-
@
|
26
|
+
@posts_paginator = paginated_scope
|
14
27
|
@topic = "#{paginated_scope.reflect_on_association(:postable).klass}View".constantize.from_user(topic, user)
|
15
28
|
prev_read = false
|
16
29
|
@post_views = paginated_scope.map.with_index do |post, i|
|
@@ -8,18 +8,21 @@ module Thredded
|
|
8
8
|
:blank?,
|
9
9
|
:empty?,
|
10
10
|
:[],
|
11
|
+
:each,
|
12
|
+
:map,
|
13
|
+
:size,
|
11
14
|
to: :@topic_views
|
12
15
|
delegate :total_pages,
|
13
16
|
:current_page,
|
14
17
|
:limit_value,
|
15
|
-
to: :@
|
18
|
+
to: :@topics_paginator
|
16
19
|
|
17
|
-
# @param user [Thredded.user_class] the user who is viewing the
|
18
|
-
# @param topics_page_scope [ActiveRecord::Relation<Thredded::Topic>]
|
19
|
-
# @param topic_view_class [Class] view_model for topic instances
|
20
|
+
# @param user [Thredded.user_class] the user who is viewing the topics page
|
21
|
+
# @param topics_page_scope [ActiveRecord::Relation<Thredded::Topic>] a kaminari-decorated ".page" scope
|
22
|
+
# @param topic_view_class [Class<TopicView>] view_model for topic instances
|
20
23
|
def initialize(user, topics_page_scope, topic_view_class: TopicView)
|
21
|
-
@
|
22
|
-
@topic_views = @
|
24
|
+
@topics_paginator = refine_scope(topics_page_scope)
|
25
|
+
@topic_views = @topics_paginator.with_read_and_follow_states(user).map do |(topic, read_state, follow)|
|
23
26
|
topic_view_class.new(topic, read_state, follow, Pundit.policy!(user, topic))
|
24
27
|
end
|
25
28
|
end
|
@@ -5,12 +5,12 @@
|
|
5
5
|
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
|
6
6
|
<%= stylesheet_link_tag 'thredded', 'data-turbolinks-track': 'reload' %>
|
7
7
|
<%= csrf_meta_tag %>
|
8
|
-
<%= csp_meta_tag
|
8
|
+
<%= csp_meta_tag %>
|
9
9
|
<%= javascript_include_tag 'thredded',
|
10
10
|
async: !Rails.application.config.assets.debug,
|
11
11
|
defer: true,
|
12
12
|
'data-turbolinks-track': 'reload' %>
|
13
|
-
|
13
|
+
<%= RailsGravatar.prefetch_dns_tag %>
|
14
14
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
15
15
|
</head>
|
16
16
|
<body>
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<%= form_for messageboard, html: { class: 'thredded--form' } do |f| %>
|
2
2
|
<ul class="thredded--form-list">
|
3
3
|
<li>
|
4
|
-
<%= f.label t('thredded.messageboard.form.title_label') %>
|
4
|
+
<%= f.label :name, t('thredded.messageboard.form.title_label') %>
|
5
5
|
<%= f.text_field :name, required: true %>
|
6
6
|
<%= render 'thredded/shared/field_errors', messages: f.object.errors[:name] %>
|
7
7
|
</li>
|
8
8
|
<li>
|
9
|
-
<%= f.label t('thredded.messageboard.form.description_label') %>
|
9
|
+
<%= f.label :description, t('thredded.messageboard.form.description_label') %>
|
10
10
|
<%= f.text_field :description %>
|
11
11
|
</li>
|
12
12
|
<li>
|
13
|
-
<%= f.label t('thredded.messageboard.form.messageboard_group_id_label') %>
|
13
|
+
<%= f.label :messageboard_group_id, t('thredded.messageboard.form.messageboard_group_id_label') %>
|
14
14
|
<%= f.collection_select :messageboard_group_id, Thredded::MessageboardGroup.all, :id, :name,
|
15
15
|
include_blank: t('thredded.messageboard.form.no_group') %>
|
16
16
|
</li>
|
@@ -13,13 +13,13 @@
|
|
13
13
|
time_ago: time_ago(record.created_at)
|
14
14
|
}
|
15
15
|
%>
|
16
|
-
<article class="thredded--post-moderation-record thredded--post-moderation-record-<%= record.moderation_state %>">
|
16
|
+
<article id="<%= dom_id(post) %>" class="thredded--post-moderation-record thredded--post-moderation-record-<%= record.moderation_state %>">
|
17
17
|
<header class="thredded--post-moderation-record--header">
|
18
18
|
<p class="thredded--post-moderation-record--moderation-state-notice">
|
19
19
|
<% if record.approved? %>
|
20
|
-
<%= t('thredded.moderation.post_approved_html', moderation_state_notice_args) %>
|
20
|
+
<%= t('thredded.moderation.post_approved_html', **moderation_state_notice_args) %>
|
21
21
|
<% elsif record.blocked? %>
|
22
|
-
<%= t('thredded.moderation.post_blocked_html', moderation_state_notice_args) %>
|
22
|
+
<%= t('thredded.moderation.post_blocked_html', **moderation_state_notice_args) %>
|
23
23
|
<% end %>
|
24
24
|
</p>
|
25
25
|
<% if post && post.content != record.post_content %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= link_to t('thredded.posts.quote_btn'),
|
1
|
+
<%= link_to t('thredded.posts.quote_btn'), post.quote_url_params,
|
2
2
|
'data-thredded-quote-post' => post.quote_path,
|
3
3
|
class: 'thredded--post--quote thredded--post--dropdown--actions--item',
|
4
4
|
rel: 'nofollow' %>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<%# If thredded JS is loaded via an [async] script, the JS may
|
9
9
|
run before or after DOMContentLoaded. Expose a flag to Thredded
|
10
10
|
so it can initialize correctly. %>
|
11
|
-
<%= javascript_tag 'data-turbolinks-eval': 'false',
|
11
|
+
<%= javascript_tag 'data-turbolinks-eval': 'false', nonce: true do %>
|
12
12
|
document.addEventListener('DOMContentLoaded', function() {
|
13
13
|
(window.Thredded = window.Thredded || {}).DOMContentLoadedFired = true;
|
14
14
|
});
|
@@ -2,11 +2,11 @@
|
|
2
2
|
<% resource_name = Thredded.user_class_name.demodulize.underscore %>
|
3
3
|
<% if thredded_signed_in? %>
|
4
4
|
<%= link_to main_app.send(:"destroy_#{resource_name}_session_path"), method: :delete do %>
|
5
|
-
|
5
|
+
<%= t('thredded.nav.sign_out') %>
|
6
6
|
<% end %>
|
7
7
|
<% else %>
|
8
8
|
<%= link_to main_app.send(:"new_#{resource_name}_session_path") do %>
|
9
|
-
|
9
|
+
<%= t('thredded.nav.sign_in') %>
|
10
10
|
<% end %>
|
11
11
|
<% end %>
|
12
12
|
</li>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# edit constants in lib/thredded/db_tools.rb
|
4
|
+
# git checkout v0.x.0 -b create-0.x-migration-fixture
|
5
|
+
# bundle
|
6
|
+
|
7
|
+
DIR=$(pwd)
|
8
|
+
|
9
|
+
cd spec/dummy && DB=sqlite3 rails db:environment:set RAILS_ENV=development
|
10
|
+
cd $DIR
|
11
|
+
DB=sqlite3 rake db:drop db:create db:migrate db:miniseed_dump
|
12
|
+
|
13
|
+
cd spec/dummy && DB=postgresql rails db:environment:set RAILS_ENV=development
|
14
|
+
cd $DIR
|
15
|
+
DB=postgresql rake db:drop db:create db:migrate db:miniseed_dump
|
16
|
+
|
17
|
+
cd spec/dummy && DB=mysql2 rails db:environment:set RAILS_ENV=development
|
18
|
+
cd $DIR
|
19
|
+
DB=mysql2 rake db:drop db:create db:migrate db:miniseed_dump
|
20
|
+
|
21
|
+
git add `pwd`/spec/migration/*.dump
|
22
|
+
|
23
|
+
git commit -em "add sample data for 0.8 base for migration spec"
|
data/bin/rubocop
CHANGED
@@ -12,6 +12,17 @@ require 'pathname'
|
|
12
12
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
13
13
|
Pathname.new(__FILE__).realpath)
|
14
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
|
+
|
15
26
|
require 'rubygems'
|
16
27
|
require 'bundler/setup'
|
17
28
|
|
data/config/i18n-tasks.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# i18n-tasks finds and manages missing and unused translations
|
2
|
-
# See https://github.com/glebm/i18n-tasks/blob/
|
2
|
+
# See https://github.com/glebm/i18n-tasks/blob/main/templates/config/i18n-tasks.yml
|
3
3
|
|
4
4
|
# Do not consider these keys missing:
|
5
5
|
ignore_missing:
|
@@ -15,3 +15,8 @@ data:
|
|
15
15
|
yaml:
|
16
16
|
write:
|
17
17
|
line_width: 110
|
18
|
+
|
19
|
+
## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
|
20
|
+
ignore_inconsistent_interpolations:
|
21
|
+
- 'thredded.users.posts_count.one'
|
22
|
+
- 'thredded.users.started_topics_count.one'
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
@@ -127,6 +127,8 @@ en:
|
|
127
127
|
moderation_users: Users
|
128
128
|
private_topics: Private Messages
|
129
129
|
settings: Notification Settings
|
130
|
+
sign_in: Sign In / Register
|
131
|
+
sign_out: Sign Out
|
130
132
|
unread_topics: Unread
|
131
133
|
null_user_name: Deleted user
|
132
134
|
posts:
|
@@ -262,7 +264,7 @@ en:
|
|
262
264
|
last_active_html: Last active %{time_ago}
|
263
265
|
posted_in_topic_html: Posted in %{topic_link}
|
264
266
|
posts_count:
|
265
|
-
one: Posted
|
267
|
+
one: Posted once
|
266
268
|
other: Posted %{count} times
|
267
269
|
recent_activity: :thredded.recent_activity
|
268
270
|
send_private_message: Send private message
|
data/config/locales/es.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/config/locales/it.yml
CHANGED
@@ -127,6 +127,8 @@ it:
|
|
127
127
|
moderation_users: Utenti
|
128
128
|
private_topics: Messaggi Privati
|
129
129
|
settings: Impostazioni Notifiche
|
130
|
+
sign_in: Entra
|
131
|
+
sign_out: Esci
|
130
132
|
unread_topics: Non letto
|
131
133
|
null_user_name: Utente cancellato
|
132
134
|
posts:
|
@@ -266,13 +268,13 @@ it:
|
|
266
268
|
last_active_html: Ultima attività %{time_ago}
|
267
269
|
posted_in_topic_html: Ha scritto in %{topic_link}
|
268
270
|
posts_count:
|
269
|
-
one: Ha commentato
|
271
|
+
one: Ha commentato una volta
|
270
272
|
other: Ha commentato %{count} volte
|
271
273
|
recent_activity: :thredded.recent_activity
|
272
274
|
send_private_message: Invia un messaggio privato
|
273
275
|
started_topic_html: Ha iniziato %{topic_link}
|
274
276
|
started_topics_count:
|
275
|
-
one: Ha iniziato
|
277
|
+
one: Ha iniziato una discussione
|
276
278
|
other: Ha iniziato %{count} discussioni
|
277
279
|
user_posted_in_topic_html: "%{user_link} ha commentato in %{topic_link}"
|
278
280
|
user_since_html: Utente da %{time_ago}
|
data/config/locales/pl.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/config/locales/zh-CN.yml
CHANGED
@@ -6,11 +6,11 @@ class UpgradeV07ToV08 < Thredded::BaseMigration
|
|
6
6
|
def up
|
7
7
|
closed_messageboards = Thredded::Messageboard.unscoped.where(closed: true).to_a
|
8
8
|
if closed_messageboards.present?
|
9
|
-
fail ActiveRecord::MigrationError,
|
10
|
-
There are #{closed_messageboards.length} closed Messageboards:
|
11
|
-
#{closed_messageboards.map { |m| "#{m.name} (id=#{m.id})" }.join("\n")}
|
12
|
-
Support for closed messageboards has been removed in thredded v0.8.0.
|
13
|
-
Delete or un-close these messageboards and consider using the "paranoia" gem to support soft deletion instead.
|
9
|
+
fail ActiveRecord::MigrationError, <<~TEXT
|
10
|
+
There are #{closed_messageboards.length} closed Messageboards:
|
11
|
+
#{closed_messageboards.map { |m| "#{m.name} (id=#{m.id})" }.join("\n")}
|
12
|
+
Support for closed messageboards has been removed in thredded v0.8.0.
|
13
|
+
Delete or un-close these messageboards and consider using the "paranoia" gem to support soft deletion instead.
|
14
14
|
TEXT
|
15
15
|
end
|
16
16
|
remove_index :thredded_messageboards, name: :index_thredded_messageboards_on_closed
|
@@ -86,6 +86,6 @@ class UpgradeThreddedV014ToV015 < Thredded::BaseMigration
|
|
86
86
|
def remove_string_limit(table, column, type: :text, indices: [])
|
87
87
|
indices.each { |(_, options)| remove_index table, name: options[:name] }
|
88
88
|
change_column table, column, type, limit: nil
|
89
|
-
indices.each { |
|
89
|
+
indices.each { |(columns, options)| add_index table, columns, **options }
|
90
90
|
end
|
91
91
|
end
|
@@ -29,8 +29,8 @@ Thredded.user_path = ->(user) {
|
|
29
29
|
# This method is used by Thredded controllers and views to fetch the currently signed-in user
|
30
30
|
Thredded.current_user_method = :"current_#{Thredded.user_class_name.demodulize.underscore}"
|
31
31
|
|
32
|
-
# User avatar URL.
|
33
|
-
Thredded.avatar_url = ->(user) {
|
32
|
+
# User avatar URL. rails_gravatar gem is used by default:
|
33
|
+
Thredded.avatar_url = ->(user) { RailsGravatar.src(user.email, 156, 'mm') }
|
34
34
|
|
35
35
|
# ==> Permissions Configuration
|
36
36
|
# By default, thredded uses a simple permission model, where all the users can post to all message boards,
|
@@ -124,7 +124,7 @@ Thredded.layout = 'thredded/application'
|
|
124
124
|
# Change the HTML sanitization settings used by Thredded.
|
125
125
|
# See the Sanitize docs for more information on the underlying library: https://github.com/rgrove/sanitize/#readme
|
126
126
|
# E.g. to allow a custom element <custom-element>:
|
127
|
-
# Thredded::ContentFormatter.
|
127
|
+
# Thredded::ContentFormatter.allowlist[:elements] += %w(custom-element)
|
128
128
|
|
129
129
|
# ==> User autocompletion (Private messages and @-mentions)
|
130
130
|
# Thredded.autocomplete_min_length = 2 lower to 1 if have 1-letter names -- increase if you want
|
data/lib/thredded/arel_compat.rb
CHANGED
@@ -1,60 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
unless Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2 || Rails::VERSION::MAJOR > 5
|
4
|
-
require 'thredded/rails_lt_5_2_arel_case_node.rb'
|
5
|
-
end
|
6
|
-
|
7
3
|
module Thredded
|
8
4
|
module ArelCompat
|
9
5
|
module_function
|
10
6
|
|
11
|
-
# On Rails >= 5, this method simply returns `relation.pluck(*columns)`.
|
12
|
-
#
|
13
|
-
# Rails 4 `pluck` does not support Arel nodes and attributes. This method does.
|
14
|
-
#
|
15
|
-
# This is an external method because monkey-patching `pluck` would
|
16
|
-
# have compatibility issues, see:
|
17
|
-
#
|
18
|
-
# https://github.com/thredded/thredded/issues/842
|
19
|
-
# https://blog.newrelic.com/engineering/ruby-agent-module-prepend-alias-method-chains/
|
20
|
-
if Rails::VERSION::MAJOR > 4
|
21
|
-
def pluck(relation, *columns)
|
22
|
-
relation.pluck(*columns)
|
23
|
-
end
|
24
|
-
else
|
25
|
-
def pluck(relation, *columns)
|
26
|
-
relation.pluck(*columns.map do |n|
|
27
|
-
if n.is_a?(Arel::Node)
|
28
|
-
Arel.sql(n.to_sql)
|
29
|
-
elsif n.is_a?(Arel::Attributes::Attribute)
|
30
|
-
n.name
|
31
|
-
else
|
32
|
-
n
|
33
|
-
end
|
34
|
-
end)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
7
|
# @param [#connection] engine
|
39
8
|
# @param [Arel::Nodes::Node] a integer node
|
40
9
|
# @param [Arel::Nodes::Node] b integer node
|
41
10
|
# @return [Arel::Nodes::Node] a / b
|
42
11
|
def integer_division(engine, a, b)
|
43
|
-
if
|
12
|
+
if /mysql|mariadb/i.match?(engine.connection.adapter_name)
|
44
13
|
Arel::Nodes::InfixOperation.new('DIV', a, b)
|
45
14
|
else
|
46
15
|
Arel::Nodes::Division.new(a, b)
|
47
16
|
end
|
48
17
|
end
|
49
|
-
|
50
|
-
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2 || Rails::VERSION::MAJOR > 5
|
51
|
-
def true_value(_engine)
|
52
|
-
true
|
53
|
-
end
|
54
|
-
else
|
55
|
-
def true_value(engine)
|
56
|
-
engine.connection.adapter_name =~ /sqlite|mysql|mariadb/i ? 1 : true
|
57
|
-
end
|
58
|
-
end
|
59
18
|
end
|
60
19
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thredded
|
4
|
-
class BaseMigration <
|
4
|
+
class BaseMigration < ActiveRecord::Migration[5.1]
|
5
5
|
protected
|
6
6
|
|
7
7
|
def user_id_type
|
@@ -15,7 +15,7 @@ module Thredded
|
|
15
15
|
|
16
16
|
# @return [Integer, nil] the maximum number of codepoints that can be indexed for a primary key or index.
|
17
17
|
def max_key_length
|
18
|
-
return nil unless
|
18
|
+
return nil unless /mysql|maria/i.match?(connection.adapter_name)
|
19
19
|
# Conservatively assume that innodb_large_prefix is **disabled**.
|
20
20
|
# If it were enabled, the maximum key length would instead be 768 utf8mb4 characters.
|
21
21
|
191
|