thredded 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +7 -114
- data/MIT-LICENSE +0 -20
- data/README.mkdn +0 -72
- data/Rakefile +0 -31
- data/app/assets/javascripts/thredded/application.js +0 -15
- data/app/assets/stylesheets/thredded/application.css +0 -13
- data/app/controllers/thredded/application_controller.rb +0 -60
- data/app/controllers/thredded/emails_controller.rb +0 -4
- data/app/controllers/thredded/messageboards_controller.rb +0 -7
- data/app/controllers/thredded/posts_controller.rb +0 -85
- data/app/controllers/thredded/preferences_controller.rb +0 -28
- data/app/controllers/thredded/private_topics_controller.rb +0 -58
- data/app/controllers/thredded/setups_controller.rb +0 -44
- data/app/controllers/thredded/topics_controller.rb +0 -99
- data/app/decorators/thredded/messageboard_decorator.rb +0 -74
- data/app/decorators/thredded/post_decorator.rb +0 -61
- data/app/decorators/thredded/topic_decorator.rb +0 -94
- data/app/decorators/thredded/user_topic_decorator.rb +0 -88
- data/app/helpers/thredded/application_helper.rb +0 -4
- data/app/helpers/thredded/posts_helper.rb +0 -7
- data/app/helpers/thredded/topics_helper.rb +0 -4
- data/app/mailers/thredded/post_mailer.rb +0 -28
- data/app/mailers/thredded/topic_mailer.rb +0 -29
- data/app/models/thredded/ability.rb +0 -66
- data/app/models/thredded/attachment.rb +0 -23
- data/app/models/thredded/category.rb +0 -9
- data/app/models/thredded/image.rb +0 -26
- data/app/models/thredded/messageboard.rb +0 -117
- data/app/models/thredded/messageboard_preference.rb +0 -14
- data/app/models/thredded/null_preference.rb +0 -11
- data/app/models/thredded/null_topic.rb +0 -16
- data/app/models/thredded/null_topic_read.rb +0 -19
- data/app/models/thredded/null_user.rb +0 -35
- data/app/models/thredded/post.rb +0 -120
- data/app/models/thredded/post_notification.rb +0 -5
- data/app/models/thredded/private_topic.rb +0 -42
- data/app/models/thredded/private_user.rb +0 -6
- data/app/models/thredded/role.rb +0 -16
- data/app/models/thredded/topic.rb +0 -154
- data/app/models/thredded/topic_category.rb +0 -6
- data/app/models/thredded/user_detail.rb +0 -6
- data/app/models/thredded/user_extender.rb +0 -21
- data/app/models/thredded/user_preference.rb +0 -6
- data/app/models/thredded/user_topic_read.rb +0 -9
- data/app/uploaders/thredded/attachment_uploader.rb +0 -30
- data/app/uploaders/thredded/image_uploader.rb +0 -16
- data/app/views/thredded/attachments/_attachment.html.erb +0 -7
- data/app/views/thredded/messageboards/_messageboard.html.erb +0 -20
- data/app/views/thredded/messageboards/index.html.erb +0 -18
- data/app/views/thredded/post_mailer/at_notification.html.erb +0 -17
- data/app/views/thredded/post_mailer/at_notification.text.erb +0 -13
- data/app/views/thredded/posts/_form.html.erb +0 -17
- data/app/views/thredded/posts/_null_user.html.erb +0 -0
- data/app/views/thredded/posts/_post.html.erb +0 -29
- data/app/views/thredded/posts/_user.html.erb +0 -7
- data/app/views/thredded/posts/edit.html.erb +0 -31
- data/app/views/thredded/posts/index.html.erb +0 -64
- data/app/views/thredded/preferences/edit.html.erb +0 -22
- data/app/views/thredded/private_topics/_form.html.erb +0 -15
- data/app/views/thredded/private_topics/index.html.erb +0 -34
- data/app/views/thredded/private_topics/new.html.erb +0 -28
- data/app/views/thredded/search/_form.html.erb +0 -9
- data/app/views/thredded/setups/_form.html.erb +0 -35
- data/app/views/thredded/setups/new.html.erb +0 -6
- data/app/views/thredded/shared/_currently_online.html.erb +0 -10
- data/app/views/thredded/shared/_error_msgs.html.erb +0 -7
- data/app/views/thredded/shared/_google_analytics.html.erb +0 -10
- data/app/views/thredded/shared/_topic_nav.html.erb +0 -21
- data/app/views/thredded/topic_mailer/message_notification.html.erb +0 -17
- data/app/views/thredded/topic_mailer/message_notification.text.erb +0 -13
- data/app/views/thredded/topics/_form.html.erb +0 -6
- data/app/views/thredded/topics/_recent_topics_by_user.html.erb +0 -8
- data/app/views/thredded/topics/_topic_condensed.html.erb +0 -24
- data/app/views/thredded/topics/_topic_form.html.erb +0 -27
- data/app/views/thredded/topics/by_category.html.erb +0 -54
- data/app/views/thredded/topics/edit.html.erb +0 -28
- data/app/views/thredded/topics/index.html.erb +0 -34
- data/app/views/thredded/topics/menu/_new_topic.html.erb +0 -3
- data/app/views/thredded/topics/new.html.erb +0 -21
- data/app/views/thredded/topics/search.html.erb +0 -34
- data/config/initializers/griddler.rb +0 -4
- data/config/routes.rb +0 -29
- data/db/migrate/20130425230852_create_thredded_tables.rb +0 -143
- data/db/migrate/20131005032727_prevent_null_sticky_and_locked.rb +0 -15
- data/db/migrate/20131014014258_uniqs_on_user_topic_read.rb +0 -9
- data/db/migrate/20131019014258_index_necessary_columns.rb +0 -24
- data/db/migrate/20131026202621_move_filter_to_messageboards.rb +0 -11
- data/db/migrate/20131029034507_convert_textile_to_markdown.rb +0 -7
- data/lib/html/pipeline/at_mention_filter.rb +0 -19
- data/lib/html/pipeline/attached_image_filter.rb +0 -59
- data/lib/html/pipeline/bbcode_filter.rb +0 -19
- data/lib/tasks/thredded_tasks.rake +0 -4
- data/lib/thredded.rb +0 -58
- data/lib/thredded/at_notification_extractor.rb +0 -15
- data/lib/thredded/at_notifier.rb +0 -67
- data/lib/thredded/at_users.rb +0 -19
- data/lib/thredded/email_processor.rb +0 -76
- data/lib/thredded/engine.rb +0 -17
- data/lib/thredded/errors.rb +0 -40
- data/lib/thredded/messageboard_user_permissions.rb +0 -27
- data/lib/thredded/post_sql_builder.rb +0 -34
- data/lib/thredded/post_user_permissions.rb +0 -41
- data/lib/thredded/private_topic_notifier.rb +0 -56
- data/lib/thredded/private_topic_user_permissions.rb +0 -38
- data/lib/thredded/search_parser.rb +0 -45
- data/lib/thredded/search_sql_builder.rb +0 -25
- data/lib/thredded/setup_thredded.rb +0 -7
- data/lib/thredded/table_sql_builder.rb +0 -105
- data/lib/thredded/topic_sql_builder.rb +0 -32
- data/lib/thredded/topic_user_permissions.rb +0 -55
- data/lib/thredded/version.rb +0 -3
@@ -1,88 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class UserTopicDecorator
|
3
|
-
extend ActiveModel::Naming
|
4
|
-
include ActiveModel::Conversion
|
5
|
-
|
6
|
-
def initialize(user, topic)
|
7
|
-
@user = user || NullUser.new
|
8
|
-
@topic = topic
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(meth, *args)
|
12
|
-
if decorated_topic.respond_to?(meth)
|
13
|
-
decorated_topic.send(meth, *args)
|
14
|
-
else
|
15
|
-
super
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def respond_to?(meth)
|
20
|
-
decorated_topic.respond_to?(meth)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.decorate_all(user, topics)
|
24
|
-
topics.map do |topic|
|
25
|
-
new(user, topic)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.model_name
|
30
|
-
ActiveModel::Name.new(self, nil, "Topic")
|
31
|
-
end
|
32
|
-
|
33
|
-
def persisted?
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
def read?
|
38
|
-
topic.posts_count == read_status.posts_count
|
39
|
-
end
|
40
|
-
|
41
|
-
def farthest_page
|
42
|
-
read_status.page
|
43
|
-
end
|
44
|
-
|
45
|
-
def farthest_post
|
46
|
-
read_status.farthest_post
|
47
|
-
end
|
48
|
-
|
49
|
-
def css_class
|
50
|
-
if read?
|
51
|
-
"read #{decorated_topic.css_class}"
|
52
|
-
else
|
53
|
-
"unread #{decorated_topic.css_class}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def user_link
|
58
|
-
if topic.user && topic.user.to_s != 'Anonymous User'
|
59
|
-
user_path = Thredded.user_path(topic.user)
|
60
|
-
"<a href='#{user_path}'>#{topic.user}</a>".html_safe
|
61
|
-
else
|
62
|
-
'<a href="#">?</a>'.html_safe
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def decorated_topic
|
67
|
-
@decorated_topic ||= TopicDecorator.new(topic)
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
attr_reader :topic, :user
|
73
|
-
|
74
|
-
def read_status
|
75
|
-
if user.id > 0
|
76
|
-
@read_status ||= topic.user_topic_reads.select do |reads|
|
77
|
-
reads.user_id == user.id
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
if @read_status.blank?
|
82
|
-
NullTopicRead.new
|
83
|
-
else
|
84
|
-
@read_status.first
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class PostMailer < ActionMailer::Base
|
3
|
-
def at_notification(post_id, user_emails)
|
4
|
-
@post = Post.find(post_id)
|
5
|
-
|
6
|
-
headers['X-SMTPAPI'] = %Q{{"category": ["thredded_#{@post.messageboard.name}","at_notification"]}}
|
7
|
-
mail from: no_reply,
|
8
|
-
to: no_reply,
|
9
|
-
bcc: user_emails,
|
10
|
-
reply_to: reply_to,
|
11
|
-
subject: subject
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def subject
|
17
|
-
"#{Thredded.email_outgoing_prefix} #{@post.topic.title}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def reply_to
|
21
|
-
"#{@post.topic.hash_id}@#{Thredded.email_incoming_host}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def no_reply
|
25
|
-
Thredded.email_from
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class TopicMailer < ActionMailer::Base
|
3
|
-
def message_notification(topic_id, emails)
|
4
|
-
@topic = Topic.find(topic_id)
|
5
|
-
headers['X-SMTPAPI'] =
|
6
|
-
%Q{{"category": ["thredded_#{@topic.messageboard.name}","at_notification"]}}
|
7
|
-
|
8
|
-
mail from: no_reply,
|
9
|
-
to: no_reply,
|
10
|
-
bcc: emails,
|
11
|
-
reply_to: reply_to,
|
12
|
-
subject: subject
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def subject
|
18
|
-
"#{Thredded.email_outgoing_prefix} #{@topic.title}"
|
19
|
-
end
|
20
|
-
|
21
|
-
def reply_to
|
22
|
-
"#{@topic.hash_id}@#{Thredded.email_incoming_host}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def no_reply
|
26
|
-
Thredded.email_from
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class Ability
|
3
|
-
include ::CanCan::Ability
|
4
|
-
|
5
|
-
def initialize(user)
|
6
|
-
user ||= Thredded::NullUser.new
|
7
|
-
user_details = Thredded::UserDetail.where(user_id: user.id).first
|
8
|
-
|
9
|
-
can :manage, :all if user_details.try(:superadmin?)
|
10
|
-
|
11
|
-
can :read, Thredded::Messageboard do |messageboard|
|
12
|
-
Thredded::MessageboardUserPermissions.new(messageboard, user).readable?
|
13
|
-
end
|
14
|
-
|
15
|
-
can :admin, Thredded::Topic do |topic|
|
16
|
-
Thredded::TopicUserPermissions.new(topic, user, user_details).adminable?
|
17
|
-
end
|
18
|
-
|
19
|
-
can :edit, Thredded::Topic do |topic|
|
20
|
-
Thredded::TopicUserPermissions.new(topic, user, user_details).editable?
|
21
|
-
end
|
22
|
-
|
23
|
-
can :update, Thredded::Topic do |topic|
|
24
|
-
Thredded::TopicUserPermissions.new(topic, user, user_details).editable?
|
25
|
-
end
|
26
|
-
|
27
|
-
can :read, Thredded::Topic do |topic|
|
28
|
-
Thredded::TopicUserPermissions.new(topic, user, user_details).readable?
|
29
|
-
end
|
30
|
-
|
31
|
-
can :create, Thredded::Topic do |topic|
|
32
|
-
Thredded::TopicUserPermissions.new(topic, user, user_details).creatable?
|
33
|
-
end
|
34
|
-
|
35
|
-
cannot :manage, Thredded::PrivateTopic
|
36
|
-
|
37
|
-
can :list, Thredded::PrivateTopic do |private_topic|
|
38
|
-
Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).listable?
|
39
|
-
end
|
40
|
-
|
41
|
-
can :manage, Thredded::PrivateTopic do |private_topic|
|
42
|
-
Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).manageable?
|
43
|
-
end
|
44
|
-
|
45
|
-
can :create, Thredded::PrivateTopic do |private_topic|
|
46
|
-
Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).creatable?
|
47
|
-
end
|
48
|
-
|
49
|
-
can :read, Thredded::PrivateTopic do |private_topic|
|
50
|
-
Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).readable?
|
51
|
-
end
|
52
|
-
|
53
|
-
can :edit, Thredded::Post do |post|
|
54
|
-
Thredded::PostUserPermissions.new(post, user, user_details).editable?
|
55
|
-
end
|
56
|
-
|
57
|
-
can :manage, Thredded::Post do |post|
|
58
|
-
Thredded::PostUserPermissions.new(post, user, user_details).manageable?
|
59
|
-
end
|
60
|
-
|
61
|
-
can :create, Thredded::Post do |post|
|
62
|
-
Thredded::PostUserPermissions.new(post, user, user_details).creatable?
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class Attachment < ActiveRecord::Base
|
3
|
-
belongs_to :post, touch: true
|
4
|
-
validates_presence_of :attachment
|
5
|
-
mount_uploader :attachment, Thredded::AttachmentUploader
|
6
|
-
before_save :update_attachment_attributes
|
7
|
-
|
8
|
-
def cache_dir
|
9
|
-
"#{Rails.root}/tmp/uploads"
|
10
|
-
end
|
11
|
-
|
12
|
-
def filename
|
13
|
-
File.basename(attachment.path)
|
14
|
-
end
|
15
|
-
|
16
|
-
def update_attachment_attributes
|
17
|
-
if attachment.present? && attachment_changed?
|
18
|
-
self.content_type = attachment.file.content_type
|
19
|
-
self.file_size = attachment.file.size
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class Image < ActiveRecord::Base
|
3
|
-
mount_uploader :image, ImageUploader
|
4
|
-
validates :image, presence: true
|
5
|
-
before_validation :save_dimensions, :save_orientation, :save_position
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def save_dimensions
|
10
|
-
if image.path
|
11
|
-
self.width = MiniMagick::Image.open(image.path)[:width]
|
12
|
-
self.height = MiniMagick::Image.open(image.path)[:height]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def save_orientation
|
17
|
-
if image.path
|
18
|
-
self.orientation = (height.to_i > width.to_i) ? 'portrait' : 'landscape'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def save_position
|
23
|
-
self.position = (self._index + 1) if self.new_record? and self._index
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class Messageboard < ActiveRecord::Base
|
3
|
-
SECURITY = %w{private logged_in public}
|
4
|
-
PERMISSIONS = %w{members logged_in anonymous}
|
5
|
-
FILTERS = %w{markdown bbcode}
|
6
|
-
|
7
|
-
extend FriendlyId
|
8
|
-
friendly_id :name, use: :slugged
|
9
|
-
|
10
|
-
validates :filter, presence: true
|
11
|
-
validates :filter, inclusion: { in: FILTERS }
|
12
|
-
validates :name, length: {
|
13
|
-
within: 1..16,
|
14
|
-
message: 'should be between 1 and 16 characters'
|
15
|
-
}
|
16
|
-
validates :name, presence: true
|
17
|
-
validates :name, uniqueness: { message: 'must be a unique board name.' }
|
18
|
-
validates :posting_permission, inclusion: { in: PERMISSIONS }
|
19
|
-
validates :security, inclusion: { in: SECURITY }
|
20
|
-
validates :topics_count, numericality: true
|
21
|
-
|
22
|
-
has_many :categories
|
23
|
-
has_many :messageboard_preferences
|
24
|
-
has_many :posts
|
25
|
-
has_many :roles
|
26
|
-
has_many :topics
|
27
|
-
has_many :private_topics
|
28
|
-
has_many :users, through: :roles, class_name: Thredded.user_class
|
29
|
-
|
30
|
-
def self.find_by_slug(slug)
|
31
|
-
begin
|
32
|
-
friendly.find(slug)
|
33
|
-
rescue ActiveRecord::RecordNotFound
|
34
|
-
raise Thredded::Errors::MessageboardNotFound
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.default_scope
|
39
|
-
where(closed: false).order('topics_count DESC')
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.decorate
|
43
|
-
all.map do |messageboard|
|
44
|
-
MessageboardDecorator.new(messageboard)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def preferences_for(user)
|
49
|
-
@preferences_for ||=
|
50
|
-
messageboard_preferences.where(user_id: user).first_or_create
|
51
|
-
end
|
52
|
-
|
53
|
-
def active_users
|
54
|
-
Role
|
55
|
-
.joins(:user)
|
56
|
-
.includes(:user)
|
57
|
-
.where(messageboard_id: self.id)
|
58
|
-
.where('last_seen > ?', 5.minutes.ago)
|
59
|
-
.order(:last_seen)
|
60
|
-
.map(&:user)
|
61
|
-
end
|
62
|
-
|
63
|
-
def update_activity_for!(user)
|
64
|
-
if role = roles.where(user_id: user).first
|
65
|
-
role.update_attribute(:last_seen, Time.now.utc)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def decorate
|
70
|
-
MessageboardDecorator.new(self)
|
71
|
-
end
|
72
|
-
|
73
|
-
def add_member(user, as='member')
|
74
|
-
roles.create(user_id: user.id, level: as)
|
75
|
-
end
|
76
|
-
|
77
|
-
def has_member?(user)
|
78
|
-
roles.where(user_id: user.id).exists?
|
79
|
-
end
|
80
|
-
|
81
|
-
def member_is_a?(user, as)
|
82
|
-
roles.where(user_id: user.id, level: as).exists?
|
83
|
-
end
|
84
|
-
|
85
|
-
def members_from_list(user_list)
|
86
|
-
users.where('lower(name) in (?)', user_list.map(&:downcase))
|
87
|
-
end
|
88
|
-
|
89
|
-
def posting_for_anonymous?
|
90
|
-
'anonymous' == posting_permission
|
91
|
-
end
|
92
|
-
|
93
|
-
def posting_for_logged_in?
|
94
|
-
'logged_in' == posting_permission
|
95
|
-
end
|
96
|
-
|
97
|
-
def posting_for_members?
|
98
|
-
'members' == posting_permission
|
99
|
-
end
|
100
|
-
|
101
|
-
def public?
|
102
|
-
'public' == security
|
103
|
-
end
|
104
|
-
|
105
|
-
def restricted_to_logged_in?
|
106
|
-
'logged_in' == security
|
107
|
-
end
|
108
|
-
|
109
|
-
def restricted_to_private?
|
110
|
-
'private' == security
|
111
|
-
end
|
112
|
-
|
113
|
-
def to_param
|
114
|
-
name.downcase
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class MessageboardPreference < ActiveRecord::Base
|
3
|
-
belongs_to :user
|
4
|
-
belongs_to :messageboard
|
5
|
-
|
6
|
-
def self.for(user)
|
7
|
-
where(user_id: user.id)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.in(messageboard)
|
11
|
-
where(messageboard_id: messageboard.id)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|