public
Description: My hobby project
Clone URL: git://github.com/Radar/rboard.git
Click here to lend your support to: rboard and make a donation at www.pledgie.com !
Added new stuff.
Radar (author)
Wed Sep 03 04:22:16 -0700 2008
commit  0d63219efc21fa6515f29acf632370bb76d4b7b2
tree    1875f17c953071fc8e4c33a6f1059f869c33ee78
parent  570c4a9a61e12c4fbf49c4f88c66b3e26ec2dfae
...
11
12
13
14
 
...
11
12
13
 
14
0
@@ -11,4 +11,4 @@ test
0
 coverage
0
 coverage/*
0
 config/*.sphinx.conf
0
-
0
+config/deploy.rb
...
2
3
4
5
6
7
8
9
10
11
12
13
 
 
 
 
 
 
 
 
 
14
15
16
17
 
18
19
20
...
55
56
57
58
59
60
61
62
63
64
65
 
 
 
 
 
 
 
66
67
68
...
2
3
4
 
 
 
 
 
 
 
 
 
5
6
7
8
9
10
11
12
13
14
15
16
 
17
18
19
20
...
55
56
57
 
 
 
 
 
 
 
 
58
59
60
61
62
63
64
65
66
67
0
@@ -2,19 +2,19 @@ class PostsController < ApplicationController
0
   before_filter :login_required
0
   
0
   def new
0
- @topic = Topic.find(params[:topic_id], :include => :posts)
0
- #is there an easier way to do this?
0
- @posts = @topic.last_10_posts
0
- @post = @topic.posts.build(:user => current_user)
0
- if params[:quote]
0
- @quoting_post = Post.find(params[:quote])
0
- @post.text = "[quote=\"" + @quoting_post.user.login + "\"]" + @quoting_post.text + "[/quote]"
0
- end
0
- end
0
+ @topic = Topic.find(params[:topic_id], :include => :posts)
0
+ #is there an easier way to do this?
0
+ @posts = @topic.last_10_posts
0
+ @post = @topic.posts.build(:user => current_user)
0
+ if params[:quote]
0
+ @quoting_post = Post.find(params[:quote])
0
+ @post.text = "[quote=\"" + @quoting_post.user.login + "\"]" + @quoting_post.text + "[/quote]"
0
+ end
0
+ end
0
 
0
   def create
0
     @topic = Topic.find(params[:topic_id], :include => :posts)
0
- @posts = is_admin? ? @topic.posts : @topic.user_posts
0
+ @posts = @topic.posts
0
     @posts = @posts.find(:all, :order => "id DESC", :limit => 10)
0
     @post = @posts.build(params[:post].merge!(:user => current_user))
0
     if @post.save
0
@@ -55,14 +55,13 @@ class PostsController < ApplicationController
0
   def destroy
0
     @post = Post.find(params[:id])
0
     @post.destroy
0
- flash[:notice] = "Post was deleted."
0
- if @post.topic.posts.size.zero?
0
- @post.topic.destroy
0
- flash[:notice] += " This was the only post in the topic, so topic was deleted also."
0
- redirect_to forum_path(@post.forum)
0
- else
0
- redirect_to forum_topic_path(@post.forum, @post.topic)
0
- end
0
+ flash[:notice] = "Post was deleted."
0
+ if @post.topic.posts.size.zero?
0
+ @post.topic.destroy
0
+ flash[:notice] += " This was the only post in the topic, so topic was deleted also."
0
+ redirect_to forum_path(@post.forum)
0
+ else
0
+ redirect_to forum_topic_path(@post.forum, @post.topic)
0
     end
0
   rescue ActiveRecord::RecordNotFound
0
     not_found
...
20
21
22
 
 
23
24
25
...
118
119
120
 
 
 
 
121
122
123
...
20
21
22
23
24
25
26
27
...
120
121
122
123
124
125
126
127
128
129
0
@@ -20,6 +20,8 @@ class TopicsController < ApplicationController
0
    end
0
   
0
   def new
0
+ check_ownership
0
+ puts "I SHOULD NEVER APPEAR"
0
     @topic = Topic.new
0
     @post = @topic.posts.build
0
   end
0
@@ -118,6 +120,10 @@ class TopicsController < ApplicationController
0
     end
0
   end
0
   
0
+ def check_ownership
0
+ redirect_to root_path and return false
0
+ end
0
+
0
   def find_forum
0
     @forum = Forum.find(params[:forum_id]) if params[:forum_id]
0
   end
...
62
63
64
 
 
 
 
 
65
66
67
...
62
63
64
65
66
67
68
69
70
71
72
0
@@ -62,6 +62,11 @@ class Forum < ActiveRecord::Base
0
     list.compact
0
   end
0
   
0
+ def self.woot
0
+ callback :after_woot
0
+ end
0
+
0
+
0
   def sub?
0
     !parent_id.nil?
0
   end
...
24
25
26
27
28
29
 
 
 
 
 
 
 
 
 
 
30
31
32
...
24
25
26
 
 
 
27
28
29
30
31
32
33
34
35
36
37
38
39
0
@@ -24,9 +24,16 @@ class Topic < ActiveRecord::Base
0
     new_forum = Forum.find(new_forum_id)
0
     update_attribute("forum_id", new_forum_id)
0
     is_new_last_post = new_forum.last_post.nil? || (new_forum.last_post.created_at <= posts.last.created_at)
0
- new_forum.update_last_post(new_forum, posts.last) if is_new_last_post
0
- old_forum.reload
0
- old_forum.update_last_post(new_forum) if was_old_last_post
0
+ if is_new_last_post
0
+ puts "UPDATING LAST POST FOR #{new_forum}"
0
+ new_forum.update_last_post(new_forum, posts.last)
0
+ end
0
+
0
+ if was_old_last_post
0
+ old_forum.reload
0
+ puts "UPDATING LAST POST FOR #{old_forum}"
0
+ old_forum.update_last_post(new_forum)
0
+ end
0
   end
0
   
0
   def lock!
...
16
17
18
19
 
20
21
22
...
40
41
42
43
 
44
45
46
...
16
17
18
 
19
20
21
22
...
40
41
42
 
43
44
45
46
0
@@ -16,7 +16,7 @@ require File.join(File.dirname(__FILE__), 'boot')
0
 Rails::Initializer.run do |config|
0
 
0
   # Settings in config/environments/* take precedence over those specified here
0
-
0
+ config.gem 'chronic'
0
   # Skip frameworks you're not going to use (only works if using vendor/rails)
0
   # config.frameworks -= [ :action_web_service, :action_mailer ]
0
 config.action_controller.session = { :session_key => "rboard_secret", :secret => "this is a super secret passphrase that protects rboard" }
0
@@ -40,7 +40,7 @@ config.action_controller.session = { :session_key => "rboard_secret", :secret =>
0
   # config.active_record.schema_format = :sql
0
 
0
   # Activate observers that should always be running
0
- # config.active_record.observers = :cacher, :garbage_collector
0
+ #config.active_record.observers = :forum_observer
0
 
0
   # Make Active Record use UTC-base instead of local time
0
   # config.active_record.default_timezone = :utc
...
13
14
15
 
16
17
18
19
20
21
22
23
...
13
14
15
16
17
18
 
 
 
19
20
21
0
@@ -13,11 +13,9 @@ ActionController::Routing::Routes.draw do |map|
0
     admin.resources :accounts, :collection => { :ban_ip => :any }, :member => { :ban => :any, :ban_ip => :any }
0
     admin.resources :themes, :member => { :make_default => :put }
0
     admin.resources :forums, :member => { :move_up => :put, :move_down => :put, :move_to_top => :put, :move_to_bottom => :put }
0
+ admin.chronic 'chronic', :controller => 'chronic'
0
   end
0
   
0
- #FIXME
0
- map.connect '/admin/chronic', :controller => "/admin/chronic"
0
-
0
   map.resources :forums, :collection => { :list => :get } do |forum|
0
     forum.resources :topics, :collection => { :moderate => :post }, :member => { :lock => :put, :unlock => :put }
0
   end
...
23
24
25
 
26
27
28
...
23
24
25
26
27
28
29
0
@@ -23,6 +23,7 @@ user_3:
0
   subject: Fifth topic!
0
   user: plebian
0
   forum: sub_of_everybody
0
+ last_post: user_3
0
   
0
 invalid:
0
   id: 4
...
1
2
 
3
4
5
6
7
8
 
9
 
10
11
12
...
43
44
45
46
 
47
48
49
...
72
73
74
 
 
 
 
 
 
 
 
 
 
 
 
 
75
...
1
 
2
3
4
5
6
7
 
8
9
10
11
12
13
...
44
45
46
 
47
48
49
50
...
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
0
@@ -1,12 +1,13 @@
0
 require File.dirname(__FILE__) + '/../spec_helper'
0
-describe Topic, "creation" do
0
+describe Topic, "in general" do
0
   fixtures :topics, :forums
0
   before do
0
     @topic = mock("topic")
0
     @forum = mock("forum")
0
     @invalid_topic = topics(:invalid)
0
- @valid_topic = topics(:user)
0
+ @valid_topic = topics(:user_3)
0
     @everybody = forums(:everybody)
0
+ @sub_of_everybody = forums(:sub_of_everybody)
0
     @admins_only = forums(:admins_only)
0
     # Remove the call to reverse for an interesting failing test
0
     @posts = @valid_topic.posts.reverse
0
@@ -43,7 +44,7 @@ describe Topic, "creation" do
0
   end
0
   
0
   it "should be able to show the string version" do
0
- @valid_topic.to_s.should eql("Third topic!")
0
+ @valid_topic.to_s.should eql("Fifth topic!")
0
   end
0
   
0
   it "should be able to lock a topic" do
0
@@ -72,4 +73,17 @@ describe Topic, "creation" do
0
     @valid_topic.should_not be_sticky
0
   end
0
   
0
+ it "should be able to move a topic from a sub-forum to a top-level forum" do
0
+ @everybody.last_post.should eql(@valid_topic.last_post)
0
+ @valid_topic.forum.should eql(@sub_of_everybody)
0
+ @valid_topic.move!(@admins_only.id)
0
+ @valid_topic.forum_id.should eql(@admins_only.id)
0
+ @sub_of_everybody.last_post_id.should be_nil
0
+ @everybody.last_post.should_not eql(@valid_topic.last_post)
0
+ @admins_only.reload
0
+ @admins_only.last_post.should eql(@valid_topic.last_post)
0
+ end
0
+
0
+
0
+
0
 end

Comments

    No one has commented yet.