thredded 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.mkdn +26 -0
- data/README.mkdn +52 -7
- data/app/assets/images/thredded/moderation.svg +4 -0
- data/app/assets/images/thredded/private-messages.svg +1 -1
- data/app/assets/images/thredded/settings.svg +1 -1
- data/app/assets/stylesheets/thredded/_base.scss +1 -1
- data/app/assets/stylesheets/thredded/_thredded.scss +1 -0
- data/app/assets/stylesheets/thredded/base/_buttons.scss +16 -0
- data/app/assets/stylesheets/thredded/base/_grid.scss +12 -0
- data/app/assets/stylesheets/thredded/components/_base.scss +4 -0
- data/app/assets/stylesheets/thredded/components/_messageboard.scss +1 -13
- data/app/assets/stylesheets/thredded/components/_topic-header.scss +27 -0
- data/app/assets/stylesheets/thredded/layout/_main-navigation.scss +1 -1
- data/app/assets/stylesheets/thredded/layout/_moderation.scss +45 -0
- data/app/assets/stylesheets/thredded/layout/_navigation.scss +20 -6
- data/app/assets/stylesheets/thredded/layout/_search-navigation.scss +2 -2
- data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +5 -3
- data/app/commands/thredded/autofollow_mentioned_users.rb +32 -0
- data/app/commands/thredded/moderate_post.rb +35 -0
- data/app/commands/thredded/notify_following_users.rb +18 -0
- data/app/commands/thredded/notify_private_topic_users.rb +4 -4
- data/app/controllers/thredded/application_controller.rb +6 -25
- data/app/controllers/thredded/messageboards_controller.rb +5 -3
- data/app/controllers/thredded/moderation_controller.rb +56 -0
- data/app/controllers/thredded/post_permalinks_controller.rb +1 -1
- data/app/controllers/thredded/posts_controller.rb +4 -2
- data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -1
- data/app/controllers/thredded/private_topics_controller.rb +2 -3
- data/app/controllers/thredded/theme_previews_controller.rb +3 -3
- data/app/controllers/thredded/topics_controller.rb +32 -11
- data/app/forms/thredded/topic_form.rb +1 -0
- data/app/helpers/thredded/application_helper.rb +26 -1
- data/app/helpers/thredded/urls_helper.rb +7 -5
- data/app/jobs/thredded/auto_follow_and_notify_job.rb +13 -0
- data/app/jobs/thredded/notify_private_topic_users_job.rb +3 -4
- data/app/mailer_previews/thredded/post_mailer_preview.rb +2 -2
- data/app/mailers/thredded/post_mailer.rb +2 -2
- data/app/models/concerns/thredded/content_moderation_state.rb +53 -0
- data/app/models/concerns/thredded/moderation_state.rb +13 -0
- data/app/models/concerns/thredded/post_common.rb +6 -71
- data/app/models/concerns/thredded/topic_common.rb +26 -11
- data/app/models/concerns/thredded/user_topic_read_state_common.rb +4 -0
- data/app/models/thredded/messageboard.rb +2 -0
- data/app/models/thredded/post.rb +24 -0
- data/app/models/thredded/post_moderation_record.rb +45 -0
- data/app/models/thredded/private_post.rb +15 -0
- data/app/models/thredded/private_topic.rb +8 -0
- data/app/models/thredded/topic.rb +39 -0
- data/app/models/thredded/user_detail.rb +11 -0
- data/app/models/thredded/user_extender.rb +14 -0
- data/app/models/thredded/user_topic_follow.rb +20 -0
- data/app/policies/thredded/messageboard_policy.rb +15 -0
- data/app/policies/thredded/post_policy.rb +17 -1
- data/app/policies/thredded/private_post_policy.rb +1 -1
- data/app/policies/thredded/private_topic_policy.rb +1 -1
- data/app/policies/thredded/topic_policy.rb +18 -1
- data/app/view_models/thredded/base_topic_view.rb +0 -13
- data/app/view_models/thredded/post_view.rb +8 -1
- data/app/view_models/thredded/posts_page_view.rb +6 -8
- data/app/view_models/thredded/private_topic_view.rb +8 -0
- data/app/view_models/thredded/private_topics_page_view.rb +24 -0
- data/app/view_models/thredded/topic_posts_page_view.rb +17 -0
- data/app/view_models/thredded/topic_view.rb +27 -1
- data/app/view_models/thredded/topics_page_view.rb +2 -4
- data/app/views/thredded/moderation/_post.html.erb +7 -0
- data/app/views/thredded/moderation/_post_moderation_actions.html.erb +12 -0
- data/app/views/thredded/moderation/_post_moderation_record.html.erb +43 -0
- data/app/views/thredded/moderation/history.html.erb +19 -0
- data/app/views/thredded/moderation/pending.html.erb +29 -0
- data/app/views/thredded/post_mailer/{at_notification.html.erb → post_notification.html.erb} +1 -1
- data/app/views/thredded/post_mailer/{at_notification.text.erb → post_notification.text.erb} +1 -1
- data/app/views/thredded/posts/_post.html.erb +8 -1
- data/app/views/thredded/posts_common/_actions.html.erb +11 -0
- data/app/views/thredded/posts_common/_content.html.erb +5 -0
- data/app/views/thredded/posts_common/_header.html.erb +5 -0
- data/app/views/thredded/private_posts/_private_post.html.erb +5 -1
- data/app/views/thredded/shared/_nav.html.erb +1 -0
- data/app/views/thredded/shared/_page.html.erb +1 -1
- data/app/views/thredded/shared/nav/_moderation.html.erb +13 -0
- data/app/views/thredded/shared/nav/_private_topics.html.erb +1 -2
- data/app/views/thredded/topics/_header.html.erb +15 -0
- data/app/views/thredded/topics/index.html.erb +2 -2
- data/app/views/thredded/topics/new.html.erb +1 -1
- data/config/locales/en.yml +26 -5
- data/config/locales/pt-BR.yml +23 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20160329231848_create_thredded.rb +40 -5
- data/db/seeds.rb +5 -5
- data/db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb +1 -2
- data/db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb +56 -0
- data/heroku.gemfile.lock +20 -18
- data/lib/generators/thredded/install/templates/initializer.rb +15 -0
- data/lib/html/pipeline/at_mention_filter.rb +5 -2
- data/lib/thredded.rb +4 -0
- data/lib/thredded/at_users.rb +3 -2
- data/lib/thredded/content_formatter.rb +81 -0
- data/lib/thredded/version.rb +1 -1
- metadata +28 -10
- data/app/commands/thredded/notify_mentioned_users.rb +0 -55
- data/app/jobs/thredded/at_notifier_job.rb +0 -12
- data/app/mailer_previews/thredded/private_post_mailer_preview.rb +0 -12
- data/app/mailers/thredded/private_post_mailer.rb +0 -17
- data/app/views/thredded/posts_common/_post.html.erb +0 -26
- data/app/views/thredded/private_post_mailer/at_notification.html.erb +0 -13
data/db/seeds.rb
CHANGED
@@ -15,8 +15,8 @@ module Thredded
|
|
15
15
|
attr_reader :user, :users, :messageboard, :topics, :private_topics, :posts
|
16
16
|
|
17
17
|
SKIP_CALLBACKS = [
|
18
|
-
[Thredded::Post, :commit, :after, :
|
19
|
-
[Thredded::PrivatePost, :commit, :after, :
|
18
|
+
[Thredded::Post, :commit, :after, :auto_follow_and_notify],
|
19
|
+
[Thredded::PrivatePost, :commit, :after, :notify_users],
|
20
20
|
].freeze
|
21
21
|
|
22
22
|
def self.run(users: 200, topics: 55, posts: (1..60))
|
@@ -44,12 +44,12 @@ module Thredded
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def create_first_user
|
47
|
-
@user ||= ::User.first ||
|
47
|
+
@user ||= ::User.first || FactoryGirl.create(:user, :approved, :admin, name: 'Joe', email: 'joe@example.com')
|
48
48
|
end
|
49
49
|
|
50
|
-
def create_users(count:
|
50
|
+
def create_users(count:)
|
51
51
|
log "Creating #{count} users..."
|
52
|
-
@users = [user] + FactoryGirl.create_list(:user, count)
|
52
|
+
@users = [user] + FactoryGirl.create_list(:user, count, *(%i(approved) if rand > 0.1))
|
53
53
|
end
|
54
54
|
|
55
55
|
def create_messageboard
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# rubocop:disable Metrics/MethodLength
|
3
|
+
class UpgradeV04ToV05 < ActiveRecord::Migration
|
4
|
+
def change
|
5
|
+
# Topic following
|
6
|
+
create_table :thredded_user_topic_follows do |t|
|
7
|
+
t.integer :user_id, null: false
|
8
|
+
t.integer :topic_id, null: false
|
9
|
+
t.datetime :created_at, null: false
|
10
|
+
t.integer :reason, limit: 1
|
11
|
+
t.index [:user_id, :topic_id], name: :thredded_user_topic_follows_user_topic, unique: true
|
12
|
+
end
|
13
|
+
|
14
|
+
# Moderation
|
15
|
+
change_table :thredded_posts, bulk: true do |t|
|
16
|
+
t.integer :moderation_state, null: false, default: 1
|
17
|
+
t.index [:moderation_state, :updated_at],
|
18
|
+
order: { updated_at: :asc },
|
19
|
+
name: :index_thredded_posts_for_display
|
20
|
+
end
|
21
|
+
change_column_default :thredded_posts, :moderation_state, from: 1, to: nil
|
22
|
+
|
23
|
+
change_table :thredded_topics, bulk: true do |t|
|
24
|
+
t.integer :moderation_state, null: false, default: 1
|
25
|
+
t.index %i(moderation_state sticky updated_at),
|
26
|
+
order: { sticky: :desc, updated_at: :desc },
|
27
|
+
name: :index_thredded_topics_for_display
|
28
|
+
end
|
29
|
+
change_column_default :thredded_topics, :moderation_state, from: 1, to: nil
|
30
|
+
|
31
|
+
change_table :thredded_user_details do |t|
|
32
|
+
t.integer :moderation_state, null: false, default: 1
|
33
|
+
t.timestamp :moderation_state_changed_at
|
34
|
+
t.index %i(moderation_state moderation_state_changed_at),
|
35
|
+
order: { moderation_state_changed_at: :desc },
|
36
|
+
name: :index_thredded_user_details_for_moderations
|
37
|
+
end
|
38
|
+
change_column_default :thredded_user_details, :moderation_state, from: 1, to: 0 # pending_moderation
|
39
|
+
|
40
|
+
create_table :thredded_post_moderation_records do |t|
|
41
|
+
t.references :post
|
42
|
+
t.references :messageboard
|
43
|
+
t.text :post_content, limit: 65_535
|
44
|
+
t.references :post_user
|
45
|
+
t.text :post_user_name
|
46
|
+
t.references :moderator
|
47
|
+
t.integer :moderation_state, null: false
|
48
|
+
t.integer :previous_moderation_state, null: false
|
49
|
+
t.timestamp :created_at, null: false
|
50
|
+
t.index [:messageboard_id, :created_at],
|
51
|
+
order: { created_at: :desc },
|
52
|
+
name: :index_thredded_moderation_records_for_display
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
# rubocop:enable Metrics/MethodLength
|
data/heroku.gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/amatsuda/kaminari
|
3
|
-
revision:
|
3
|
+
revision: f93231e6e7624dde21b528726ec471029ffb8b02
|
4
4
|
specs:
|
5
5
|
kaminari (1.0.0.alpha)
|
6
6
|
actionpack (>= 3.0.0)
|
@@ -17,7 +17,7 @@ GIT
|
|
17
17
|
PATH
|
18
18
|
remote: .
|
19
19
|
specs:
|
20
|
-
thredded (0.
|
20
|
+
thredded (0.5.0)
|
21
21
|
active_record_union (>= 1.1.1)
|
22
22
|
autoprefixer-rails
|
23
23
|
autosize-rails
|
@@ -86,7 +86,7 @@ GEM
|
|
86
86
|
tzinfo (~> 1.1)
|
87
87
|
addressable (2.4.0)
|
88
88
|
arel (7.0.0)
|
89
|
-
autoprefixer-rails (6.3.6)
|
89
|
+
autoprefixer-rails (6.3.6.2)
|
90
90
|
execjs
|
91
91
|
autosize-rails (1.18.17)
|
92
92
|
rails (>= 3.1)
|
@@ -109,7 +109,7 @@ GEM
|
|
109
109
|
db_text_search (0.2.0)
|
110
110
|
activerecord (>= 4.1.15, < 6.0)
|
111
111
|
erubis (2.7.0)
|
112
|
-
execjs (2.
|
112
|
+
execjs (2.7.0)
|
113
113
|
factory_girl (4.7.0)
|
114
114
|
activesupport (>= 3.0.0)
|
115
115
|
factory_girl_rails (4.7.0)
|
@@ -128,12 +128,12 @@ GEM
|
|
128
128
|
nokogiri (>= 1.4)
|
129
129
|
html-pipeline-vimeo (0.1.1)
|
130
130
|
html-pipeline (~> 2.0)
|
131
|
-
html-pipeline-youtube (0.1.
|
131
|
+
html-pipeline-youtube (0.1.3)
|
132
132
|
html-pipeline (~> 2.0)
|
133
133
|
htmlentities (4.3.4)
|
134
134
|
http_accept_language (2.0.5)
|
135
135
|
i18n (0.7.0)
|
136
|
-
inline_svg (0.
|
136
|
+
inline_svg (0.8.0)
|
137
137
|
activesupport (>= 4.0.4)
|
138
138
|
loofah (>= 2.0)
|
139
139
|
nokogiri (~> 1.6)
|
@@ -151,25 +151,27 @@ GEM
|
|
151
151
|
mail (2.6.4)
|
152
152
|
mime-types (>= 1.16, < 4)
|
153
153
|
method_source (0.8.2)
|
154
|
-
mime-types (3.
|
154
|
+
mime-types (3.1)
|
155
155
|
mime-types-data (~> 3.2015)
|
156
|
-
mime-types-data (3.2016.
|
157
|
-
mini_portile2 (2.
|
158
|
-
minitest (5.
|
159
|
-
multi_json (1.12.
|
156
|
+
mime-types-data (3.2016.0521)
|
157
|
+
mini_portile2 (2.1.0)
|
158
|
+
minitest (5.9.0)
|
159
|
+
multi_json (1.12.1)
|
160
160
|
newrelic_rpm (3.15.2.317)
|
161
161
|
nio4r (1.2.1)
|
162
|
-
nokogiri (1.6.
|
163
|
-
mini_portile2 (~> 2.
|
162
|
+
nokogiri (1.6.8)
|
163
|
+
mini_portile2 (~> 2.1.0)
|
164
|
+
pkg-config (~> 1.1.7)
|
164
165
|
nokogumbo (1.4.7)
|
165
166
|
nokogiri
|
166
167
|
pg (0.18.4)
|
168
|
+
pkg-config (1.1.7)
|
167
169
|
puma (3.4.0)
|
168
170
|
pundit (1.1.0)
|
169
171
|
activesupport (>= 3.0.0)
|
170
172
|
rack (2.0.0.rc1)
|
171
173
|
json
|
172
|
-
rack-canonical-host (0.2.
|
174
|
+
rack-canonical-host (0.2.2)
|
173
175
|
addressable (> 0, < 3)
|
174
176
|
rack (>= 1.0.0, < 3)
|
175
177
|
rack-test (0.6.3)
|
@@ -215,8 +217,8 @@ GEM
|
|
215
217
|
rb-gravatar (1.0.5)
|
216
218
|
ref (2.0.0)
|
217
219
|
request_store (1.3.1)
|
218
|
-
rinku (
|
219
|
-
rollbar (2.11.
|
220
|
+
rinku (2.0.0)
|
221
|
+
rollbar (2.11.5)
|
220
222
|
multi_json
|
221
223
|
sanitize (4.0.1)
|
222
224
|
crass (~> 1.0.2)
|
@@ -247,12 +249,12 @@ GEM
|
|
247
249
|
ref
|
248
250
|
thor (0.19.1)
|
249
251
|
thread_safe (0.3.5)
|
250
|
-
tilt (2.0.
|
252
|
+
tilt (2.0.5)
|
251
253
|
turbolinks (2.5.3)
|
252
254
|
coffee-rails
|
253
255
|
tzinfo (1.2.2)
|
254
256
|
thread_safe (~> 0.1)
|
255
|
-
websocket-driver (0.6.
|
257
|
+
websocket-driver (0.6.4)
|
256
258
|
websocket-extensions (>= 0.1.0)
|
257
259
|
websocket-extensions (0.1.2)
|
258
260
|
|
@@ -34,6 +34,9 @@ Thredded.moderator_column = :admin
|
|
34
34
|
# The name of the admin flag column on the users table.
|
35
35
|
Thredded.admin_column = :admin
|
36
36
|
|
37
|
+
# Whether posts and topics pending moderation are visible to regular users.
|
38
|
+
Thredded.content_visible_while_pending_moderation = true
|
39
|
+
|
37
40
|
# This model can be customized further by overriding a handful of methods on the User model.
|
38
41
|
# For more information, see app/models/thredded/user_extender.rb.
|
39
42
|
|
@@ -54,6 +57,18 @@ Thredded.admin_column = :admin
|
|
54
57
|
# Set the layout for rendering the thredded views.
|
55
58
|
Thredded.layout = 'thredded/application'
|
56
59
|
|
60
|
+
# ==> Post Content Formatting
|
61
|
+
# Customize the way Thredded handles post formatting.
|
62
|
+
|
63
|
+
# Change the default html-pipeline filters used by thredded.
|
64
|
+
# E.g. to remove BBCode support:
|
65
|
+
# Thredded::ContentFormatter.pipeline_filters -= [HTML::Pipeline::BbcodeFilter]
|
66
|
+
|
67
|
+
# Change the HTML sanitization settings used by Thredded.
|
68
|
+
# See the Sanitize docs for more information on the underlying library: https://github.com/rgrove/sanitize/#readme
|
69
|
+
# E.g. to allow a custom element <custom-element>:
|
70
|
+
# Thredded::ContentFormatter.whitelist[:elements] += %w(custom-element)
|
71
|
+
|
57
72
|
# ==> Error Handling
|
58
73
|
# By default Thredded just renders a flash alert on errors such as Topic not found, or Login required.
|
59
74
|
# Below is an example of overriding the default behavior on LoginRequired:
|
@@ -4,15 +4,18 @@ require 'thredded/at_users'
|
|
4
4
|
module HTML
|
5
5
|
class Pipeline
|
6
6
|
class AtMentionFilter < Filter
|
7
|
+
# @param context [Hash]
|
8
|
+
# @options context :users_provider [#call(usernames)] given usernames, returns a list of users.
|
7
9
|
def initialize(text, context = nil, result = nil)
|
8
10
|
super text, context, result
|
9
11
|
@text = text.to_s.delete("\r")
|
10
|
-
@
|
12
|
+
@users_provider = context[:users_provider]
|
11
13
|
@view_context = context[:view_context]
|
12
14
|
end
|
13
15
|
|
14
16
|
def call
|
15
|
-
html
|
17
|
+
return html unless @users_provider
|
18
|
+
html = Thredded::AtUsers.render(@text, @users_provider, @view_context)
|
16
19
|
html.rstrip!
|
17
20
|
html
|
18
21
|
end
|
data/lib/thredded.rb
CHANGED
@@ -46,6 +46,9 @@ module Thredded
|
|
46
46
|
# @return [Symbol] The name of the admin flag column on the users table for the default permissions model
|
47
47
|
mattr_accessor :admin_column
|
48
48
|
|
49
|
+
# @return [Boolean] Whether posts that are pending moderation are visible to regular users.
|
50
|
+
mattr_accessor :content_visible_while_pending_moderation
|
51
|
+
|
49
52
|
self.active_user_threshold = 5.minutes
|
50
53
|
self.admin_column = :admin
|
51
54
|
self.avatar_url = ->(user) { Gravatar.src(user.email, 128, 'mm') }
|
@@ -53,6 +56,7 @@ module Thredded
|
|
53
56
|
self.layout = 'thredded/application'
|
54
57
|
self.moderator_column = :admin
|
55
58
|
self.user_name_column = :name
|
59
|
+
self.content_visible_while_pending_moderation = true
|
56
60
|
|
57
61
|
# @return [Class<Thredded::UserExtender>] the user class from the host application.
|
58
62
|
def self.user_class
|
data/lib/thredded/at_users.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Thredded
|
3
3
|
class AtUsers
|
4
|
-
|
4
|
+
# @param users_provider [#call(usernames)] given usernames, returns a list of users.
|
5
|
+
def self.render(content, users_provider, view_context)
|
5
6
|
at_names = AtNotificationExtractor.new(content).run
|
6
7
|
|
7
8
|
if at_names.any?
|
8
|
-
members =
|
9
|
+
members = users_provider.call(at_names)
|
9
10
|
|
10
11
|
members.each do |member|
|
11
12
|
member_path = Thredded.user_path(view_context, member)
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Thredded
|
3
|
+
# Generates HTML from content source.
|
4
|
+
class ContentFormatter
|
5
|
+
# Sanitization whitelist options.
|
6
|
+
mattr_accessor :whitelist
|
7
|
+
|
8
|
+
self.whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST.deep_merge(
|
9
|
+
elements: HTML::Pipeline::SanitizationFilter::WHITELIST[:elements] + %w(iframe span figure figcaption),
|
10
|
+
transformers: HTML::Pipeline::SanitizationFilter::WHITELIST[:transformers] + [
|
11
|
+
lambda do |env|
|
12
|
+
node = env[:node]
|
13
|
+
|
14
|
+
a_tags = node.css('a')
|
15
|
+
a_tags.each do |a_tag|
|
16
|
+
a_tag['href'] ||= '#'
|
17
|
+
if a_tag['href'].starts_with? 'http'
|
18
|
+
a_tag['target'] = '_blank'
|
19
|
+
a_tag['rel'] = 'nofollow noopener'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
],
|
24
|
+
attributes: {
|
25
|
+
'a' => %w(href rel),
|
26
|
+
'iframe' => %w(src width height frameborder allowfullscreen sandbox seamless),
|
27
|
+
'span' => %w(class),
|
28
|
+
},
|
29
|
+
add_attributes: {
|
30
|
+
'iframe' => {
|
31
|
+
'seamless' => 'seamless',
|
32
|
+
'sandbox' => 'allow-same-origin allow-scripts allow-forms',
|
33
|
+
}
|
34
|
+
}
|
35
|
+
)
|
36
|
+
|
37
|
+
# HTML::Pipeline filters.
|
38
|
+
mattr_accessor :pipeline_filters
|
39
|
+
|
40
|
+
self.pipeline_filters = [
|
41
|
+
HTML::Pipeline::VimeoFilter,
|
42
|
+
HTML::Pipeline::YoutubeFilter,
|
43
|
+
HTML::Pipeline::BbcodeFilter,
|
44
|
+
HTML::Pipeline::MarkdownFilter,
|
45
|
+
HTML::Pipeline::SanitizationFilter,
|
46
|
+
HTML::Pipeline::AtMentionFilter,
|
47
|
+
HTML::Pipeline::EmojiFilter,
|
48
|
+
HTML::Pipeline::AutolinkFilter,
|
49
|
+
].freeze
|
50
|
+
|
51
|
+
# @param view_context [Object] the context of the rendering view.
|
52
|
+
# @param pipeline_options [Hash]
|
53
|
+
def initialize(view_context, pipeline_options = {})
|
54
|
+
@view_context = view_context
|
55
|
+
@pipeline_options = pipeline_options
|
56
|
+
end
|
57
|
+
|
58
|
+
# @param content [String]
|
59
|
+
# @return [String] formatted and sanitized html-safe content.
|
60
|
+
def format_content(content)
|
61
|
+
pipeline = HTML::Pipeline.new(content_pipeline_filters, content_pipeline_options.merge(@pipeline_options))
|
62
|
+
result = pipeline.call(content, view_context: @view_context)
|
63
|
+
result[:output].to_s.html_safe
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
# @return [Array<HTML::Pipeline::Filter]>]
|
69
|
+
def content_pipeline_filters
|
70
|
+
ContentFormatter.pipeline_filters
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Hash] options for HTML::Pipeline.new
|
74
|
+
def content_pipeline_options
|
75
|
+
{
|
76
|
+
asset_root: Rails.application.config.action_controller.asset_host || '',
|
77
|
+
whitelist: ContentFormatter.whitelist
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/thredded/version.rb
CHANGED
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Oliveira
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bbcoder
|
@@ -626,6 +626,7 @@ files:
|
|
626
626
|
- Procfile
|
627
627
|
- README.mkdn
|
628
628
|
- app/assets/images/thredded/breadcrumb-chevron.svg
|
629
|
+
- app/assets/images/thredded/moderation.svg
|
629
630
|
- app/assets/images/thredded/private-messages.svg
|
630
631
|
- app/assets/images/thredded/settings.svg
|
631
632
|
- app/assets/javascripts/thredded.es6
|
@@ -670,20 +671,24 @@ files:
|
|
670
671
|
- app/assets/stylesheets/thredded/components/_topics.scss
|
671
672
|
- app/assets/stylesheets/thredded/layout/_main-container.scss
|
672
673
|
- app/assets/stylesheets/thredded/layout/_main-navigation.scss
|
674
|
+
- app/assets/stylesheets/thredded/layout/_moderation.scss
|
673
675
|
- app/assets/stylesheets/thredded/layout/_navigation.scss
|
674
676
|
- app/assets/stylesheets/thredded/layout/_search-navigation.scss
|
675
677
|
- app/assets/stylesheets/thredded/layout/_user-navigation.scss
|
676
678
|
- app/assets/stylesheets/thredded/utilities/_is-compact.scss
|
677
679
|
- app/assets/stylesheets/thredded/utilities/_is-expanded.scss
|
678
680
|
- app/commands/thredded/at_notification_extractor.rb
|
681
|
+
- app/commands/thredded/autofollow_mentioned_users.rb
|
679
682
|
- app/commands/thredded/members_marked_notified.rb
|
680
683
|
- app/commands/thredded/messageboard_destroyer.rb
|
681
|
-
- app/commands/thredded/
|
684
|
+
- app/commands/thredded/moderate_post.rb
|
685
|
+
- app/commands/thredded/notify_following_users.rb
|
682
686
|
- app/commands/thredded/notify_private_topic_users.rb
|
683
687
|
- app/controllers/thredded/application_controller.rb
|
684
688
|
- app/controllers/thredded/autocomplete_users_controller.rb
|
685
689
|
- app/controllers/thredded/messageboard_groups_controller.rb
|
686
690
|
- app/controllers/thredded/messageboards_controller.rb
|
691
|
+
- app/controllers/thredded/moderation_controller.rb
|
687
692
|
- app/controllers/thredded/post_permalinks_controller.rb
|
688
693
|
- app/controllers/thredded/posts_controller.rb
|
689
694
|
- app/controllers/thredded/preferences_controller.rb
|
@@ -697,17 +702,17 @@ files:
|
|
697
702
|
- app/helpers/thredded/application_helper.rb
|
698
703
|
- app/helpers/thredded/urls_helper.rb
|
699
704
|
- app/jobs/thredded/activity_updater_job.rb
|
700
|
-
- app/jobs/thredded/
|
705
|
+
- app/jobs/thredded/auto_follow_and_notify_job.rb
|
701
706
|
- app/jobs/thredded/notify_private_topic_users_job.rb
|
702
707
|
- app/mailer_previews/thredded/base_mailer_preview.rb
|
703
708
|
- app/mailer_previews/thredded/post_mailer_preview.rb
|
704
|
-
- app/mailer_previews/thredded/private_post_mailer_preview.rb
|
705
709
|
- app/mailer_previews/thredded/private_topic_mailer_preview.rb
|
706
710
|
- app/mailers/thredded/base_mailer.rb
|
707
711
|
- app/mailers/thredded/post_mailer.rb
|
708
|
-
- app/mailers/thredded/private_post_mailer.rb
|
709
712
|
- app/mailers/thredded/private_topic_mailer.rb
|
713
|
+
- app/models/concerns/thredded/content_moderation_state.rb
|
710
714
|
- app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
|
715
|
+
- app/models/concerns/thredded/moderation_state.rb
|
711
716
|
- app/models/concerns/thredded/post_common.rb
|
712
717
|
- app/models/concerns/thredded/topic_common.rb
|
713
718
|
- app/models/concerns/thredded/user_topic_read_state_common.rb
|
@@ -719,6 +724,7 @@ files:
|
|
719
724
|
- app/models/thredded/null_user.rb
|
720
725
|
- app/models/thredded/null_user_topic_read_state.rb
|
721
726
|
- app/models/thredded/post.rb
|
727
|
+
- app/models/thredded/post_moderation_record.rb
|
722
728
|
- app/models/thredded/post_notification.rb
|
723
729
|
- app/models/thredded/private_post.rb
|
724
730
|
- app/models/thredded/private_topic.rb
|
@@ -739,6 +745,7 @@ files:
|
|
739
745
|
- app/models/thredded/user_permissions/write/none.rb
|
740
746
|
- app/models/thredded/user_preference.rb
|
741
747
|
- app/models/thredded/user_private_topic_read_state.rb
|
748
|
+
- app/models/thredded/user_topic_follow.rb
|
742
749
|
- app/models/thredded/user_topic_read_state.rb
|
743
750
|
- app/policies/thredded/messageboard_group_policy.rb
|
744
751
|
- app/policies/thredded/messageboard_policy.rb
|
@@ -751,7 +758,9 @@ files:
|
|
751
758
|
- app/view_models/thredded/post_view.rb
|
752
759
|
- app/view_models/thredded/posts_page_view.rb
|
753
760
|
- app/view_models/thredded/private_topic_view.rb
|
761
|
+
- app/view_models/thredded/private_topics_page_view.rb
|
754
762
|
- app/view_models/thredded/topic_email_view.rb
|
763
|
+
- app/view_models/thredded/topic_posts_page_view.rb
|
755
764
|
- app/view_models/thredded/topic_view.rb
|
756
765
|
- app/view_models/thredded/topics_page_view.rb
|
757
766
|
- app/views/layouts/thredded/application.html.erb
|
@@ -771,21 +780,27 @@ files:
|
|
771
780
|
- app/views/thredded/messageboards/edit.html.erb
|
772
781
|
- app/views/thredded/messageboards/index.html.erb
|
773
782
|
- app/views/thredded/messageboards/new.html.erb
|
774
|
-
- app/views/thredded/
|
775
|
-
- app/views/thredded/
|
783
|
+
- app/views/thredded/moderation/_post.html.erb
|
784
|
+
- app/views/thredded/moderation/_post_moderation_actions.html.erb
|
785
|
+
- app/views/thredded/moderation/_post_moderation_record.html.erb
|
786
|
+
- app/views/thredded/moderation/history.html.erb
|
787
|
+
- app/views/thredded/moderation/pending.html.erb
|
788
|
+
- app/views/thredded/post_mailer/post_notification.html.erb
|
789
|
+
- app/views/thredded/post_mailer/post_notification.text.erb
|
776
790
|
- app/views/thredded/posts/_form.html.erb
|
777
791
|
- app/views/thredded/posts/_post.html.erb
|
778
792
|
- app/views/thredded/posts/_user.html.erb
|
779
793
|
- app/views/thredded/posts/edit.html.erb
|
794
|
+
- app/views/thredded/posts_common/_actions.html.erb
|
795
|
+
- app/views/thredded/posts_common/_content.html.erb
|
780
796
|
- app/views/thredded/posts_common/_form.html.erb
|
781
|
-
- app/views/thredded/posts_common/
|
797
|
+
- app/views/thredded/posts_common/_header.html.erb
|
782
798
|
- app/views/thredded/posts_common/form/_after_content.html.erb
|
783
799
|
- app/views/thredded/posts_common/form/_before_content.html.erb
|
784
800
|
- app/views/thredded/posts_common/form/_content_field.html.erb
|
785
801
|
- app/views/thredded/preferences/_form.html.erb
|
786
802
|
- app/views/thredded/preferences/_header.html.erb
|
787
803
|
- app/views/thredded/preferences/edit.html.erb
|
788
|
-
- app/views/thredded/private_post_mailer/at_notification.html.erb
|
789
804
|
- app/views/thredded/private_posts/_form.html.erb
|
790
805
|
- app/views/thredded/private_posts/_private_post.html.erb
|
791
806
|
- app/views/thredded/private_topic_mailer/message_notification.html.erb
|
@@ -806,6 +821,7 @@ files:
|
|
806
821
|
- app/views/thredded/shared/_header.html.erb
|
807
822
|
- app/views/thredded/shared/_nav.html.erb
|
808
823
|
- app/views/thredded/shared/_page.html.erb
|
824
|
+
- app/views/thredded/shared/nav/_moderation.html.erb
|
809
825
|
- app/views/thredded/shared/nav/_notification_preferences.html.erb
|
810
826
|
- app/views/thredded/shared/nav/_private_topics.html.erb
|
811
827
|
- app/views/thredded/shared/nav/_standalone.html.erb
|
@@ -832,6 +848,7 @@ files:
|
|
832
848
|
- db/seeds.rb
|
833
849
|
- db/upgrade_migrations/20160410111522_upgrade_v0_2_to_v0_3.rb
|
834
850
|
- db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb
|
851
|
+
- db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb
|
835
852
|
- heroku.gemfile
|
836
853
|
- heroku.gemfile.lock
|
837
854
|
- lib/generators/thredded/install/USAGE
|
@@ -842,6 +859,7 @@ files:
|
|
842
859
|
- lib/tasks/thredded_tasks.rake
|
843
860
|
- lib/thredded.rb
|
844
861
|
- lib/thredded/at_users.rb
|
862
|
+
- lib/thredded/content_formatter.rb
|
845
863
|
- lib/thredded/engine.rb
|
846
864
|
- lib/thredded/errors.rb
|
847
865
|
- lib/thredded/main_app_route_delegator.rb
|