thredded 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. metadata +7 -114
  3. data/MIT-LICENSE +0 -20
  4. data/README.mkdn +0 -72
  5. data/Rakefile +0 -31
  6. data/app/assets/javascripts/thredded/application.js +0 -15
  7. data/app/assets/stylesheets/thredded/application.css +0 -13
  8. data/app/controllers/thredded/application_controller.rb +0 -60
  9. data/app/controllers/thredded/emails_controller.rb +0 -4
  10. data/app/controllers/thredded/messageboards_controller.rb +0 -7
  11. data/app/controllers/thredded/posts_controller.rb +0 -85
  12. data/app/controllers/thredded/preferences_controller.rb +0 -28
  13. data/app/controllers/thredded/private_topics_controller.rb +0 -58
  14. data/app/controllers/thredded/setups_controller.rb +0 -44
  15. data/app/controllers/thredded/topics_controller.rb +0 -99
  16. data/app/decorators/thredded/messageboard_decorator.rb +0 -74
  17. data/app/decorators/thredded/post_decorator.rb +0 -61
  18. data/app/decorators/thredded/topic_decorator.rb +0 -94
  19. data/app/decorators/thredded/user_topic_decorator.rb +0 -88
  20. data/app/helpers/thredded/application_helper.rb +0 -4
  21. data/app/helpers/thredded/posts_helper.rb +0 -7
  22. data/app/helpers/thredded/topics_helper.rb +0 -4
  23. data/app/mailers/thredded/post_mailer.rb +0 -28
  24. data/app/mailers/thredded/topic_mailer.rb +0 -29
  25. data/app/models/thredded/ability.rb +0 -66
  26. data/app/models/thredded/attachment.rb +0 -23
  27. data/app/models/thredded/category.rb +0 -9
  28. data/app/models/thredded/image.rb +0 -26
  29. data/app/models/thredded/messageboard.rb +0 -117
  30. data/app/models/thredded/messageboard_preference.rb +0 -14
  31. data/app/models/thredded/null_preference.rb +0 -11
  32. data/app/models/thredded/null_topic.rb +0 -16
  33. data/app/models/thredded/null_topic_read.rb +0 -19
  34. data/app/models/thredded/null_user.rb +0 -35
  35. data/app/models/thredded/post.rb +0 -120
  36. data/app/models/thredded/post_notification.rb +0 -5
  37. data/app/models/thredded/private_topic.rb +0 -42
  38. data/app/models/thredded/private_user.rb +0 -6
  39. data/app/models/thredded/role.rb +0 -16
  40. data/app/models/thredded/topic.rb +0 -154
  41. data/app/models/thredded/topic_category.rb +0 -6
  42. data/app/models/thredded/user_detail.rb +0 -6
  43. data/app/models/thredded/user_extender.rb +0 -21
  44. data/app/models/thredded/user_preference.rb +0 -6
  45. data/app/models/thredded/user_topic_read.rb +0 -9
  46. data/app/uploaders/thredded/attachment_uploader.rb +0 -30
  47. data/app/uploaders/thredded/image_uploader.rb +0 -16
  48. data/app/views/thredded/attachments/_attachment.html.erb +0 -7
  49. data/app/views/thredded/messageboards/_messageboard.html.erb +0 -20
  50. data/app/views/thredded/messageboards/index.html.erb +0 -18
  51. data/app/views/thredded/post_mailer/at_notification.html.erb +0 -17
  52. data/app/views/thredded/post_mailer/at_notification.text.erb +0 -13
  53. data/app/views/thredded/posts/_form.html.erb +0 -17
  54. data/app/views/thredded/posts/_null_user.html.erb +0 -0
  55. data/app/views/thredded/posts/_post.html.erb +0 -29
  56. data/app/views/thredded/posts/_user.html.erb +0 -7
  57. data/app/views/thredded/posts/edit.html.erb +0 -31
  58. data/app/views/thredded/posts/index.html.erb +0 -64
  59. data/app/views/thredded/preferences/edit.html.erb +0 -22
  60. data/app/views/thredded/private_topics/_form.html.erb +0 -15
  61. data/app/views/thredded/private_topics/index.html.erb +0 -34
  62. data/app/views/thredded/private_topics/new.html.erb +0 -28
  63. data/app/views/thredded/search/_form.html.erb +0 -9
  64. data/app/views/thredded/setups/_form.html.erb +0 -35
  65. data/app/views/thredded/setups/new.html.erb +0 -6
  66. data/app/views/thredded/shared/_currently_online.html.erb +0 -10
  67. data/app/views/thredded/shared/_error_msgs.html.erb +0 -7
  68. data/app/views/thredded/shared/_google_analytics.html.erb +0 -10
  69. data/app/views/thredded/shared/_topic_nav.html.erb +0 -21
  70. data/app/views/thredded/topic_mailer/message_notification.html.erb +0 -17
  71. data/app/views/thredded/topic_mailer/message_notification.text.erb +0 -13
  72. data/app/views/thredded/topics/_form.html.erb +0 -6
  73. data/app/views/thredded/topics/_recent_topics_by_user.html.erb +0 -8
  74. data/app/views/thredded/topics/_topic_condensed.html.erb +0 -24
  75. data/app/views/thredded/topics/_topic_form.html.erb +0 -27
  76. data/app/views/thredded/topics/by_category.html.erb +0 -54
  77. data/app/views/thredded/topics/edit.html.erb +0 -28
  78. data/app/views/thredded/topics/index.html.erb +0 -34
  79. data/app/views/thredded/topics/menu/_new_topic.html.erb +0 -3
  80. data/app/views/thredded/topics/new.html.erb +0 -21
  81. data/app/views/thredded/topics/search.html.erb +0 -34
  82. data/config/initializers/griddler.rb +0 -4
  83. data/config/routes.rb +0 -29
  84. data/db/migrate/20130425230852_create_thredded_tables.rb +0 -143
  85. data/db/migrate/20131005032727_prevent_null_sticky_and_locked.rb +0 -15
  86. data/db/migrate/20131014014258_uniqs_on_user_topic_read.rb +0 -9
  87. data/db/migrate/20131019014258_index_necessary_columns.rb +0 -24
  88. data/db/migrate/20131026202621_move_filter_to_messageboards.rb +0 -11
  89. data/db/migrate/20131029034507_convert_textile_to_markdown.rb +0 -7
  90. data/lib/html/pipeline/at_mention_filter.rb +0 -19
  91. data/lib/html/pipeline/attached_image_filter.rb +0 -59
  92. data/lib/html/pipeline/bbcode_filter.rb +0 -19
  93. data/lib/tasks/thredded_tasks.rake +0 -4
  94. data/lib/thredded.rb +0 -58
  95. data/lib/thredded/at_notification_extractor.rb +0 -15
  96. data/lib/thredded/at_notifier.rb +0 -67
  97. data/lib/thredded/at_users.rb +0 -19
  98. data/lib/thredded/email_processor.rb +0 -76
  99. data/lib/thredded/engine.rb +0 -17
  100. data/lib/thredded/errors.rb +0 -40
  101. data/lib/thredded/messageboard_user_permissions.rb +0 -27
  102. data/lib/thredded/post_sql_builder.rb +0 -34
  103. data/lib/thredded/post_user_permissions.rb +0 -41
  104. data/lib/thredded/private_topic_notifier.rb +0 -56
  105. data/lib/thredded/private_topic_user_permissions.rb +0 -38
  106. data/lib/thredded/search_parser.rb +0 -45
  107. data/lib/thredded/search_sql_builder.rb +0 -25
  108. data/lib/thredded/setup_thredded.rb +0 -7
  109. data/lib/thredded/table_sql_builder.rb +0 -105
  110. data/lib/thredded/topic_sql_builder.rb +0 -32
  111. data/lib/thredded/topic_user_permissions.rb +0 -55
  112. data/lib/thredded/version.rb +0 -3
@@ -1,19 +0,0 @@
1
- module Thredded
2
- class NullTopicRead
3
- def page
4
- 1
5
- end
6
-
7
- def post_id
8
- 0
9
- end
10
-
11
- def posts_count
12
- 0
13
- end
14
-
15
- def farthest_post
16
- Post.new
17
- end
18
- end
19
- end
@@ -1,35 +0,0 @@
1
- module Thredded
2
- class NullUser
3
- def admins?(messageboard)
4
- false
5
- end
6
-
7
- def thredded_private_topics
8
- false
9
- end
10
-
11
- def can_read_messageboard?(messageboard)
12
- messageboard.public?
13
- end
14
-
15
- def id
16
- 0
17
- end
18
-
19
- def member_of?(messageboard)
20
- false
21
- end
22
-
23
- def name
24
- 'Anonymous User'
25
- end
26
-
27
- def to_s
28
- name
29
- end
30
-
31
- def valid?
32
- false
33
- end
34
- end
35
- end
@@ -1,120 +0,0 @@
1
- require 'thredded/at_notifier'
2
- require 'gravtastic'
3
-
4
- module Thredded
5
- class Post < ActiveRecord::Base
6
- include Gravtastic
7
-
8
- gravtastic :user_email, default: Thredded.avatar_default
9
- paginates_per 50
10
-
11
- belongs_to :messageboard, counter_cache: true
12
- belongs_to :topic, counter_cache: true
13
- belongs_to :user, class_name: Thredded.user_class
14
- has_many :attachments
15
- has_many :post_notifications
16
-
17
- accepts_nested_attributes_for :attachments
18
-
19
- validates_presence_of :content, :messageboard_id
20
-
21
- before_validation :set_user_email
22
- after_save :notify_at_users
23
- after_create :modify_parent_posts_counts
24
-
25
- def created_date
26
- created_at.strftime("%b %d, %Y %I:%M:%S %Z") if created_at
27
- end
28
-
29
- def created_timestamp
30
- created_at.strftime("%Y-%m-%dT%H:%M:%S") if created_at
31
- end
32
-
33
- def gravatar_url
34
- super.gsub(/http:/, '')
35
- end
36
-
37
- def self.filters
38
- ['bbcode', 'markdown']
39
- end
40
-
41
- def filtered_content
42
- pipeline = HTML::Pipeline.new [
43
- HTML::Pipeline::AttachedImageFilter,
44
- html_filter_for_pipeline,
45
- HTML::Pipeline::SanitizationFilter,
46
- HTML::Pipeline::AtMentionFilter,
47
- HTML::Pipeline::EmojiFilter,
48
- HTML::Pipeline::AutolinkFilter,
49
- ], context_options
50
-
51
- result = pipeline.call(content)
52
- result[:output].to_s
53
- end
54
-
55
- private
56
-
57
- def context_options
58
- {
59
- asset_root: Thredded.asset_root,
60
- post: self,
61
- whitelist: sanitize_whitelist
62
- }
63
- end
64
-
65
- def sanitize_whitelist
66
- HTML::Pipeline::SanitizationFilter::WHITELIST.deep_merge({
67
- attributes: {
68
- 'code' => ['class'],
69
- 'img' => ['src', 'class', 'width', 'height'],
70
- 'blockquote' => ['class'],
71
- },
72
- transformers: [
73
- lambda do |env|
74
- node = env[:node]
75
- node_name = env[:node_name]
76
-
77
- return if env[:is_whitelisted] || !node.element?
78
- return if node_name != 'iframe'
79
- return if (node['src'] =~ /\A(https?:)?\/\/(?:www\.)?youtube(?:-nocookie)?\.com\//).nil?
80
-
81
- Sanitize.clean_node!(node, {
82
- elements: %w[iframe],
83
-
84
- attributes: {
85
- 'iframe' => %w[allowfullscreen frameborder height src width]
86
- }
87
- })
88
-
89
- { node_whitelist: [node]}
90
- end
91
- ]
92
- })
93
- end
94
-
95
- def html_filter_for_pipeline
96
- if filter == 'bbcode'
97
- HTML::Pipeline::BbcodeFilter
98
- else
99
- HTML::Pipeline::MarkdownFilter
100
- end
101
- end
102
-
103
- def modify_parent_posts_counts
104
- Thredded::UserDetail.increment_counter(:posts_count, user_id)
105
- topic.last_user = user
106
- topic.touch
107
- topic.save
108
- end
109
-
110
- def set_user_email
111
- if user
112
- self.user_email = user.email
113
- end
114
- end
115
-
116
- def notify_at_users
117
- Thredded::AtNotifier.new(self).notifications_for_at_users
118
- end
119
- end
120
- end
@@ -1,5 +0,0 @@
1
- module Thredded
2
- class PostNotification < ActiveRecord::Base
3
- belongs_to :post
4
- end
5
- end
@@ -1,42 +0,0 @@
1
- module Thredded
2
- class PrivateTopic < Thredded::Topic
3
- has_many :private_users
4
- has_many :users, through: :private_users
5
-
6
- def self.including_roles_for(user)
7
- joins(messageboard: :roles)
8
- .where(thredded_roles: {user_id: user.id})
9
- end
10
-
11
- def self.for_user(user)
12
- joins(:private_users)
13
- .where(thredded_private_users: {user_id: user.id})
14
- end
15
-
16
- def add_user(user)
17
- if String == user.class
18
- user = User.find_by_name(user)
19
- end
20
-
21
- users << user
22
- end
23
-
24
- def public?
25
- false
26
- end
27
-
28
- def private?
29
- true
30
- end
31
-
32
- def user_id=(ids)
33
- if ids.size > 0
34
- self.users = User.where(id: ids.uniq)
35
- end
36
- end
37
-
38
- def users_to_sentence
39
- users.map{ |user| user.to_s.capitalize }.to_sentence
40
- end
41
- end
42
- end
@@ -1,6 +0,0 @@
1
- module Thredded
2
- class PrivateUser < ActiveRecord::Base
3
- belongs_to :private_topic
4
- belongs_to :user
5
- end
6
- end
@@ -1,16 +0,0 @@
1
- module Thredded
2
- class Role < ActiveRecord::Base
3
- ROLES = ['superadmin', 'admin', 'moderator', 'member']
4
-
5
- belongs_to :messageboard
6
- belongs_to :user, class_name: Thredded.user_class
7
-
8
- validates_presence_of :level
9
- validates_inclusion_of :level, in: ROLES
10
- validates_presence_of :messageboard_id
11
- validates_presence_of :user_id
12
-
13
- scope :for, lambda { |messageboard| where(messageboard_id: messageboard.id) }
14
- scope :as, lambda { |role| where(level: role) }
15
- end
16
- end
@@ -1,154 +0,0 @@
1
- require 'thredded/search_sql_builder'
2
-
3
- module Thredded
4
- class Topic < ActiveRecord::Base
5
- STATES = %w{pending approved}
6
-
7
- extend FriendlyId
8
- friendly_id :title, use: :scoped, scope: :messageboard
9
- paginates_per 50 if self.respond_to?(:paginates_per)
10
-
11
- has_many :posts, -> { includes :attachments }
12
- has_many :topic_categories
13
- has_many :categories, through: :topic_categories
14
- has_many :user_topic_reads
15
-
16
- belongs_to :last_user, class_name: Thredded.user_class,
17
- foreign_key: 'last_user_id'
18
-
19
- belongs_to :user, class_name: Thredded.user_class
20
-
21
- belongs_to :messageboard, counter_cache: true, touch: true
22
-
23
- validates_inclusion_of :state, in: STATES
24
- validates_presence_of :hash_id
25
- validates_presence_of :last_user_id
26
- validates_presence_of :messageboard_id
27
- validates_numericality_of :posts_count
28
- validates_uniqueness_of :hash_id
29
-
30
- accepts_nested_attributes_for :posts, reject_if: :updating?
31
- accepts_nested_attributes_for :categories
32
-
33
- delegate :name, :name=, :email, :email=, to: :user, prefix: true
34
-
35
- before_validation do
36
- self.hash_id = SecureRandom.hex(10) if self.hash_id.nil?
37
- end
38
-
39
- after_create :increment_topics_count
40
-
41
- def self.stuck
42
- where(sticky: true)
43
- end
44
-
45
- def self.unstuck
46
- where(sticky: false)
47
- end
48
-
49
- def self.on_page(page_num)
50
- page(page_num).per(30)
51
- end
52
-
53
- def self.for_messageboard(messageboard)
54
- where(messageboard_id: messageboard.id)
55
- end
56
-
57
- def self.public
58
- where("type IS NULL")
59
- end
60
-
61
- def self.order_by_stuck_and_updated_time
62
- order('sticky DESC, updated_at DESC')
63
- end
64
-
65
- def self.search(query, messageboard)
66
- sql_builder = Thredded::SearchSqlBuilder.new(query, messageboard)
67
- sql = sql_builder.build
68
- sql_params = [sql].concat(sql_builder.binds)
69
- results = find_by_sql(sql_params)
70
-
71
- if results.empty?
72
- raise Thredded::Errors::EmptySearchResults, query
73
- end
74
-
75
- results
76
- end
77
-
78
- def self.decorate
79
- all.map do |topic|
80
- TopicDecorator.new(topic)
81
- end
82
- end
83
-
84
- def self.find_by_slug(slug)
85
- begin
86
- includes(:user_topic_reads).friendly.find(slug)
87
- rescue ActiveRecord::RecordNotFound
88
- raise Thredded::Errors::TopicNotFound
89
- end
90
- end
91
-
92
- def decorate
93
- TopicDecorator.new(self)
94
- end
95
-
96
- def last_user
97
- super || NullUser.new
98
- end
99
-
100
- def public?
101
- true
102
- end
103
-
104
- def private?
105
- false
106
- end
107
-
108
- def pending?
109
- state == 'pending'
110
- end
111
-
112
- def users
113
- []
114
- end
115
-
116
- def users_to_sentence
117
- ''
118
- end
119
-
120
- def self.inherited(child)
121
- child.instance_eval do
122
- def model_name
123
- Topic.model_name
124
- end
125
- end
126
-
127
- super
128
- end
129
-
130
- def self.select_options
131
- subclasses.map(&:to_s).sort
132
- end
133
-
134
- def self.recent
135
- limit(10)
136
- end
137
-
138
- def updating?
139
- id.present?
140
- end
141
-
142
- def categories_to_sentence
143
- if categories
144
- categories.map(&:name).to_sentence
145
- end
146
- end
147
-
148
- private
149
-
150
- def increment_topics_count
151
- UserDetail.increment_counter(:topics_count, user_id)
152
- end
153
- end
154
- end
@@ -1,6 +0,0 @@
1
- module Thredded
2
- class TopicCategory < ActiveRecord::Base
3
- belongs_to :category
4
- belongs_to :topic
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Thredded
2
- class UserDetail < ActiveRecord::Base
3
- belongs_to :user, class_name: Thredded.user_class
4
- validates :user_id, presence: true
5
- end
6
- end
@@ -1,21 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- module Thredded
4
- module UserExtender
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- has_many :thredded_messageboard_preferences, class_name: 'Thredded::MessageboardPreference', foreign_key: 'user_id'
9
- has_many :thredded_posts, class_name: 'Thredded::Post', foreign_key: 'user_id'
10
- has_many :thredded_private_topics, through: :thredded_private_users, class_name: 'Thredded::PrivateTopic', source: :private_topic
11
- has_many :thredded_private_users, class_name: 'Thredded::PrivateUser', foreign_key: 'user_id'
12
- has_many :thredded_roles, class_name: 'Thredded::Role', foreign_key: 'user_id'
13
- has_many :thredded_topics, class_name: 'Thredded::Topic', foreign_key: 'user_id'
14
- has_many :thredded_read_topics, class_name: 'Thredded::UserTopicRead', foreign_key: 'user_id'
15
- has_many :thredded_messageboards, through: :thredded_roles, class_name: 'Thredded::Messageboard', source: :messageboard
16
-
17
- has_one :thredded_user_detail, class_name: 'Thredded::UserDetail', foreign_key: 'user_id'
18
- has_one :thredded_user_preference, class_name: 'Thredded::UserPreference', foreign_key: 'user_id'
19
- end
20
- end
21
- end
@@ -1,6 +0,0 @@
1
- module Thredded
2
- class UserPreference < ActiveRecord::Base
3
- belongs_to :user, class_name: Thredded.user_class
4
- validates :user_id, presence: true
5
- end
6
- end