thredded 0.0.7 → 0.0.8
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/application_controller.rb +6 -12
- data/app/controllers/thredded/messageboards_controller.rb +0 -2
- data/app/controllers/thredded/posts_controller.rb +2 -2
- data/app/controllers/thredded/private_topics_controller.rb +0 -2
- data/app/controllers/thredded/topics_controller.rb +1 -1
- data/app/models/thredded/messageboard.rb +9 -6
- data/config/routes.rb +1 -1
- data/lib/thredded/errors.rb +11 -1
- data/lib/thredded/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c2929ae0328e4fd8c0faf14a7dbd5ba4a1bd4b3
|
4
|
+
data.tar.gz: 50f7bb4efdbdf97b372ceb9da07ef6b6bf6aa692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c7d85da251177d9c62120f40281e2710a4e9c61c5622e998dd47179ac75aa5f60651176fefdc50adc787de144da33868c525c8c88fc3193095fd0278a6cd8c
|
7
|
+
data.tar.gz: 15cc242a83c68ac14700c019bc59624a64260f43d0510b5bd234e43ab322b983f30a283b1170b70285bbc39be95f78c5da8cf699d412de4f986cf750d4489468
|
@@ -2,10 +2,13 @@ module Thredded
|
|
2
2
|
class ApplicationController < ::ApplicationController
|
3
3
|
helper Thredded::Engine.helpers
|
4
4
|
helper_method :messageboard, :topic, :preferences
|
5
|
-
before_filter :update_user_activity
|
6
5
|
|
7
6
|
rescue_from CanCan::AccessDenied do |exception|
|
8
|
-
redirect_to root_path, alert: exception.message
|
7
|
+
redirect_to thredded.root_path, alert: exception.message
|
8
|
+
end
|
9
|
+
|
10
|
+
rescue_from Thredded::Errors::MessageboardNotFound do |exception|
|
11
|
+
redirect_to thredded.root_path, alert: exception.message
|
9
12
|
end
|
10
13
|
|
11
14
|
private
|
@@ -21,9 +24,7 @@ module Thredded
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def messageboard
|
24
|
-
|
25
|
-
@messageboard ||= Messageboard.where(slug: params[:messageboard_id]).first
|
26
|
-
end
|
27
|
+
@messageboard ||= Messageboard.find_by_slug(params[:messageboard_id])
|
27
28
|
end
|
28
29
|
|
29
30
|
def preferences
|
@@ -37,12 +38,5 @@ module Thredded
|
|
37
38
|
@topic ||= messageboard.topics.find(params[:topic_id])
|
38
39
|
end
|
39
40
|
end
|
40
|
-
|
41
|
-
def ensure_messageboard_exists
|
42
|
-
if messageboard.blank?
|
43
|
-
redirect_to thredded.root_path,
|
44
|
-
flash: { error: 'This messageboard does not exist.' }
|
45
|
-
end
|
46
|
-
end
|
47
41
|
end
|
48
42
|
end
|
@@ -2,10 +2,10 @@ module Thredded
|
|
2
2
|
class PostsController < Thredded::ApplicationController
|
3
3
|
load_and_authorize_resource only: [:index, :show]
|
4
4
|
helper_method :messageboard, :topic, :user_topic
|
5
|
+
before_filter :update_user_activity
|
5
6
|
|
6
7
|
rescue_from Thredded::Errors::TopicNotFound do |exception|
|
7
|
-
redirect_to messageboard_topics_path(messageboard),
|
8
|
-
alert: 'This topic does not exist.'
|
8
|
+
redirect_to messageboard_topics_path(messageboard), alert: exception.message
|
9
9
|
end
|
10
10
|
|
11
11
|
def index
|
@@ -5,15 +5,10 @@ module Thredded
|
|
5
5
|
FILTERS = %w{markdown bbcode}
|
6
6
|
|
7
7
|
extend FriendlyId
|
8
|
-
friendly_id :name
|
8
|
+
friendly_id :name, use: :slugged
|
9
9
|
|
10
10
|
validates :filter, presence: true
|
11
11
|
validates :filter, inclusion: { in: FILTERS }
|
12
|
-
validates :name, format: {
|
13
|
-
with: /\A[\w\-]+\z/,
|
14
|
-
on: :create,
|
15
|
-
message: 'should be letters, nums, dash, underscore only.'
|
16
|
-
}
|
17
12
|
validates :name, length: {
|
18
13
|
within: 1..16,
|
19
14
|
message: 'should be between 1 and 16 characters'
|
@@ -32,6 +27,14 @@ module Thredded
|
|
32
27
|
has_many :private_topics
|
33
28
|
has_many :users, through: :roles, class_name: Thredded.user_class
|
34
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
|
+
|
35
38
|
def self.default_scope
|
36
39
|
where(closed: false).order('topics_count DESC')
|
37
40
|
end
|
data/config/routes.rb
CHANGED
@@ -15,7 +15,7 @@ Thredded::Engine.routes.draw do
|
|
15
15
|
get '/:messageboard_id/preferences/edit' => 'preferences#edit'
|
16
16
|
get '/:messageboard_id/new(.:format)' => 'topics#new', as: :new_messageboard_topic
|
17
17
|
get '/:messageboard_id/:id/edit(.:format)' => 'topics#edit', as: :edit_messageboard_topic
|
18
|
-
get '/:messageboard_id/:topic_id
|
18
|
+
get '/:messageboard_id/:topic_id/page-:page(.:format)' => 'posts#index',
|
19
19
|
as: :paged_messageboard_topic_posts, constraints: { page: /\d+/ }
|
20
20
|
|
21
21
|
resources :messageboards, only: [:index], path: '' do
|
data/lib/thredded/errors.rb
CHANGED
@@ -3,6 +3,16 @@ module Thredded
|
|
3
3
|
end
|
4
4
|
|
5
5
|
module Errors
|
6
|
-
class TopicNotFound < Thredded::Error
|
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
|
7
17
|
end
|
8
18
|
end
|
data/lib/thredded/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Oliveira
|
@@ -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.
|
519
|
+
rubygems_version: 2.1.10
|
520
520
|
signing_key:
|
521
521
|
specification_version: 4
|
522
522
|
summary: A forum engine
|