Module: Thredded
- Defined in:
- lib/thredded/database_seeder.rb,
lib/thredded.rb,
lib/thredded/engine.rb,
lib/thredded/errors.rb,
lib/thredded/version.rb,
app/models/thredded/post.rb,
app/models/thredded/stats.rb,
app/models/thredded/topic.rb,
lib/thredded/search_parser.rb,
lib/thredded/topics_search.rb,
app/models/thredded/category.rb,
app/forms/thredded/topic_form.rb,
app/models/thredded/null_user.rb,
lib/thredded/content_formatter.rb,
app/models/thredded/user_detail.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,
app/models/thredded/private_topic.rb,
app/models/thredded/user_extender.rb,
app/policies/thredded/post_policy.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/null_preference.rb,
app/models/thredded/user_preference.rb,
app/view_models/thredded/topic_view.rb,
app/forms/thredded/private_topic_form.rb,
app/models/thredded/messageboard_user.rb,
app/models/thredded/post_notification.rb,
app/models/thredded/user_topic_follow.rb,
lib/thredded/main_app_route_delegator.rb,
app/jobs/thredded/activity_updater_job.rb,
app/models/thredded/messageboard_group.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,
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/thredded/post_moderation_record.rb,
app/policies/thredded/private_topic_policy.rb,
app/view_models/thredded/private_topic_view.rb,
app/commands/thredded/messageboard_destroyer.rb,
app/commands/thredded/notify_following_users.rb,
app/jobs/thredded/auto_follow_and_notify_job.rb,
app/commands/thredded/members_marked_notified.rb,
app/models/concerns/thredded/moderation_state.rb,
app/models/thredded/user_permissions/read/all.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,
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/autofollow_mentioned_users.rb,
app/commands/thredded/notify_private_topic_users.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/thredded/user_messageboard_preference.rb,
app/view_models/thredded/messageboard_group_view.rb,
app/controllers/thredded/messageboards_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/thredded/private_topics_controller.rb,
app/controllers/thredded/theme_previews_controller.rb,
app/models/thredded/user_permissions/moderate/none.rb,
app/controllers/thredded/post_permalinks_controller.rb,
app/models/concerns/thredded/content_moderation_state.rb,
app/controllers/thredded/autocomplete_users_controller.rb,
app/controllers/thredded/messageboard_groups_controller.rb,
app/mailer_previews/thredded/private_topic_mailer_preview.rb,
app/models/concerns/thredded/user_topic_read_state_common.rb,
app/controllers/thredded/private_post_permalinks_controller.rb,
app/models/thredded/user_permissions/admin/if_admin_column_true.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:disable Metrics/ClassLength
Defined Under Namespace
Modules: ApplicationHelper, ContentModerationState, Errors, Generators, MainAppRouteDelegator, ModeratePost, ModerationState, PostCommon, TopicCommon, UrlsHelper, UserExtender, UserPermissions, UserTopicReadStateCommon Classes: ActivityUpdaterJob, ApplicationController, AtNotificationExtractor, AutoFollowAndNotifyJob, AutocompleteUsersController, AutofollowMentionedUsers, BaseMailer, BaseMailerPreview, BaseTopicView, Category, ContentFormatter, DatabaseSeeder, Engine, Error, FriendlyIdReservedWordsAndPagination, MarkAllRead, MembersMarkedNotified, Messageboard, MessageboardDestroyer, MessageboardGroup, MessageboardGroupPolicy, MessageboardGroupView, MessageboardGroupsController, MessageboardPolicy, MessageboardUser, MessageboardsController, ModerationController, NotifyFollowingUsers, NotifyPrivateTopicUsers, NotifyPrivateTopicUsersJob, NullPreference, NullUser, NullUserTopicReadState, Post, PostMailer, PostMailerPreview, PostModerationRecord, PostNotification, PostPermalinksController, PostPolicy, PostView, PostsController, PostsPageView, PreferencesController, PrivatePost, PrivatePostPermalinksController, PrivatePostPolicy, PrivateTopic, PrivateTopicForm, PrivateTopicMailer, PrivateTopicMailerPreview, PrivateTopicPolicy, PrivateTopicView, PrivateTopicsController, PrivateTopicsPageView, PrivateUser, ReadStatesController, SearchParser, Stats, ThemePreviewsController, Topic, TopicCategory, TopicEmailView, TopicForm, TopicPolicy, TopicPostsPageView, TopicView, TopicsController, TopicsPageView, TopicsSearch, UserDetail, UserMessageboardPreference, UserPreference, UserPreferencesForm, UserPrivateTopicReadState, UserTopicFollow, UserTopicReadState
Constant Summary collapse
- VERSION =
'0.7.0'
Class Method Summary collapse
- .messageboards_order=(value) ⇒ 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_display_name_method ⇒ Object
-
.user_path(view_context, user) ⇒ String
Path to the user evaluated in the specified context.
Instance Method Summary collapse
-
#admin_column ⇒ Symbol
The name of the admin flag column on the users table for the default permissions model.
-
#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 fetch the currently signed-in user.
-
#moderator_column ⇒ Symbol
The name of the moderator flag column on the users table for the default permissions model.
-
#show_topic_followers ⇒ Boolean
Whether users that are following a topic are listed on topic page.
-
#user_display_name_method ⇒ Symbol
The name of the method used by Thredded to display users.
Class Method Details
.messageboards_order=(value) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/thredded.rb', line 76 def self.(value) case value when :position, :topics_count_desc, :last_post_at_desc @@messageboards_order = value # rubocop:disable Style/ClassVars else fail ArgumentError, "Unexpected value for Thredded.messageboards_order: #{value}" end 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.
116 117 118 119 120 121 122 123 124 |
# File 'lib/thredded.rb', line 116 def self.posts_page_view(scope:, current_user:) current_user ||= Thredded::NullUser.new 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.
106 107 108 |
# File 'lib/thredded.rb', line 106 def self.standalone_layout? layout.is_a?(String) && layout.start_with?('thredded/') end |
.user_class ⇒ Class<Thredded::UserExtender>
Returns the user class from the host application.
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/thredded.rb', line 86 def self.user_class fail 'Please use a string instead of a class' if @@user_class.is_a?(Class) if @@user_class.is_a?(String) begin Object.const_get(@@user_class) rescue NameError @@user_class.constantize end end end |
.user_display_name_method ⇒ Object
71 72 73 |
# File 'lib/thredded.rb', line 71 def self.user_display_name_method @@user_display_name_method || user_name_column end |
.user_path(view_context, user) ⇒ String
Returns path to the user evaluated in the specified context.
101 102 103 |
# File 'lib/thredded.rb', line 101 def self.user_path(view_context, user) view_context.instance_exec(user, &@@user_path) end |
Instance Method Details
#admin_column ⇒ Symbol
Returns The name of the admin flag column on the users table for the default permissions model.
49 |
# File 'lib/thredded.rb', line 49 mattr_accessor :admin_column |
#content_visible_while_pending_moderation ⇒ Boolean
Returns Whether posts that are pending moderation are visible to regular users.
52 |
# File 'lib/thredded.rb', line 52 mattr_accessor :content_visible_while_pending_moderation |
#current_user_method ⇒ Symbol
Returns The name of the method used by Thredded controllers and views to fetch the currently signed-in user.
43 |
# File 'lib/thredded.rb', line 43 mattr_accessor :current_user_method |
#moderator_column ⇒ Symbol
Returns The name of the moderator flag column on the users table for the default permissions model.
46 |
# File 'lib/thredded.rb', line 46 mattr_accessor :moderator_column |
#show_topic_followers ⇒ Boolean
Returns Whether users that are following a topic are listed on topic page.
55 |
# File 'lib/thredded.rb', line 55 mattr_accessor :show_topic_followers |
#user_display_name_method ⇒ Symbol
Returns The name of the method used by Thredded to display users.
58 |
# File 'lib/thredded.rb', line 58 mattr_accessor :user_display_name_method |