radiant-forum-extension 3.0.0.rc6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/views/admin/pages/_edit_commentability.html.haml +5 -2
- data/app/views/posts/_post.html.haml +1 -1
- data/config/locales/en.yml +3 -0
- data/config/routes.rb +4 -3
- data/forum_extension.rb +0 -4
- data/lib/commentable_model.rb +2 -2
- data/lib/forum_page.rb +2 -1
- data/lib/forum_reader_sessions_controller.rb +6 -2
- data/lib/radiant-forum-extension.rb +1 -1
- data/radiant-forum-extension.gemspec +3 -3
- data/spec/lib/forum_page_spec.rb +1 -1
- data/spec/models/post_spec.rb +6 -5
- metadata +11 -17
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
- fields_for :page do |f|
|
4
4
|
.commentability
|
5
|
+
%label
|
6
|
+
= t('forum_extension.comments').titlecase
|
7
|
+
%br
|
5
8
|
= f.check_box :commentable, {:onclick => "if (this.checked) { $('page_comments_closed').enable(); $('comments_closed_label').removeClassName('disabled'); } else { $('page_comments_closed').disable(); $('comments_closed_label').addClassName('disabled'); }"}
|
6
|
-
= f.label :commentable
|
9
|
+
= f.label :commentable
|
7
10
|
%br
|
8
11
|
= f.check_box :comments_closed, :disabled => !@page.commentable?
|
9
|
-
= f.label :comments_closed,
|
12
|
+
= f.label :comments_closed, nil, :id => 'comments_closed_label', :class => !@page.commentable? ? 'disabled' : ''
|
data/config/locales/en.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
forum_prefix = Radiant.config['forum.path'] || "forum"
|
2
|
+
|
1
3
|
ActionController::Routing::Routes.draw do |map|
|
2
|
-
map.with_options :path_prefix =>
|
4
|
+
map.with_options :path_prefix => forum_prefix do |forum|
|
3
5
|
forum.resources :forums, :only => [:index, :show], :has_many => [:topics]
|
4
6
|
forum.resources :topics, :only => [:index, :show], :has_many => [:posts]
|
5
7
|
forum.resources :posts, :member => { :remove => :get }
|
@@ -12,7 +14,6 @@ ActionController::Routing::Routes.draw do |map|
|
|
12
14
|
admin.resources :posts
|
13
15
|
end
|
14
16
|
|
15
|
-
map.forum_home "
|
17
|
+
map.forum_home "#{forum_prefix}.:format", :controller => 'topics', :action => 'index'
|
16
18
|
map.add_comment "/pages/:page_id/posts/new.:format", :controller => 'posts', :action => 'new'
|
17
|
-
|
18
19
|
end
|
data/forum_extension.rb
CHANGED
@@ -6,10 +6,6 @@ class ForumExtension < Radiant::Extension
|
|
6
6
|
description RadiantForumExtension::DESCRIPTION
|
7
7
|
url RadiantForumExtension::URL
|
8
8
|
|
9
|
-
extension_config do |config|
|
10
|
-
config.gem 'acts_as_list', :version => "~> 0.1.2"
|
11
|
-
end
|
12
|
-
|
13
9
|
def activate
|
14
10
|
ActiveRecord::Base.send :include, CommentableModel # provides has_comments class method that is used here by topics and pages but can be called from any model
|
15
11
|
Reader.send :include, ForumReader # has topics and posts
|
data/lib/commentable_model.rb
CHANGED
@@ -64,11 +64,11 @@ module CommentableModel # for inclusion into ActiveRecord::Base
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def paged?
|
67
|
-
Radiant
|
67
|
+
Radiant.config['forum.paginate_posts?'] && posts.count > posts_per_page
|
68
68
|
end
|
69
69
|
|
70
70
|
def posts_per_page
|
71
|
-
(Radiant
|
71
|
+
(Radiant.config['forum.posts_per_page'] || 25).to_i
|
72
72
|
end
|
73
73
|
|
74
74
|
def last_page
|
data/lib/forum_page.rb
CHANGED
@@ -28,7 +28,8 @@ module ForumPage
|
|
28
28
|
return false unless Radiant::Config['forum.allow_page_comments?'] && commentable?
|
29
29
|
return false if comments_closed?
|
30
30
|
return true unless commentable_period && commentable_period > 0
|
31
|
-
|
31
|
+
age = (Time.now - self.published_at).to_i
|
32
|
+
return age < commentable_period
|
32
33
|
end
|
33
34
|
|
34
35
|
def locked?
|
@@ -2,8 +2,12 @@ module ForumReaderSessionsController
|
|
2
2
|
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval do
|
5
|
-
def default_welcome_url_with_forum
|
6
|
-
|
5
|
+
def default_welcome_url_with_forum(reader=nil)
|
6
|
+
if Radiant.config['reader.login_to'] == 'forum'
|
7
|
+
topics_url
|
8
|
+
else
|
9
|
+
default_welcome_url_without_forum(reader)
|
10
|
+
end
|
7
11
|
end
|
8
12
|
alias_method_chain :default_welcome_url, :forum
|
9
13
|
end
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = RadiantForumExtension::SUMMARY
|
13
13
|
s.description = RadiantForumExtension::DESCRIPTION
|
14
14
|
|
15
|
-
s.add_dependency 'radiant-reader-extension', "~> 3.0.0
|
15
|
+
s.add_dependency 'radiant-reader-extension', "~> 3.0.0"
|
16
16
|
s.add_dependency 'acts_as_list', "~> 0.1.2"
|
17
17
|
|
18
18
|
ignores = if File.exist?('.gitignore')
|
@@ -26,9 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.require_paths = ["lib"]
|
27
27
|
|
28
28
|
s.post_install_message = %{
|
29
|
-
Add this to your radiant project
|
29
|
+
Add this to the Gemfile in your radiant project:
|
30
30
|
|
31
|
-
|
31
|
+
gem 'radiant-forum-extension', '~> #{RadiantForumExtension::VERSION}'
|
32
32
|
|
33
33
|
}
|
34
34
|
end
|
data/spec/lib/forum_page_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe 'Forum-extended page' do
|
|
29
29
|
page = pages(:commentable)
|
30
30
|
page.send(:commentable_period).should == 28.days
|
31
31
|
page.locked?.should be_false
|
32
|
-
page.
|
32
|
+
page.published_at = Time.now - 30.days
|
33
33
|
page.locked?.should be_true
|
34
34
|
end
|
35
35
|
end
|
data/spec/models/post_spec.rb
CHANGED
@@ -82,13 +82,14 @@ describe Post do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should report on which page of its topic it can be found" do
|
85
|
-
Radiant
|
86
|
-
Radiant
|
87
|
-
|
85
|
+
Radiant.config['forum.paginate_posts?'] = true
|
86
|
+
Radiant.config['forum.posts_per_page'] = 25
|
87
|
+
topic = topics(:older)
|
88
|
+
firstpost = topic.posts.create!(:body => 'foo', :reader => readers(:normal))
|
88
89
|
55.times do |i|
|
89
|
-
|
90
|
+
topic.posts.create!(:body => "rhubarb_#{i}", :reader => readers(:normal))
|
90
91
|
end
|
91
|
-
lastpost =
|
92
|
+
lastpost = topic.posts.create!(:body => 'bar', :reader => readers(:normal))
|
92
93
|
firstpost.page_when_paginated.should == 1
|
93
94
|
lastpost.page_when_paginated.should == 3
|
94
95
|
end
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-forum-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 6
|
12
|
-
version: 3.0.0.rc6
|
10
|
+
version: 3.0.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- William Ross
|
@@ -17,7 +15,7 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2011-
|
18
|
+
date: 2011-09-06 00:00:00 +01:00
|
21
19
|
default_executable:
|
22
20
|
dependencies:
|
23
21
|
- !ruby/object:Gem::Dependency
|
@@ -28,14 +26,12 @@ dependencies:
|
|
28
26
|
requirements:
|
29
27
|
- - ~>
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
29
|
+
hash: 7
|
32
30
|
segments:
|
33
31
|
- 3
|
34
32
|
- 0
|
35
33
|
- 0
|
36
|
-
|
37
|
-
- 1
|
38
|
-
version: 3.0.0.rc1
|
34
|
+
version: 3.0.0
|
39
35
|
type: :runtime
|
40
36
|
version_requirements: *id001
|
41
37
|
- !ruby/object:Gem::Dependency
|
@@ -265,7 +261,7 @@ has_rdoc: true
|
|
265
261
|
homepage: http://radiant.spanner.org/forum
|
266
262
|
licenses: []
|
267
263
|
|
268
|
-
post_install_message: "\n Add this to your radiant project
|
264
|
+
post_install_message: "\n Add this to the Gemfile in your radiant project:\n\n gem 'radiant-forum-extension', '~> 3.0.0'\n\n "
|
269
265
|
rdoc_options: []
|
270
266
|
|
271
267
|
require_paths:
|
@@ -282,14 +278,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
282
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
279
|
none: false
|
284
280
|
requirements:
|
285
|
-
- - "
|
281
|
+
- - ">="
|
286
282
|
- !ruby/object:Gem::Version
|
287
|
-
hash:
|
283
|
+
hash: 3
|
288
284
|
segments:
|
289
|
-
-
|
290
|
-
|
291
|
-
- 1
|
292
|
-
version: 1.3.1
|
285
|
+
- 0
|
286
|
+
version: "0"
|
293
287
|
requirements: []
|
294
288
|
|
295
289
|
rubyforge_project:
|