Module: Thredded
- Defined in:
- lib/thredded.rb,
lib/thredded/compat.rb,
lib/thredded/engine.rb,
lib/thredded/errors.rb,
lib/thredded/version.rb,
lib/thredded/db_tools.rb,
app/models/thredded/post.rb,
lib/thredded/arel_compat.rb,
app/models/thredded/stats.rb,
app/models/thredded/topic.rb,
lib/thredded/base_notifier.rb,
lib/thredded/base_migration.rb,
lib/thredded/users_provider.rb,
lib/thredded/webpack_assets.rb,
app/forms/thredded/post_form.rb,
app/models/thredded/category.rb,
lib/thredded/database_seeder.rb,
app/forms/thredded/topic_form.rb,
app/models/thredded/null_user.rb,
lib/thredded/content_formatter.rb,
lib/thredded/email_transformer.rb,
lib/thredded/view_hooks/config.rb,
app/helpers/thredded/nav_helper.rb,
app/models/thredded/user_detail.rb,
app/helpers/thredded/icon_helper.rb,
app/helpers/thredded/urls_helper.rb,
app/mailers/thredded/base_mailer.rb,
app/mailers/thredded/post_mailer.rb,
app/models/thredded/messageboard.rb,
app/models/thredded/private_post.rb,
app/models/thredded/private_user.rb,
lib/thredded/html_pipeline/utils.rb,
lib/thredded/view_hooks/renderer.rb,
app/models/thredded/private_topic.rb,
app/models/thredded/user_extender.rb,
app/policies/thredded/post_policy.rb,
app/forms/thredded/edit_topic_form.rb,
app/helpers/thredded/render_helper.rb,
app/models/thredded/topic_category.rb,
app/policies/thredded/topic_policy.rb,
app/view_models/thredded/post_view.rb,
app/commands/thredded/mark_all_read.rb,
app/commands/thredded/moderate_post.rb,
app/models/thredded/user_preference.rb,
app/view_models/thredded/topic_view.rb,
lib/thredded/email_transformer/base.rb,
app/forms/thredded/private_post_form.rb,
lib/thredded/formatting_demo_content.rb,
app/forms/thredded/private_topic_form.rb,
app/models/thredded/messageboard_user.rb,
app/models/thredded/user_topic_follow.rb,
app/notifiers/thredded/email_notifier.rb,
lib/thredded/email_transformer/onebox.rb,
app/commands/thredded/autofollow_users.rb,
app/helpers/thredded/moderation_helper.rb,
app/jobs/thredded/activity_updater_job.rb,
app/models/thredded/messageboard_group.rb,
app/view_hooks/thredded/all_view_hooks.rb,
lib/thredded/email_transformer/spoiler.rb,
app/helpers/thredded/application_helper.rb,
app/forms/thredded/user_preferences_form.rb,
app/models/concerns/thredded/post_common.rb,
app/view_models/thredded/base_topic_view.rb,
app/view_models/thredded/posts_page_view.rb,
lib/thredded/html_pipeline/onebox_filter.rb,
app/commands/thredded/create_messageboard.rb,
app/controllers/thredded/posts_controller.rb,
app/mailers/thredded/private_topic_mailer.rb,
app/models/concerns/thredded/topic_common.rb,
app/models/thredded/user_topic_read_state.rb,
app/policies/thredded/messageboard_policy.rb,
app/policies/thredded/private_post_policy.rb,
app/view_models/thredded/topic_email_view.rb,
app/view_models/thredded/topics_page_view.rb,
app/controllers/thredded/topics_controller.rb,
app/models/concerns/thredded/search_parser.rb,
app/models/concerns/thredded/topics_search.rb,
app/models/thredded/post_moderation_record.rb,
app/models/thredded/user_post_notification.rb,
app/policies/thredded/private_topic_policy.rb,
app/view_models/thredded/messageboard_view.rb,
lib/thredded/html_pipeline/autolink_filter.rb,
lib/thredded/html_pipeline/kramdown_filter.rb,
app/view_models/thredded/private_topic_view.rb,
app/commands/thredded/notify_following_users.rb,
app/jobs/thredded/auto_follow_and_notify_job.rb,
lib/thredded/html_pipeline/at_mention_filter.rb,
app/models/concerns/thredded/moderation_state.rb,
app/models/thredded/user_permissions/read/all.rb,
lib/thredded/html_pipeline/spoiler_tag_filter.rb,
app/controllers/thredded/moderation_controller.rb,
app/models/thredded/null_user_topic_read_state.rb,
app/models/thredded/user_permissions/write/all.rb,
app/view_models/thredded/topic_posts_page_view.rb,
lib/thredded/html_pipeline/wrap_iframes_filter.rb,
app/commands/thredded/at_notification_extractor.rb,
app/controllers/thredded/application_controller.rb,
app/controllers/thredded/preferences_controller.rb,
app/controllers/thredded/read_states_controller.rb,
app/models/thredded/user_permissions/admin/none.rb,
app/models/thredded/user_permissions/write/none.rb,
app/policies/thredded/messageboard_group_policy.rb,
app/commands/thredded/notify_private_topic_users.rb,
app/controllers/concerns/thredded/render_preview.rb,
app/jobs/thredded/notify_private_topic_users_job.rb,
app/mailer_previews/thredded/base_mailer_preview.rb,
app/mailer_previews/thredded/post_mailer_preview.rb,
app/models/concerns/thredded/notifier_preference.rb,
app/models/thredded/user_messageboard_preference.rb,
app/view_models/thredded/messageboard_group_view.rb,
app/controllers/concerns/thredded/new_post_params.rb,
app/controllers/thredded/messageboards_controller.rb,
app/controllers/thredded/post_previews_controller.rb,
app/controllers/thredded/private_posts_controller.rb,
app/models/thredded/user_private_topic_read_state.rb,
app/view_models/thredded/private_topics_page_view.rb,
lib/generators/thredded/install/install_generator.rb,
app/controllers/concerns/thredded/new_topic_params.rb,
app/controllers/thredded/private_topics_controller.rb,
app/controllers/thredded/theme_previews_controller.rb,
app/controllers/thredded/topic_previews_controller.rb,
app/models/thredded/user_permissions/moderate/none.rb,
app/controllers/thredded/post_permalinks_controller.rb,
app/models/thredded/notifications_for_private_topics.rb,
app/models/concerns/thredded/content_moderation_state.rb,
app/models/thredded/notifications_for_followed_topics.rb,
app/controllers/thredded/autocomplete_users_controller.rb,
lib/thredded/collection_to_strings_with_cache_renderer.rb,
app/controllers/thredded/messageboard_groups_controller.rb,
app/controllers/concerns/thredded/new_private_post_params.rb,
app/controllers/thredded/private_post_previews_controller.rb,
app/mailer_previews/thredded/private_topic_mailer_preview.rb,
app/models/concerns/thredded/user_topic_read_state_common.rb,
app/controllers/concerns/thredded/new_private_topic_params.rb,
app/controllers/thredded/private_topic_previews_controller.rb,
app/controllers/thredded/private_post_permalinks_controller.rb,
app/models/thredded/user_permissions/admin/if_admin_column_true.rb,
app/models/thredded/messageboard_notifications_for_followed_topics.rb,
app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb,
app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb,
app/models/thredded/user_permissions/message/readers_of_writeable_boards.rb
Overview
rubocop:enable HandleExceptions
Defined Under Namespace
Modules: ApplicationHelper, ArelCompat, Compat, ContentModerationState, DbTools, EmailTransformer, Errors, FormattingDemoContent, Generators, HtmlPipeline, IconHelper, ModeratePost, ModerationHelper, ModerationState, NavHelper, NewPostParams, NewPrivatePostParams, NewPrivateTopicParams, NewTopicParams, NotifierPreference, PostCommon, RenderHelper, RenderPreview, TopicCommon, UrlsHelper, UserExtender, UserPermissions, UserTopicReadStateCommon, UsersProvider, ViewHooks, WebpackAssets Classes: ActivityUpdaterJob, AllViewHooks, ApplicationController, AtNotificationExtractor, AutoFollowAndNotifyJob, AutocompleteUsersController, AutofollowUsers, BaseMailer, BaseMailerPreview, BaseMigration, BaseNotifier, BaseTopicView, Category, CollectionToStringsWithCacheRenderer, ContentFormatter, CreateMessageboard, DatabaseSeeder, EditTopicForm, EmailNotifier, Engine, Error, FriendlyIdReservedWordsAndPagination, MarkAllRead, Messageboard, MessageboardGroup, MessageboardGroupPolicy, MessageboardGroupView, MessageboardGroupsController, MessageboardNotificationsForFollowedTopics, MessageboardPolicy, MessageboardUser, MessageboardView, MessageboardsController, ModerationController, NotificationsForFollowedTopics, NotificationsForPrivateTopics, NotifyFollowingUsers, NotifyPrivateTopicUsers, NotifyPrivateTopicUsersJob, NullUser, NullUserTopicReadState, Post, PostForm, PostMailer, PostMailerPreview, PostModerationRecord, PostPermalinksController, PostPolicy, PostPreviewsController, PostView, PostsController, PostsPageView, PreferencesController, PrivatePost, PrivatePostForm, PrivatePostPermalinksController, PrivatePostPolicy, PrivatePostPreviewsController, PrivatePostsController, PrivateTopic, PrivateTopicForm, PrivateTopicMailer, PrivateTopicMailerPreview, PrivateTopicPolicy, PrivateTopicPreviewsController, PrivateTopicView, PrivateTopicsController, PrivateTopicsPageView, PrivateUser, ReadStatesController, SearchParser, Stats, ThemePreviewsController, Topic, TopicCategory, TopicEmailView, TopicForm, TopicPolicy, TopicPostsPageView, TopicPreviewsController, TopicView, TopicsController, TopicsPageView, TopicsSearch, UserDetail, UserMessageboardPreference, UserPostNotification, UserPreference, UserPreferencesForm, UserPrivateTopicReadState, UserTopicFollow, UserTopicReadState, UsersProviderWithCache
Constant Summary collapse
- VERSION =
'1.1.0'
Class Attribute Summary collapse
-
.active_user_threshold ⇒ ActiveSupport::Duration
How long the users are considered online after their last action.
-
.admin_column ⇒ Symbol
The name of the admin flag column on the users table for the default permissions model.
-
.auto_follow_when_creating_topic ⇒ Boolean
Whether the user should get subscribed to a new topic they’ve created.
-
.auto_follow_when_posting_in_topic ⇒ Boolean
Whether the user should get subscribed to a topic after posting in it.
-
.autocomplete_min_length ⇒ Number
Minimum length to trigger username auto-completion for @-mentions and private message recipients.
-
.avatar_url ⇒ Proc
A lambda that returns the avatar URL for the given user.
-
.content_visible_while_pending_moderation ⇒ Boolean
Whether posts that are pending moderation are visible to regular users.
-
.current_user_method ⇒ Symbol
The name of the method used by Thredded controllers and views to get the currently signed-in user.
-
.currently_online_enabled ⇒ Boolean
Whether the list of users who are currently online is displayed.
-
.email_from ⇒ String
Sender email for Thredded notification emails.
-
.email_outgoing_prefix ⇒ String
Email subject prefix.
-
.layout ⇒ String
The layout to use for rendering Thredded views.
-
.messageboard_name_length_range ⇒ Range<Integer>
The range of valid messageboard name lengths.
-
.messageboards_order ⇒ :position, ...
How to calculate the position of messageboards in a list: :position set the position manually (new messageboards go to the bottom, by creation timestamp) :last_post_at_desc most recent post first :topics_count_desc most topics first.
-
.moderator_column ⇒ Symbol
The name of the moderator flag column on the users table for the default permissions model.
-
.parent_mailer ⇒ String
The name of the parent mailer class for Thredded mailers.
-
.posts_per_page ⇒ Number
The number of posts to display per page in a topic.
-
.private_messaging_enabled ⇒ Boolean
Whether the private messaging functionality is enabled.
-
.routes_id_constraint ⇒ Object
By default, thredded uses integers for record ID route constraints.
-
.show_messageboard_delete_button ⇒ Boolean
Whether admin users see button to delete entire messageboards on the messageboard edit page.
-
.show_messageboard_group_page ⇒ Boolean
Whether MessageboardGroup show page is enabled.
-
.show_topic_followers ⇒ Boolean
Whether users that are following a topic are listed on the topic page.
-
.slugifier ⇒ Proc
The proc that Thredded uses to generate URL slugs from text.
-
.topic_title_length_range ⇒ Range<Integer>
The range of valid topic title lengths.
-
.topics_per_page ⇒ Number
The number of topics to display per page.
-
.user_class_name ⇒ String
readonly
The name of the user class.
-
.user_display_name_method ⇒ Symbol
The name of the method used by Thredded to display users.
-
.user_name_column ⇒ Symbol
The user table column that contains the username.
-
.user_path(view_context, user) ⇒ String
Path to the user evaluated in the specified context.
Class Method Summary collapse
-
.notifiers ⇒ Array
The notifiers, by default just the EmailNotifier.
- .notifiers=(notifiers) ⇒ Object
-
.posts_page_view(scope:, current_user:) ⇒ PostsPageView
Returns a view for the given posts’ scope, applying read permission filters to the scope.
-
.standalone_layout? ⇒ Boolean
Whether the layout is a thredded layout as opposed to the application layout.
-
.user_class ⇒ Class<Thredded::UserExtender>
The user class from the host application.
- .user_class=(user_class_name) ⇒ Object
-
.view_hooks ⇒ Thredded::AllViewHooks
View hooks configuration.
Class Attribute Details
.active_user_threshold ⇒ ActiveSupport::Duration
Returns How long the users are considered online after their last action.
112 113 114 |
# File 'lib/thredded.rb', line 112 def active_user_threshold @active_user_threshold end |
.admin_column ⇒ Symbol
Returns The name of the admin flag column on the users table for the default permissions model.
75 76 77 |
# File 'lib/thredded.rb', line 75 def admin_column @admin_column end |
.auto_follow_when_creating_topic ⇒ Boolean
Returns Whether the user should get subscribed to a new topic they’ve created.
141 142 143 |
# File 'lib/thredded.rb', line 141 def auto_follow_when_creating_topic @auto_follow_when_creating_topic end |
.auto_follow_when_posting_in_topic ⇒ Boolean
Returns Whether the user should get subscribed to a topic after posting in it.
144 145 146 |
# File 'lib/thredded.rb', line 144 def auto_follow_when_posting_in_topic @auto_follow_when_posting_in_topic end |
.autocomplete_min_length ⇒ Number
Returns Minimum length to trigger username auto-completion for @-mentions and private message recipients.
127 128 129 |
# File 'lib/thredded.rb', line 127 def autocomplete_min_length @autocomplete_min_length end |
.avatar_url ⇒ Proc
Returns A lambda that returns the avatar URL for the given user.
69 70 71 |
# File 'lib/thredded.rb', line 69 def avatar_url @avatar_url end |
.content_visible_while_pending_moderation ⇒ Boolean
Returns Whether posts that are pending moderation are visible to regular users.
80 81 82 |
# File 'lib/thredded.rb', line 80 def content_visible_while_pending_moderation @content_visible_while_pending_moderation end |
.current_user_method ⇒ Symbol
Returns The name of the method used by Thredded controllers and views to get the currently signed-in user.
60 61 62 |
# File 'lib/thredded.rb', line 60 def current_user_method @current_user_method end |
.currently_online_enabled ⇒ Boolean
Returns Whether the list of users who are currently online is displayed.
109 110 111 |
# File 'lib/thredded.rb', line 109 def currently_online_enabled @currently_online_enabled end |
.email_from ⇒ String
Returns Sender email for Thredded notification emails.
152 153 154 |
# File 'lib/thredded.rb', line 152 def email_from @email_from end |
.email_outgoing_prefix ⇒ String
Returns Email subject prefix.
155 156 157 |
# File 'lib/thredded.rb', line 155 def email_outgoing_prefix @email_outgoing_prefix end |
.layout ⇒ String
Returns The layout to use for rendering Thredded views.
91 92 93 |
# File 'lib/thredded.rb', line 91 def layout @layout end |
.messageboard_name_length_range ⇒ Range<Integer>
Returns The range of valid messageboard name lengths.
172 173 174 |
# File 'lib/thredded.rb', line 172 def @messageboard_name_length_range end |
.messageboards_order ⇒ :position, ...
How to calculate the position of messageboards in a list: :position set the position manually (new messageboards go to the bottom, by creation timestamp) :last_post_at_desc most recent post first :topics_count_desc most topics first
121 122 123 |
# File 'lib/thredded.rb', line 121 def @messageboards_order end |
.moderator_column ⇒ Symbol
Returns The name of the moderator flag column on the users table for the default permissions model.
83 84 85 |
# File 'lib/thredded.rb', line 83 def moderator_column @moderator_column end |
.parent_mailer ⇒ String
Returns The name of the parent mailer class for Thredded mailers.
149 150 151 |
# File 'lib/thredded.rb', line 149 def parent_mailer @parent_mailer end |
.posts_per_page ⇒ Number
Returns The number of posts to display per page in a topic.
96 97 98 |
# File 'lib/thredded.rb', line 96 def posts_per_page @posts_per_page end |
.private_messaging_enabled ⇒ Boolean
Returns Whether the private messaging functionality is enabled.
104 105 106 |
# File 'lib/thredded.rb', line 104 def private_messaging_enabled @private_messaging_enabled end |
.routes_id_constraint ⇒ Object
167 168 169 |
# File 'lib/thredded.rb', line 167 def routes_id_constraint @routes_id_constraint end |
.show_messageboard_delete_button ⇒ Boolean
Returns Whether admin users see button to delete entire messageboards on the messageboard edit page.
86 87 88 |
# File 'lib/thredded.rb', line 86 def @show_messageboard_delete_button end |
.show_messageboard_group_page ⇒ Boolean
Returns Whether MessageboardGroup show page is enabled.
130 131 132 |
# File 'lib/thredded.rb', line 130 def @show_messageboard_group_page end |
.show_topic_followers ⇒ Boolean
Returns Whether users that are following a topic are listed on the topic page.
99 100 101 |
# File 'lib/thredded.rb', line 99 def show_topic_followers @show_topic_followers end |
.slugifier ⇒ Proc
Returns The proc that Thredded uses to generate URL slugs from text.
160 161 162 |
# File 'lib/thredded.rb', line 160 def slugifier @slugifier end |
.topic_title_length_range ⇒ Range<Integer>
Returns The range of valid topic title lengths.
175 176 177 |
# File 'lib/thredded.rb', line 175 def topic_title_length_range @topic_title_length_range end |
.topics_per_page ⇒ Number
Returns The number of topics to display per page.
124 125 126 |
# File 'lib/thredded.rb', line 124 def topics_per_page @topics_per_page end |
.user_class_name ⇒ String (readonly)
Returns The name of the user class.
57 58 59 |
# File 'lib/thredded.rb', line 57 def user_class_name @user_class_name end |
.user_display_name_method ⇒ Symbol
Returns The name of the method used by Thredded to display users.
189 190 191 |
# File 'lib/thredded.rb', line 189 def user_display_name_method @user_display_name_method || user_name_column end |
.user_name_column ⇒ Symbol
Returns The user table column that contains the username. Must be unique.
63 64 65 |
# File 'lib/thredded.rb', line 63 def user_name_column @user_name_column end |
.user_path(view_context, user) ⇒ String
Returns path to the user evaluated in the specified context.
221 222 223 |
# File 'lib/thredded.rb', line 221 def user_path(view_context, user) view_context.instance_exec(user, &@user_path) end |
Class Method Details
.notifiers ⇒ Array
Returns The notifiers, by default just the EmailNotifier.
178 179 180 |
# File 'lib/thredded.rb', line 178 def notifiers @notifiers ||= [Thredded::EmailNotifier.new] end |
.notifiers=(notifiers) ⇒ Object
183 184 185 186 |
# File 'lib/thredded.rb', line 183 def notifiers=(notifiers) notifiers.each { |notifier| Thredded::BaseNotifier.validate_notifier(notifier) } @notifiers = notifiers end |
.posts_page_view(scope:, current_user:) ⇒ PostsPageView
Returns a view for the given posts’ scope, applying read permission filters to the scope. Can be used in main_app, e.g. for showing the recent user posts on the profile page.
238 239 240 241 242 243 244 245 246 |
# File 'lib/thredded.rb', line 238 def posts_page_view(scope:, current_user:) current_user ||= Thredded::NullUser.new Thredded::PostsPageView.new( current_user, Pundit.policy_scope!(current_user, scope) .where(messageboard_id: Pundit.policy_scope!(current_user, Thredded::Messageboard.all).pluck(:id)) .includes(:postable) ) end |
.standalone_layout? ⇒ Boolean
Whether the layout is a thredded layout as opposed to the application layout.
226 227 228 |
# File 'lib/thredded.rb', line 226 def standalone_layout? layout.is_a?(String) && layout.start_with?('thredded/') end |
.user_class ⇒ Class<Thredded::UserExtender>
Returns the user class from the host application.
212 213 214 215 216 |
# File 'lib/thredded.rb', line 212 def user_class # This is nil before the initializer is installed. return nil if @user_class_name.nil? @user_class_name.constantize end |
.user_class=(user_class_name) ⇒ Object
204 205 206 207 208 209 |
# File 'lib/thredded.rb', line 204 def user_class=(user_class_name) unless user_class_name.is_a?(String) fail "Thredded.user_class must be set to a String, got #{user_class_name.inspect}" end @user_class_name = user_class_name end |
.view_hooks ⇒ Thredded::AllViewHooks
Returns View hooks configuration.
133 134 135 136 |
# File 'lib/thredded.rb', line 133 def view_hooks Thredded::AllViewHooks.instance || fail('`Thredded.view_hooks` must be configured in a `Rails.application.config.to_prepare` block!') end |