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,27 +0,0 @@
1
- module Thredded
2
- class MessageboardUserPermissions
3
- attr_reader :messageboard, :user
4
-
5
- def initialize(messageboard, user)
6
- @messageboard = messageboard
7
- @user = user
8
- end
9
-
10
- def readable?
11
- (messageboard.restricted_to_private? && messageboard.has_member?(user)) ||
12
- (messageboard.restricted_to_logged_in? && user.valid?) ||
13
- messageboard.public?
14
- end
15
-
16
- def postable?
17
- if messageboard.posting_for_anonymous? &&
18
- (messageboard.restricted_to_private? || messageboard.restricted_to_logged_in?)
19
- false
20
- else
21
- messageboard.posting_for_anonymous? ||
22
- (messageboard.posting_for_logged_in? && user.try(:valid?)) ||
23
- (messageboard.posting_for_members? && messageboard.has_member?(user))
24
- end
25
- end
26
- end
27
- end
@@ -1,34 +0,0 @@
1
- module Thredded
2
- class PostSqlBuilder < TableSqlBuilder
3
- def build_text_search
4
- if text.present?
5
- search_text = text
6
- add_from('thredded_posts p')
7
- add_where('t.id = p.topic_id')
8
- add_where("to_tsvector('english', p.content) @@ plainto_tsquery('english', ?)", search_text.uniq.join(' '))
9
-
10
- search_text.each do |term|
11
- if (is_quoted(term))
12
- add_where('p.content ILIKE ?', term.gsub('"', '%'))
13
- end
14
- end
15
- end
16
- end
17
-
18
- def build_in_category
19
- if categories.present?
20
- add_from('thredded_topic_categories tc')
21
- add_where('tc.topic_id = t.id')
22
- add_where('tc.category_id in (?)', categories)
23
- end
24
- end
25
-
26
- def build_by_user
27
- if users.present?
28
- add_from 'thredded_posts p'
29
- add_where('t.id = p.topic_id')
30
- add_where('p.user_id in (?)', users)
31
- end
32
- end
33
- end
34
- end
@@ -1,41 +0,0 @@
1
- module Thredded
2
- class PostUserPermissions
3
- attr_reader :post, :user, :user_details, :messageboard, :topic
4
-
5
- def initialize(post, user, user_details)
6
- @post = post
7
- @topic = post.topic
8
- @messageboard = post.messageboard
9
- @user = user
10
- @user_details = user_details || UserDetail.new
11
- end
12
-
13
- def editable?
14
- created_post? || messageboard.member_is_a?(user, 'admin')
15
- end
16
-
17
- def manageable?
18
- created_post?
19
- end
20
-
21
- def creatable?
22
- thread_is_not_locked? && can_create_topic?
23
- end
24
-
25
- private
26
-
27
- def created_post?
28
- user.id == post.user_id
29
- end
30
-
31
- def thread_is_not_locked?
32
- !@topic.locked?
33
- end
34
-
35
- def can_create_topic?
36
- TopicUserPermissions.new(@topic, @user, @user_details).creatable?
37
- end
38
- end
39
- end
40
-
41
-
@@ -1,56 +0,0 @@
1
- module Thredded
2
- class PrivateTopicNotifier
3
- def initialize(topic)
4
- @post = topic.posts.first || Post.new
5
- @topic = topic
6
- end
7
-
8
- def notifications_for_private_topic
9
- members = private_topic_recipients
10
-
11
- if members.present?
12
- user_emails = members.map(&:email)
13
- TopicMailer.message_notification(topic.id, user_emails).deliver
14
- mark_notified(members)
15
- end
16
- end
17
-
18
- def private_topic_recipients
19
- members = topic.users - [topic.user]
20
- members = exclude_those_opting_out_of_message_notifications(members)
21
- members = exclude_previously_notified(members)
22
- members
23
- end
24
-
25
- private
26
-
27
- attr_reader :post, :topic
28
-
29
- def mark_notified(members)
30
- members.each do |member|
31
- post.post_notifications.create(email: member.email)
32
- end
33
- end
34
-
35
- def exclude_those_opting_out_of_message_notifications(members)
36
- members.reject do |member|
37
- !Thredded::MessageboardPreference
38
- .for(member)
39
- .in(topic.messageboard)
40
- .first
41
- .try(:notify_on_message?)
42
- end
43
- end
44
-
45
- def notify_for_member_in_messageboard?(member, messageboard)
46
- end
47
-
48
- def exclude_previously_notified(members)
49
- emails_notified = post.post_notifications.map(&:email)
50
-
51
- members.reject do |member|
52
- emails_notified.include? member.email
53
- end
54
- end
55
- end
56
- end
@@ -1,38 +0,0 @@
1
- module Thredded
2
- class PrivateTopicUserPermissions
3
- attr_reader :private_topic, :user, :user_details, :messageboard
4
-
5
- def initialize(private_topic, user, user_details)
6
- @private_topic = private_topic
7
- @messageboard = private_topic.messageboard
8
- @user = user
9
- @user_details = user_details || UserDetail.new
10
- end
11
-
12
- def listable?
13
- if user.thredded_private_topics
14
- user.thredded_private_topics.for_user(user).any?
15
- end
16
- end
17
-
18
- def manageable?
19
- user_started_topic?
20
- end
21
-
22
- def readable?
23
- private_topic.users.include?(user)
24
- end
25
-
26
- def creatable?
27
- TopicUserPermissions
28
- .new(private_topic, user, user_details).creatable?
29
- end
30
-
31
- private
32
-
33
- def user_started_topic?
34
- user.id == private_topic.user_id
35
- end
36
- end
37
- end
38
-
@@ -1,45 +0,0 @@
1
- module Thredded
2
- class SearchParser
3
- def initialize(query)
4
- @query = query
5
- @keywords = ['in', 'by', 'order']
6
- end
7
-
8
- def parse
9
- parsed_input = parse_keywords
10
- parsed_input['text'] = parse_text
11
- parsed_input
12
- end
13
-
14
- def parse_keywords
15
- found_terms_hash = {}
16
-
17
- @keywords.each do |keyword|
18
- regex = Regexp.new(keyword+'\s*:\s*\w+', Regexp::IGNORECASE)
19
- keyword_scan = @query.scan(regex)
20
- @query = @query.gsub(regex, '')
21
-
22
- if keyword_scan.present?
23
- keyword_scan.each do |term|
24
- keyword_term = term.gsub(' ', '').split(':')
25
-
26
- if found_terms_hash[keyword].nil?
27
- found_terms_hash[keyword] = []
28
- end
29
-
30
- found_terms_hash[keyword] << keyword_term[1]
31
- end
32
- end
33
- end
34
-
35
- found_terms_hash
36
- end
37
-
38
- def parse_text
39
- regex = Regexp.new('\"[^"]*\"')
40
- found_terms = @query.scan(regex)
41
- @query = @query.sub(regex,'')
42
- found_terms.concat(@query.split(/\s+/))
43
- end
44
- end
45
- end
@@ -1,25 +0,0 @@
1
- require 'thredded/topic_sql_builder'
2
- require 'thredded/post_sql_builder'
3
-
4
- module Thredded
5
- class SearchSqlBuilder
6
- def initialize(query, messageboard)
7
- @topic_builder = TopicSqlBuilder.new(query, messageboard)
8
- @post_builder = PostSqlBuilder.new(query, messageboard)
9
- @order_by = 'ORDER BY updated_at DESC'
10
- end
11
-
12
- def build
13
- [
14
- 'SELECT * FROM thredded_topics WHERE id IN (', @post_builder.sql,
15
- 'UNION', @topic_builder.sql,
16
- ')', @order_by,
17
- 'LIMIT 50'
18
- ].join(' ')
19
- end
20
-
21
- def binds
22
- @post_builder.binds.concat(@topic_builder.binds)
23
- end
24
- end
25
- end
@@ -1,7 +0,0 @@
1
- module Thredded
2
- class SetupThredded
3
- def matches?(request)
4
- return Thredded::Messageboard.all.empty?
5
- end
6
- end
7
- end
@@ -1,105 +0,0 @@
1
- require 'thredded/search_parser'
2
-
3
- module Thredded
4
- class TableSqlBuilder
5
- attr_accessor :binds
6
-
7
- def initialize(query, messageboard)
8
- @terms = SearchParser.new(query).parse
9
-
10
- @select = 'SELECT t.id'
11
- @from = 'FROM thredded_topics t'
12
- @where = ['t.messageboard_id = ?']
13
- @binds = [messageboard.id]
14
-
15
- @search_categories = []
16
- @search_users = []
17
- @search_text = []
18
- end
19
-
20
- def sql
21
- build_by_user
22
- build_in_category
23
- build_text_search
24
-
25
- [@select,
26
- @from,
27
- 'WHERE', @where.join(' AND '),
28
- ].join(' ')
29
- end
30
-
31
- private
32
-
33
- def is_quoted(term)
34
- term.count('"') == 2
35
- end
36
-
37
- def categories
38
- if @search_categories.any?
39
- @search_categories
40
- else
41
- if @terms['in']
42
- @terms['in'].each do |category_name|
43
- category = Category
44
- .where('lower(name) = ?', category_name.downcase).first
45
- if category
46
- @search_categories << category.id
47
- end
48
- end
49
- end
50
-
51
- @search_categories
52
- end
53
- end
54
-
55
- def users
56
- if @search_users.any?
57
- @search_users
58
- else
59
-
60
- if @terms['by']
61
- @terms['by'].each do |username|
62
- user = User.where('lower(name) = ?', username.downcase).first
63
-
64
- if user
65
- @search_users << user.id
66
- end
67
- end
68
- end
69
-
70
- @search_users
71
- end
72
- end
73
-
74
- def text
75
- @terms['text']
76
- end
77
-
78
- def build_by_user
79
- raise 'SubclassResponsibility'
80
- end
81
-
82
- def build_in_category
83
- raise 'SubclassResponsibility'
84
- end
85
-
86
- def build_text_search
87
- raise 'SubclassResponsibility'
88
- end
89
-
90
- def add_from(table)
91
- if @from.exclude? table
92
- @from = "#{@from}, #{table}"
93
- end
94
- end
95
-
96
- def add_where(where, binds=nil)
97
- if @where.exclude? where
98
- @where << where
99
- if (binds.present?)
100
- @binds.push(binds)
101
- end
102
- end
103
- end
104
- end
105
- end
@@ -1,32 +0,0 @@
1
- require 'thredded/table_sql_builder'
2
-
3
- module Thredded
4
- class TopicSqlBuilder < TableSqlBuilder
5
- def build_text_search
6
- if text.present?
7
- search_text = text
8
- add_where("to_tsvector('english', t.title) @@ plainto_tsquery('english', ?)", search_text.uniq.join(' '))
9
-
10
- search_text.each do |term|
11
- if (is_quoted(term))
12
- add_where('t.title ILIKE ?', term.gsub('"', '%'))
13
- end
14
- end
15
- end
16
- end
17
-
18
- def build_in_category
19
- if categories.present?
20
- add_from('topic_categories tc')
21
- add_where('tc.topic_id = t.id')
22
- add_where('tc.category_id in (?)', categories)
23
- end
24
- end
25
-
26
- def build_by_user
27
- if users.present?
28
- add_where('t.user_id in (?)', users)
29
- end
30
- end
31
- end
32
- end
@@ -1,55 +0,0 @@
1
- module Thredded
2
- class TopicUserPermissions
3
- attr_reader :topic, :user, :user_details, :messageboard
4
-
5
- def initialize(topic, user, user_details)
6
- @topic = topic
7
- @messageboard = topic.messageboard
8
- @user = user
9
- @user_details = user_details || UserDetail.new
10
- end
11
-
12
- def creatable?
13
- member? || messageboard_restrictions_allow?
14
- end
15
-
16
- def adminable?
17
- superadmin? || administrates_messageboard?
18
- end
19
-
20
- def editable?
21
- superadmin? || administrates_messageboard? || started_by_user?
22
- end
23
-
24
- def readable?
25
- MessageboardUserPermissions.new(messageboard, user).readable?
26
- end
27
-
28
- private
29
-
30
- def messageboard_restrictions_allow?
31
- user.valid? &&
32
- (
33
- messageboard.public? ||
34
- messageboard.restricted_to_logged_in? ||
35
- messageboard.posting_for_logged_in?
36
- )
37
- end
38
-
39
- def member?
40
- user.valid? && messageboard.has_member?(user)
41
- end
42
-
43
- def superadmin?
44
- user_details.superadmin?
45
- end
46
-
47
- def started_by_user?
48
- topic.user_id == user.id
49
- end
50
-
51
- def administrates_messageboard?
52
- user.valid? && messageboard.member_is_a?(user, 'admin')
53
- end
54
- end
55
- end