thredded 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/thredded/messageboards_controller.rb +1 -1
- data/app/controllers/thredded/posts_controller.rb +7 -6
- data/app/controllers/thredded/topics_controller.rb +3 -2
- data/app/decorators/thredded/messageboard_decorator.rb +74 -0
- data/app/models/thredded/messageboard.rb +22 -9
- data/app/models/thredded/null_topic.rb +16 -0
- data/app/models/thredded/post.rb +0 -1
- data/app/models/thredded/topic.rb +4 -1
- data/app/views/thredded/messageboards/_messageboard.html.erb +9 -6
- data/app/views/thredded/posts/_form.html.erb +0 -8
- data/app/views/thredded/preferences/edit.html.erb +0 -4
- data/db/migrate/20131026202621_move_filter_to_messageboards.rb +11 -0
- data/db/migrate/20131029034507_convert_textile_to_markdown.rb +7 -0
- data/lib/thredded.rb +1 -1
- data/lib/thredded/version.rb +1 -1
- metadata +12 -12
- data/app/helpers/thredded/messageboard_helper.rb +0 -44
- data/app/models/thredded/messageboard_decorator.rb +0 -18
- data/app/models/thredded/null_messageboard_preference.rb +0 -7
- data/lib/thredded/filter/textile.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5bbfffd3928efffdf26597640c19eb5f9d52f24
|
4
|
+
data.tar.gz: 1c1fd24a8c1d0d52d01bea3727539b99bf5898f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c98c1f4eacd78aa4df72ab88b92d9fa4f08ae12aff4118ba5c67013c58a6410eac3a46da923fcac53fd5a68820d3b603dc834c2c20cbefd8676950a4f3b4baad
|
7
|
+
data.tar.gz: e503d2a13970801509b6aada495bcee7308c32547074bc18b3f3d561089825d7131120ea66d2a9dce586f6ddda63c6ea6b0b3c60cadece68b926a7d31e88814c
|
@@ -12,7 +12,7 @@ module Thredded
|
|
12
12
|
authorize! :read, topic
|
13
13
|
|
14
14
|
@posts = topic.posts.page(current_page)
|
15
|
-
@post = messageboard.posts.build(topic: topic
|
15
|
+
@post = messageboard.posts.build(topic: topic)
|
16
16
|
|
17
17
|
update_read_status!
|
18
18
|
end
|
@@ -41,6 +41,7 @@ module Thredded
|
|
41
41
|
ip: request.remote_ip,
|
42
42
|
user: current_user,
|
43
43
|
messageboard: messageboard,
|
44
|
+
filter: messageboard.filter,
|
44
45
|
)
|
45
46
|
end
|
46
47
|
|
@@ -60,7 +61,11 @@ module Thredded
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def topic
|
63
|
-
@topic ||=
|
64
|
+
@topic ||= topic_with_eager_loaded_user_topic_reads
|
65
|
+
end
|
66
|
+
|
67
|
+
def topic_with_eager_loaded_user_topic_reads
|
68
|
+
messageboard.topics.find_by_slug(params[:topic_id])
|
64
69
|
end
|
65
70
|
|
66
71
|
def user_topic
|
@@ -71,10 +76,6 @@ module Thredded
|
|
71
76
|
@post ||= topic.posts.find(params[:id])
|
72
77
|
end
|
73
78
|
|
74
|
-
def post_filter
|
75
|
-
messageboard.preferences_for(current_user).filter
|
76
|
-
end
|
77
|
-
|
78
79
|
def current_page
|
79
80
|
params[:page].nil? ? 1 : params[:page].to_i
|
80
81
|
end
|
@@ -26,7 +26,7 @@ module Thredded
|
|
26
26
|
@topic = messageboard.topics.build
|
27
27
|
@topic
|
28
28
|
.posts
|
29
|
-
.build
|
29
|
+
.build
|
30
30
|
|
31
31
|
unless can? :create, @topic
|
32
32
|
error = 'Sorry, you are not authorized to post on this messageboard.'
|
@@ -58,7 +58,7 @@ module Thredded
|
|
58
58
|
|
59
59
|
def topic
|
60
60
|
if messageboard
|
61
|
-
@topic ||= messageboard.topics.
|
61
|
+
@topic ||= messageboard.topics.friendly.find(params[:id])
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -84,6 +84,7 @@ module Thredded
|
|
84
84
|
messageboard: messageboard,
|
85
85
|
ip: request.remote_ip,
|
86
86
|
user: current_user,
|
87
|
+
filter: messageboard.filter,
|
87
88
|
}
|
88
89
|
}
|
89
90
|
})
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Thredded
|
2
|
+
class MessageboardDecorator < SimpleDelegator
|
3
|
+
include ActionView::Helpers::NumberHelper
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
|
6
|
+
def initialize(messageboard)
|
7
|
+
super
|
8
|
+
@messageboard = messageboard
|
9
|
+
end
|
10
|
+
|
11
|
+
def original
|
12
|
+
messageboard
|
13
|
+
end
|
14
|
+
|
15
|
+
def meta
|
16
|
+
topics_count = number_to_human(messageboard.topics_count)
|
17
|
+
posts_count = number_to_human(messageboard.posts_count)
|
18
|
+
|
19
|
+
"#{topics_count} topics, #{posts_count} posts".downcase
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
if messageboard.description.blank?
|
24
|
+
''
|
25
|
+
else
|
26
|
+
content_tag :p, messageboard.description
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def latest_topic_timeago
|
31
|
+
if latest_topic.updated_at.nil?
|
32
|
+
<<-eohtml.html_safe
|
33
|
+
<abbr>
|
34
|
+
a little while ago
|
35
|
+
</abbr>
|
36
|
+
eohtml
|
37
|
+
else
|
38
|
+
<<-eohtml.html_safe
|
39
|
+
<abbr class="timeago" title="#{topic_updated_at_utc}">
|
40
|
+
#{topic_updated_at_str}
|
41
|
+
</abbr>
|
42
|
+
eohtml
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def latest_topic
|
47
|
+
@latest_topic ||= messageboard.topics.order('updated_at DESC').first || Thredded::NullTopic.new
|
48
|
+
end
|
49
|
+
|
50
|
+
def latest_user
|
51
|
+
latest_topic.last_user
|
52
|
+
end
|
53
|
+
|
54
|
+
def category_options
|
55
|
+
messageboard.categories.map { |cat| [cat.name, cat.id] }
|
56
|
+
end
|
57
|
+
|
58
|
+
def users_options
|
59
|
+
messageboard.users.map { |user| [user.to_s, user.id] }
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
attr_reader :messageboard
|
65
|
+
|
66
|
+
def topic_updated_at_utc
|
67
|
+
latest_topic.updated_at.getutc.iso8601
|
68
|
+
end
|
69
|
+
|
70
|
+
def topic_updated_at_str
|
71
|
+
latest_topic.updated_at.to_s
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -2,20 +2,27 @@ module Thredded
|
|
2
2
|
class Messageboard < ActiveRecord::Base
|
3
3
|
SECURITY = %w{private logged_in public}
|
4
4
|
PERMISSIONS = %w{members logged_in anonymous}
|
5
|
+
FILTERS = %w{markdown bbcode}
|
5
6
|
|
6
7
|
extend FriendlyId
|
7
8
|
friendly_id :name
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
validates :filter, presence: true
|
11
|
+
validates :filter, inclusion: { in: FILTERS }
|
12
|
+
validates :name, format: {
|
13
|
+
with: /\A[\w\-]+\z/,
|
14
|
+
on: :create,
|
14
15
|
message: 'should be letters, nums, dash, underscore only.'
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
}
|
17
|
+
validates :name, length: {
|
18
|
+
within: 1..16,
|
18
19
|
message: 'should be between 1 and 16 characters'
|
20
|
+
}
|
21
|
+
validates :name, presence: true
|
22
|
+
validates :name, uniqueness: { message: 'must be a unique board name.' }
|
23
|
+
validates :posting_permission, inclusion: { in: PERMISSIONS }
|
24
|
+
validates :security, inclusion: { in: SECURITY }
|
25
|
+
validates :topics_count, numericality: true
|
19
26
|
|
20
27
|
has_many :categories
|
21
28
|
has_many :messageboard_preferences
|
@@ -29,9 +36,15 @@ module Thredded
|
|
29
36
|
where(closed: false).order('topics_count DESC')
|
30
37
|
end
|
31
38
|
|
39
|
+
def self.decorate
|
40
|
+
all.map do |messageboard|
|
41
|
+
MessageboardDecorator.new(messageboard)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
def preferences_for(user)
|
33
46
|
@preferences_for ||=
|
34
|
-
messageboard_preferences.where(user_id: user).
|
47
|
+
messageboard_preferences.where(user_id: user).first_or_create
|
35
48
|
end
|
36
49
|
|
37
50
|
def active_users
|
data/app/models/thredded/post.rb
CHANGED
@@ -80,8 +80,11 @@ module Thredded
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def self.find_by_slug(slug)
|
83
|
-
|
83
|
+
begin
|
84
|
+
includes(:user_topic_reads).friendly.find(slug)
|
85
|
+
rescue ActiveRecord::RecordNotFound
|
84
86
|
raise Thredded::Errors::TopicNotFound
|
87
|
+
end
|
85
88
|
end
|
86
89
|
|
87
90
|
def decorate
|
@@ -1,16 +1,19 @@
|
|
1
|
-
<% if can? :read, messageboard %>
|
1
|
+
<% if can? :read, messageboard.original %>
|
2
2
|
<div class="messageboard">
|
3
3
|
<header>
|
4
|
-
<h2
|
5
|
-
|
4
|
+
<h2>
|
5
|
+
<%= link_to messageboard.name, messageboard_topics_path(messageboard) %>
|
6
|
+
</h2>
|
7
|
+
|
8
|
+
<div class="meta"><%= messageboard.meta %></div>
|
6
9
|
</header>
|
7
10
|
|
8
|
-
|
11
|
+
<%= messageboard.description %>
|
9
12
|
|
10
13
|
<footer>
|
11
14
|
<p>
|
12
|
-
<%=
|
13
|
-
<cite>by <%=
|
15
|
+
<%= messageboard.latest_topic_timeago %>
|
16
|
+
<cite>by <%= messageboard.latest_user %></cite>
|
14
17
|
</p>
|
15
18
|
</footer>
|
16
19
|
</div>
|
@@ -15,11 +15,3 @@
|
|
15
15
|
<%= f.link_to_add 'Add an attachment', :attachments,
|
16
16
|
{ class: :add_attachment } %>
|
17
17
|
</li>
|
18
|
-
|
19
|
-
<li>
|
20
|
-
<%= f.select :filter, Thredded::Post.filters, {} %>
|
21
|
-
<a href="#pseudo-help"
|
22
|
-
title="huh?"
|
23
|
-
class="hide-for-small filter-help"
|
24
|
-
id="filter-help">?</a>
|
25
|
-
</li>
|
@@ -13,10 +13,6 @@
|
|
13
13
|
<%= f.label :notify_on_message, 'Notify me when I am included in a private topic' %>
|
14
14
|
<%= f.check_box :notify_on_message %>
|
15
15
|
</li>
|
16
|
-
<li>
|
17
|
-
<%= f.label :filter, 'Preferred post filter' %>
|
18
|
-
<%= f.select :filter, Thredded::Post.filters %>
|
19
|
-
</li>
|
20
16
|
<li class="submit"><%= f.submit 'Update Preferences' %></li>
|
21
17
|
</ul>
|
22
18
|
<% end %>
|
@@ -0,0 +1,11 @@
|
|
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
|
data/lib/thredded.rb
CHANGED
@@ -8,12 +8,12 @@ require 'nested_form'
|
|
8
8
|
require 'thredded/email_processor'
|
9
9
|
require 'thredded/errors'
|
10
10
|
require 'thredded/filter/base'
|
11
|
+
require 'thredded/at_notifier'
|
11
12
|
require 'thredded/filter/at_notification'
|
12
13
|
require 'thredded/filter/attachment'
|
13
14
|
require 'thredded/filter/bbcode'
|
14
15
|
require 'thredded/filter/emoji'
|
15
16
|
require 'thredded/filter/markdown'
|
16
|
-
require 'thredded/filter/textile'
|
17
17
|
require 'thredded/messageboard_user_permissions'
|
18
18
|
require 'thredded/post_user_permissions'
|
19
19
|
require 'thredded/private_topic_user_permissions'
|
data/lib/thredded/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thredded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bb-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: cancan
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: carrierwave
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '>='
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: escape_utils
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: unf
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
@@ -391,11 +391,11 @@ files:
|
|
391
391
|
- app/controllers/thredded/private_topics_controller.rb
|
392
392
|
- app/controllers/thredded/setups_controller.rb
|
393
393
|
- app/controllers/thredded/topics_controller.rb
|
394
|
+
- app/decorators/thredded/messageboard_decorator.rb
|
394
395
|
- app/decorators/thredded/post_decorator.rb
|
395
396
|
- app/decorators/thredded/topic_decorator.rb
|
396
397
|
- app/decorators/thredded/user_topic_decorator.rb
|
397
398
|
- app/helpers/thredded/application_helper.rb
|
398
|
-
- app/helpers/thredded/messageboard_helper.rb
|
399
399
|
- app/helpers/thredded/posts_helper.rb
|
400
400
|
- app/helpers/thredded/topics_helper.rb
|
401
401
|
- app/mailers/thredded/post_mailer.rb
|
@@ -405,10 +405,9 @@ files:
|
|
405
405
|
- app/models/thredded/category.rb
|
406
406
|
- app/models/thredded/image.rb
|
407
407
|
- app/models/thredded/messageboard.rb
|
408
|
-
- app/models/thredded/messageboard_decorator.rb
|
409
408
|
- app/models/thredded/messageboard_preference.rb
|
410
|
-
- app/models/thredded/null_messageboard_preference.rb
|
411
409
|
- app/models/thredded/null_preference.rb
|
410
|
+
- app/models/thredded/null_topic.rb
|
412
411
|
- app/models/thredded/null_topic_read.rb
|
413
412
|
- app/models/thredded/null_user.rb
|
414
413
|
- app/models/thredded/post.rb
|
@@ -464,6 +463,8 @@ files:
|
|
464
463
|
- db/migrate/20131005032727_prevent_null_sticky_and_locked.rb
|
465
464
|
- db/migrate/20131014014258_uniqs_on_user_topic_read.rb
|
466
465
|
- db/migrate/20131019014258_index_necessary_columns.rb
|
466
|
+
- db/migrate/20131026202621_move_filter_to_messageboards.rb
|
467
|
+
- db/migrate/20131029034507_convert_textile_to_markdown.rb
|
467
468
|
- lib/tasks/thredded_tasks.rake
|
468
469
|
- lib/thredded/at_notification_extractor.rb
|
469
470
|
- lib/thredded/at_notifier.rb
|
@@ -478,7 +479,6 @@ files:
|
|
478
479
|
- lib/thredded/filter/emoji.rb
|
479
480
|
- lib/thredded/filter/markdown.rb
|
480
481
|
- lib/thredded/filter/syntax.rb
|
481
|
-
- lib/thredded/filter/textile.rb
|
482
482
|
- lib/thredded/filter.rb
|
483
483
|
- lib/thredded/messageboard_user_permissions.rb
|
484
484
|
- lib/thredded/post_sql_builder.rb
|
@@ -516,7 +516,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
516
516
|
version: '0'
|
517
517
|
requirements: []
|
518
518
|
rubyforge_project:
|
519
|
-
rubygems_version: 2.0.
|
519
|
+
rubygems_version: 2.0.7
|
520
520
|
signing_key:
|
521
521
|
specification_version: 4
|
522
522
|
summary: A forum engine
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
module MessageboardHelper
|
3
|
-
def link_or_text_to(messageboard)
|
4
|
-
if can? :read, messageboard
|
5
|
-
link_to messageboard.name, messageboard_topics_path(messageboard)
|
6
|
-
else
|
7
|
-
messageboard.name
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def meta_for(messageboard)
|
12
|
-
topics = messageboard.topics_count
|
13
|
-
posts = messageboard.posts_count
|
14
|
-
"#{number_to_human topics} topics,
|
15
|
-
#{number_to_human posts} posts".downcase
|
16
|
-
end
|
17
|
-
|
18
|
-
def latest_thread_for(messageboard)
|
19
|
-
topic = messageboard.topics.first
|
20
|
-
|
21
|
-
if topic.present?
|
22
|
-
abbr = content_tag :abbr, class: 'updated_at timeago', title: topic.updated_at.strftime('%Y-%m-%dT%H:%M:%S') do
|
23
|
-
topic.updated_at.strftime('%b %d, %Y %I:%M:%S %Z')
|
24
|
-
end
|
25
|
-
|
26
|
-
if can? :read, messageboard
|
27
|
-
link_to abbr , messageboard_topic_posts_path(messageboard, topic)
|
28
|
-
else
|
29
|
-
abbr
|
30
|
-
end
|
31
|
-
else
|
32
|
-
''
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def latest_user_for(messageboard)
|
37
|
-
if messageboard.topics.first.present? && messageboard.topics.first.user.present?
|
38
|
-
messageboard.topics.first.last_user.to_s
|
39
|
-
else
|
40
|
-
''
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Thredded
|
2
|
-
class MessageboardDecorator < SimpleDelegator
|
3
|
-
attr_reader :messageboard
|
4
|
-
|
5
|
-
def initialize(messageboard)
|
6
|
-
super
|
7
|
-
@messageboard = messageboard
|
8
|
-
end
|
9
|
-
|
10
|
-
def category_options
|
11
|
-
messageboard.categories.map { |cat| [cat.name, cat.id] }
|
12
|
-
end
|
13
|
-
|
14
|
-
def users_options
|
15
|
-
messageboard.users.map { |user| [user.to_s, user.id] }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'redcloth'
|
2
|
-
|
3
|
-
module Thredded
|
4
|
-
module Filter
|
5
|
-
module Textile
|
6
|
-
def self.included(base)
|
7
|
-
base.class_eval do
|
8
|
-
Thredded::Post::Filters << :textile
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def filtered_content
|
13
|
-
if filter.to_sym == :textile
|
14
|
-
@filtered_content = RedCloth.new(super).to_html.html_safe
|
15
|
-
else
|
16
|
-
@filtered_content = super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|