Module: Commontator

Defined in:
lib/commontator.rb,
lib/commontator/engine.rb,
lib/commontator/version.rb,
lib/commontator/controllers.rb,
app/models/commontator/thread.rb,
lib/commontator/link_renderer.rb,
lib/commontator/shared_helper.rb,
app/models/commontator/comment.rb,
lib/commontator/commontable_config.rb,
lib/commontator/commontator_config.rb,
app/models/commontator/subscription.rb,
lib/commontator/acts_as_commontable.rb,
lib/commontator/acts_as_commontator.rb,
lib/commontator/security_transgression.rb,
app/helpers/commontator/application_helper.rb,
app/mailers/commontator/subscriptions_mailer.rb,
app/controllers/commontator/threads_controller.rb,
app/controllers/commontator/comments_controller.rb,
app/controllers/commontator/application_controller.rb,
app/controllers/commontator/subscriptions_controller.rb

Defined Under Namespace

Modules: ActsAsCommontable, ActsAsCommontator, ApplicationHelper, Controllers, SharedHelper Classes: ApplicationController, Comment, CommentsController, CommontableConfig, CommontatorConfig, Engine, LinkRenderer, SecurityTransgression, Subscription, SubscriptionsController, SubscriptionsMailer, Thread, ThreadsController

Constant Summary collapse

ENGINE_ATTRIBUTES =

Can be set in initializer only

[
  :current_user_proc,
  :javascript_proc,
  :mentions_enabled
]
COMMONTATOR_ATTRIBUTES =

Can be set in initializer or passed as an option to acts_as_commontator

[
  :user_name_proc,
  :user_link_proc,
  :user_avatar_proc,
  :user_email_proc,
  :user_mentions_proc
]
COMMONTABLE_ATTRIBUTES =

Can be set in initializer or passed as an option to acts_as_commontable

[
  :comment_filter,
  :thread_read_proc,
  :thread_moderator_proc,
  :comment_editing,
  :comment_deletion,
  :moderator_permissions,
  :comment_voting,
  :vote_count_proc,
  :comment_order,
  :new_comment_style,
  :comments_per_page,
  :thread_subscription,
  :email_from_proc,
  :commontable_name_proc,
  :comment_url_proc
]
DEPRECATED_ATTRIBUTES =
[
  [:moderators_can_edit_comments, :moderator_permissions],
  [:hide_deleted_comments, :comment_filter],
  [:hide_closed_threads, :thread_read_proc],
  [:wp_link_renderer_proc],
  [:voting_text_proc, :vote_count_proc],
  [:user_name_clickable, :user_link_proc],
  [:user_admin_proc, :thread_moderator_proc],
  [:auto_subscribe_on_comment, :thread_subscription],
  [:can_edit_own_comments, :comment_editing],
  [:can_edit_old_comments, :comment_editing],
  [:can_delete_own_comments, :comment_deletion],
  [:can_delete_old_comments, :comment_deletion],
  [:can_subscribe_to_thread, :thread_subscription],
  [:can_vote_on_comments, :comment_voting],
  [:combine_upvotes_and_downvotes, :vote_count_proc],
  [:comments_order, :comment_order],
  [:closed_threads_are_readable, :thread_read_proc],
  [:deleted_comments_are_visible, :comment_filter],
  [:can_read_thread_proc, :thread_read_proc],
  [:can_edit_thread_proc, :thread_moderator_proc],
  [:admin_can_edit_comments, :moderator_permissions],
  [:subscription_email_enable_proc, :user_email_proc],
  [:comment_name, 'config/locales'],
  [:comment_create_verb_present, 'config/locales'],
  [:comment_create_verb_past, 'config/locales'],
  [:comment_edit_verb_present, 'config/locales'],
  [:comment_edit_verb_past, 'config/locales'],
  [:timestamp_format, 'config/locales'],
  [:subscription_email_to_proc, 'config/locales'],
  [:subscription_email_from_proc, :email_from_proc],
  [:subscription_email_subject_proc, 'config/locales'],
  [:comments_ordered_by_votes, :comment_order],
  [:current_user_method, :current_user_proc],
  [:user_missing_name, 'config/locales'],
  [:user_email_method, :user_email_proc],
  [:user_name_method, :user_name_proc],
  [:commontable_name, :commontable_name_proc],
  [:commontable_id_method],
  [:commontable_url_proc, :comment_url_proc]
]
VERSION =
"5.1.0"

Class Method Summary collapse

Class Method Details

.comment_url(comment, routing_proxy) ⇒ Object



139
140
141
# File 'lib/commontator.rb', line 139

def self.comment_url(comment, routing_proxy)
  commontable_config(comment.thread.commontable).comment_url_proc.call(comment, routing_proxy)
end

.commontable_config(obj) ⇒ Object



111
112
113
# File 'lib/commontator.rb', line 111

def self.commontable_config(obj)
  (obj && obj.is_commontable) ? obj.commontable_config : self
end

.commontable_name(commontable) ⇒ Object



135
136
137
# File 'lib/commontator.rb', line 135

def self.commontable_name(commontable)
  commontable_config(commontable).commontable_name_proc.call(commontable)
end

.commontator_avatar(user, view) ⇒ Object



127
128
129
# File 'lib/commontator.rb', line 127

def self.commontator_avatar(user, view)
  commontator_config(user).user_avatar_proc.call(user, view)
end

.commontator_config(user) ⇒ Object



107
108
109
# File 'lib/commontator.rb', line 107

def self.commontator_config(user)
  (user && user.is_commontator) ? user.commontator_config : self
end

.commontator_email(user, mailer = nil) ⇒ Object



123
124
125
# File 'lib/commontator.rb', line 123

def self.commontator_email(user, mailer = nil)
  commontator_config(user).user_email_proc.call(user, mailer)
end


119
120
121
# File 'lib/commontator.rb', line 119

def self.commontator_link(user, routing_proxy)
  commontator_config(user).user_link_proc.call(user, routing_proxy)
end

.commontator_mentions(user, thread, search_phrase) ⇒ Object



131
132
133
# File 'lib/commontator.rb', line 131

def self.commontator_mentions(user, thread, search_phrase)
  commontator_config(user).user_mentions_proc.call(user, thread, search_phrase)
end

.commontator_name(user) ⇒ Object



115
116
117
# File 'lib/commontator.rb', line 115

def self.commontator_name(user)
  commontator_config(user).user_name_proc.call(user)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Commontator)

    the object that the method was called on



101
102
103
104
105
# File 'lib/commontator.rb', line 101

def self.configure
  @deprecated_method_called = false
  yield self
  warn "\n[COMMONTATOR] We recommend that you backup the config/initializers/commontator.rb file, rename or remove it, run rake commontator:install:initializers to copy the new default one, then configure it to your liking.\n" if @deprecated_method_called
end