thredded 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,15 +0,0 @@
1
- class PreventNullStickyAndLocked < ActiveRecord::Migration
2
- def up
3
- change_column_null :thredded_topics, :sticky, false, false
4
- change_column_null :thredded_topics, :locked, false, false
5
- change_column_null :thredded_topics, :posts_count, false, 0
6
- remove_column :thredded_topics, :attribs
7
- end
8
-
9
- def down
10
- add_column :thredded_topics, :attribs, :string, default: '[]'
11
- change_column_null :thredded_topics, :posts_count, true
12
- change_column_null :thredded_topics, :sticky, true
13
- change_column_null :thredded_topics, :locked, true
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- class UniqsOnUserTopicRead < ActiveRecord::Migration
2
- def up
3
- add_index :thredded_user_topic_reads, [:user_id, :topic_id], unique: true
4
- end
5
-
6
- def down
7
- remove_index :thredded_user_topic_reads, [:user_id, :topic_id]
8
- end
9
- end
@@ -1,24 +0,0 @@
1
- class IndexNecessaryColumns < ActiveRecord::Migration
2
- def change
3
- add_index :thredded_attachments, :post_id
4
- add_index :thredded_categories, :messageboard_id
5
- add_index :thredded_images, :post_id
6
- add_index :thredded_post_notifications, :post_id
7
- add_index :thredded_messageboards, :slug
8
-
9
- add_index :thredded_posts, :user_id
10
- add_index :thredded_posts, :topic_id
11
- add_index :thredded_posts, :messageboard_id
12
-
13
- add_index :thredded_private_users, :private_topic_id
14
- add_index :thredded_private_users, :user_id
15
-
16
- add_index :thredded_topic_categories, :topic_id
17
- add_index :thredded_topic_categories, :category_id
18
-
19
- add_index :thredded_topics, :user_id
20
- add_index :thredded_topics, :last_user_id
21
- add_index :thredded_topics, :messageboard_id
22
- add_index :thredded_topics, :hash_id
23
- end
24
- end
@@ -1,11 +0,0 @@
1
- class MoveFilterToMessageboards < ActiveRecord::Migration
2
- def up
3
- add_column :thredded_messageboards, :filter, :string, null: false, default: 'markdown'
4
- remove_column :thredded_messageboard_preferences, :filter
5
- end
6
-
7
- def down
8
- add_column :thredded_messageboard_preferences, :filter, :string, null: false, default: 'markdown'
9
- remove_column :thredded_messageboards, :filter
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- class ConvertTextileToMarkdown < ActiveRecord::Migration
2
- def up
3
- execute <<-sql
4
- UPDATE thredded_posts SET filter='markdown' WHERE filter = 'textile'
5
- sql
6
- end
7
- end
@@ -1,19 +0,0 @@
1
- require 'thredded/at_users'
2
-
3
- module HTML
4
- class Pipeline
5
- class AtMentionFilter < Filter
6
- def initialize(text, context = nil, result = nil)
7
- super text, context, result
8
- @text = text.to_s.gsub "\r", ''
9
- @post = context[:post]
10
- end
11
-
12
- def call
13
- html = Thredded::AtUsers.render(@text, @post.messageboard)
14
- html.rstrip!
15
- html
16
- end
17
- end
18
- end
19
- end
@@ -1,59 +0,0 @@
1
-
2
- module HTML
3
- class Pipeline
4
- class AttachedImageFilter < Filter
5
- def initialize(text, context = nil, result = nil)
6
- super text, context, result
7
- @text = text.gsub "\r", ''
8
- @post = context[:post]
9
- end
10
-
11
- def call
12
- html = @text
13
- matches = @text.scan(/(?<full>\[t:(?<tag>\w+)=?(?<img_nmb>\d+)? ?(?<attribs>[^\]]+)?\])/)
14
-
15
- matches.each do |match|
16
- str_buff = ''
17
- full = match[0]
18
- tag = match[1]
19
- img_number = match[2] ? match[2].to_i - 1 : 0 # default to first attachment
20
- attribs = match[3]
21
-
22
- if(tag != 'img' || !@post.attachments[img_number])
23
- next
24
- end
25
-
26
- # start with img tag
27
- str_buff += '<img '
28
-
29
- # get attachment object at spot img_number - 1
30
- attachment = @post.attachments[img_number]
31
- str_buff += 'src="' + attachment.attachment.to_s + '" '
32
-
33
- # do attribute stuff, left right first
34
- if !attribs.nil?
35
- if align = attribs.match(/(left|right)/)
36
- str_buff += 'class="align_' + align[0] + '" '
37
- end
38
-
39
- # attributes, width x height
40
- if wxh = attribs.match(/(\d+)x?(\d+)?/)
41
- str_buff += 'width="' + wxh[1] + '" '
42
- height = wxh[2].nil? ? wxh[1] : wxh[2]
43
- str_buff += 'height="' + height + '" '
44
- end
45
- end
46
-
47
- # end img tag
48
- str_buff += '/>'
49
-
50
- # replace in post content
51
- html = html.sub(full, str_buff)
52
- end
53
-
54
- html
55
- end
56
- end
57
- end
58
- end
59
-
@@ -1,19 +0,0 @@
1
- require 'bbcoder'
2
-
3
- module HTML
4
- class Pipeline
5
- class BbcodeFilter < TextFilter
6
- def initialize(text, context = {}, result = nil)
7
- super text, context, result
8
- @context = context
9
- @text = @text.gsub "\r", ''
10
- end
11
-
12
- def call
13
- html = BBCoder.new(@text).to_html.gsub(/\n|\r\n/, '<br />')
14
- html.rstrip!
15
- "<p>#{html}</p>"
16
- end
17
- end
18
- end
19
- end
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :thredded do
3
- # # Task goes here
4
- # end
@@ -1,58 +0,0 @@
1
- require 'thredded/engine'
2
- require 'cancan'
3
- require 'carrierwave'
4
- require 'griddler'
5
- require 'kaminari'
6
- require 'friendly_id'
7
- require 'nested_form'
8
- require 'thredded/email_processor'
9
- require 'thredded/errors'
10
- require 'thredded/at_notifier'
11
- require 'html/pipeline'
12
- require 'html/pipeline/bbcode_filter'
13
- require 'html/pipeline/attached_image_filter'
14
- require 'html/pipeline/at_mention_filter'
15
- require 'thredded/messageboard_user_permissions'
16
- require 'thredded/post_user_permissions'
17
- require 'thredded/private_topic_user_permissions'
18
- require 'thredded/topic_user_permissions'
19
- require 'thredded/search_sql_builder'
20
-
21
- module Thredded
22
- mattr_accessor :user_class,
23
- :email_incoming_host,
24
- :email_from,
25
- :email_outgoing_prefix,
26
- :user_path,
27
- :file_storage,
28
- :asset_root,
29
- :layout,
30
- :avatar_default
31
-
32
- self.file_storage = :file # or :fog
33
- self.asset_root = '' # or fully qualified URI to assets
34
- self.layout = 'thredded'
35
- self.avatar_default = 'mm'
36
-
37
- def self.user_class
38
- if @@user_class.is_a?(Class)
39
- raise 'Please use a string instead of a class'
40
- end
41
-
42
- if @@user_class.is_a?(String)
43
- begin
44
- Object.const_get(@@user_class)
45
- rescue NameError
46
- @@user_class.constantize
47
- end
48
- end
49
- end
50
-
51
- def self.user_path(user)
52
- if @@user_path.respond_to? :call
53
- @@user_path.call(user)
54
- else
55
- '/'
56
- end
57
- end
58
- end
@@ -1,15 +0,0 @@
1
- module Thredded
2
- class AtNotificationExtractor
3
- def initialize(content)
4
- @content = content
5
- end
6
-
7
- def extract
8
- scanned_names = @content.scan(/@([\w]+)(\W)?/)
9
- scanned_names += @content.scan(/@"([\w\ ]+)"(\W)?/)
10
- scanned_names
11
- .map(&:first)
12
- .uniq
13
- end
14
- end
15
- end
@@ -1,67 +0,0 @@
1
- require 'thredded/at_notification_extractor'
2
-
3
- module Thredded
4
- class AtNotifier
5
- def initialize(post)
6
- @post = post
7
- end
8
-
9
- def notifications_for_at_users
10
- members = at_notifiable_members
11
-
12
- if members.present?
13
- user_emails = members.map(&:email)
14
- Thredded::PostMailer.at_notification(post.id, user_emails).deliver
15
- mark_notified(members)
16
- end
17
- end
18
-
19
- def at_notifiable_members
20
- at_names = Thredded::AtNotificationExtractor.new(post.content).extract
21
- members = post.messageboard.members_from_list(at_names).to_a
22
-
23
- members.delete post.user
24
- members = exclude_previously_notified(members)
25
- members = exclude_those_that_are_not_private(members)
26
- members = exclude_those_opting_out_of_at_notifications(members)
27
-
28
- members
29
- end
30
-
31
- private
32
-
33
- attr_reader :post
34
-
35
- def exclude_those_opting_out_of_at_notifications(members)
36
- members.reject do |member|
37
- !Thredded::MessageboardPreference
38
- .for(member)
39
- .in(post.messageboard)
40
- .first
41
- .try(:notify_on_mention?)
42
- end
43
- end
44
-
45
- def exclude_those_that_are_not_private(members)
46
- members.reject do |member|
47
- post.topic.private? && post.topic.users.exclude?(member)
48
- end
49
- end
50
-
51
- def exclude_previously_notified(members)
52
- emails_notified = Thredded::PostNotification
53
- .where(post_id: post.id)
54
- .map(&:email)
55
-
56
- members.reject do |member|
57
- emails_notified.include? member.email
58
- end
59
- end
60
-
61
- def mark_notified(members)
62
- members.each do |member|
63
- post.post_notifications.create(email: member.email)
64
- end
65
- end
66
- end
67
- end
@@ -1,19 +0,0 @@
1
- require 'thredded/at_notification_extractor'
2
-
3
- module Thredded
4
- class AtUsers
5
- def self.render(content, messageboard)
6
- at_names = AtNotificationExtractor.new(content).extract
7
- members = messageboard.members_from_list(at_names)
8
-
9
- members.each do |member|
10
- member_path = Thredded.user_path(member)
11
-
12
- content.gsub!(/@#{member.to_s}/i,
13
- %Q{<a href="#{member_path}">@#{member}</a>})
14
- end
15
-
16
- content
17
- end
18
- end
19
- end
@@ -1,76 +0,0 @@
1
- module Thredded
2
- class EmailProcessor
3
- attr_accessor :email, :messageboard, :user
4
-
5
- def initialize(email)
6
- @email = email
7
- @user = find_user
8
- @messageboard = find_messageboard
9
- end
10
-
11
- def self.process(email)
12
- processor = self.new(email)
13
- processor.create_or_update_topic
14
- end
15
-
16
- def create_or_update_topic
17
- if can_post_to_topic?
18
- topic = find_or_build_topic
19
- post = topic.posts.build(
20
- user: user,
21
- content: email.body,
22
- source: 'email',
23
- messageboard: messageboard,
24
- attachments_attributes: attachment_params,
25
- )
26
- post.user_email = user.email
27
-
28
- topic.save
29
- else
30
- return false
31
- end
32
- end
33
-
34
- private
35
-
36
- def attachment_params
37
- @attachment_params = {}
38
-
39
- email.attachments.each_with_index do |attachment, i|
40
- @attachment_params[i.to_s] = { 'attachment' => attachment }
41
- end
42
-
43
- @attachment_params
44
- end
45
-
46
- def can_post_to_topic?
47
- user && messageboard &&
48
- Thredded::Ability.new(user).can?(:create, messageboard.topics.new)
49
- end
50
-
51
- def find_or_build_topic
52
- topic = find_topic
53
-
54
- if topic.nil?
55
- topic = messageboard.topics.build(title: email.subject)
56
- topic.user = user
57
- topic.state = 'pending'
58
- end
59
-
60
- topic.last_user = user
61
- topic
62
- end
63
-
64
- def find_topic
65
- Thredded::Topic.where(hash_id: email.to).first
66
- end
67
-
68
- def find_messageboard
69
- Thredded::Messageboard.where(name: email.to).first || find_topic.try(:messageboard)
70
- end
71
-
72
- def find_user
73
- User.where(email: email.from).first
74
- end
75
- end
76
- end
@@ -1,17 +0,0 @@
1
- module Thredded
2
- class Engine < ::Rails::Engine
3
- isolate_namespace Thredded
4
-
5
- config.autoload_paths << File.expand_path('../../../app/decorators', __FILE__)
6
-
7
- config.generators do |g|
8
- g.test_framework :rspec, fixture: true
9
- g.fixture_replacement :factory_girl, dir: 'spec/factories'
10
- g.helper false
11
- end
12
-
13
- config.to_prepare do
14
- Thredded.user_class.send(:include, Thredded::UserExtender)
15
- end
16
- end
17
- end
@@ -1,40 +0,0 @@
1
- module Thredded
2
- class Error < StandardError
3
- end
4
-
5
- module Errors
6
- class TopicNotFound < Thredded::Error
7
- def message
8
- 'This topic does not exist.'
9
- end
10
- end
11
-
12
- class MessageboardNotFound < Thredded::Error
13
- def message
14
- 'This messageboard does not exist.'
15
- end
16
- end
17
-
18
- class MessageboardReadDenied < Thredded::Error
19
- def message
20
- 'You are not authorized access to this messageboard.'
21
- end
22
- end
23
-
24
- class TopicCreateDenied < Thredded::Error
25
- def message
26
- 'You are not authorized to post in this messageboard.'
27
- end
28
- end
29
-
30
- class EmptySearchResults < Thredded::Error
31
- def initialize(query)
32
- @query = query
33
- end
34
-
35
- def message
36
- "There are no results for your search - '#{@query}'"
37
- end
38
- end
39
- end
40
- end