public
Description: El Dorado is a full-stack community web application written in Ruby/Rails.
Homepage: http://almosteffortless.com/eldorado/
Clone URL: git://github.com/trevorturk/el-dorado.git
adding locate action for posts to find within thread, adding edit and 
quote links to posts in search results

git-svn-id: http://eldorado.googlecode.com/svn/trunk@437 
9c008b19-a030-0410-9975-d76d301b4276
trevorturk (author)
Sat Sep 01 14:01:11 -0700 2007
commit  b3d6e54755ddbca74b0ba83d2754b12bfa231e0a
tree    ea63cfcf01141deb70366611eb65fbe7eee9848c
parent  0d88b0ff7d2a9a460e76ed9e9c04ab654585ba7d
...
1
2
3
4
 
5
6
7
...
42
43
44
 
 
 
 
 
45
46
47
...
1
2
3
 
4
5
6
7
...
42
43
44
45
46
47
48
49
50
51
52
0
@@ -1,7 +1,7 @@
0
 class PostsController < ApplicationController
0
   
0
   before_filter :redirect_to_home, :only => [:index, :show]
0
- before_filter :force_login
0
+ before_filter :force_login, :except => [:locate]
0
   before_filter :find_topic_and_post, :except => [:index, :new, :create]
0
   before_filter :can_edit_post, :only => [:edit, :update, :destroy]
0
   
0
@@ -42,6 +42,11 @@ class PostsController < ApplicationController
0
     @post.body = "[quote=#{@post.user.login}]#{@post.body}[/quote]"
0
     render :template => "posts/_new"
0
   end
0
+
0
+ def locate
0
+ @post = Post.find(params[:id])
0
+ redirect_to :controller => 'topics', :action => 'show', :id => @post.topic.id, :page => @post.page, :anchor => 'p' + @post.id.to_s
0
+ end
0
     
0
   def find_topic_and_post
0
     @post = Post.find(params[:id])
...
15
16
17
18
 
19
20
21
...
15
16
17
 
18
19
20
21
0
@@ -15,7 +15,7 @@ class SearchController < ApplicationController
0
       @headers = Header.paginate(:page => params[:page], :per_page => Topic::PER_PAGE, :include => :user, :order => 'headers.created_at desc', :conditions => ["filename LIKE ?", '%' + params[:query] + '%'])
0
       render :template => "headers/index"
0
     elsif params[:type] == 'posts'
0
- @posts = Post.paginate(:page => params[:page], :per_page => Topic::PER_PAGE, :include => :user, :order => 'posts.created_at desc', :conditions => ["body LIKE ?", '%' + params[:query] + '%'])
0
+ @posts = Post.paginate(:page => params[:page], :per_page => Topic::PER_PAGE, :include => [:user, :topic], :order => 'posts.created_at desc', :conditions => ["body LIKE ?", '%' + params[:query] + '%'])
0
       render :template => "topics/show"
0
     elsif params[:type] == 'topics'
0
       @topics = Topic.paginate(:page => params[:page], :per_page => Topic::PER_PAGE, :include => [:user, :last_poster], :order => 'last_post_at desc', :conditions => ["title LIKE ?", '%' + params[:query] + '%'])
...
4
5
6
7
 
 
8
9
10
...
4
5
6
 
7
8
9
10
11
0
@@ -4,7 +4,8 @@
0
     <span class="top">Edit Post</span>
0
     <p><%= f.text_area :body, :rows => '10', :style => 'width:66%;' %></p>
0
     <p>
0
- <%= submit_tag "Save Changes", :disable_with => "Save Changes" %>
0
+ <%= submit_tag "Save Changes", :disable_with => "Save Changes" %> or
0
+ <%= link_to('Upload a New File', new_upload_path, :popup => ['height=530,width=820,status=1']) %> or
0
       <% if @topic.posts_count > 1 %>
0
         <%= link_to 'Delete', post_path, :confirm => 'Are you sure?', :method => :delete %> or
0
       <% end %>
...
33
34
35
36
 
37
38
39
...
83
84
85
86
87
88
 
 
 
 
 
 
 
89
 
90
91
92
93
 
94
95
96
...
33
34
35
 
36
37
38
39
...
83
84
85
 
 
 
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
0
@@ -33,7 +33,7 @@
0
         <th><%= time_ago_or_time_stamp(post.created_at, TzTime.now, true, true) %></th>
0
         <th class="thr">
0
           <% if current_controller == 'search' %>
0
- <%= link_to post.topic.title + ' &raquo;', topic_path(:id => post.topic.id) %>
0
+ <%= link_to post.topic.title + ' &raquo;', locate_post_path(post) %>
0
           <% else %>
0
             <%= link_to "#" + (index + @padding).to_s, topic_path(:page => @page, :anchor => 'p' + post.id.to_s) %>
0
           <% end %>
0
@@ -83,14 +83,20 @@
0
           <% end %>
0
         </td>
0
         <td class="body links">
0
- <% unless current_controller == 'search' %>
0
- <% if can_edit?(post) %>
0
- <%= link_to 'Edit', edit_post_path(post) %>&nbsp;|
0
+ <% if can_edit?(post) %>
0
+ <%= link_to 'Edit', edit_post_path(post) %>&nbsp;|
0
+ <% end %>
0
+
0
+ <% if current_controller == 'search' %>
0
+ <% if logged_in? && !post.topic.closed %>
0
+ <%= link_to 'Quote', quote_post_path(post) %>
0
             <% end %>
0
+ <% else %>
0
             <% if logged_in? && !@topic.closed %>
0
               <%= link_to 'Quote', quote_post_path(post) %>
0
             <% end %>
0
           <% end %>
0
+
0
         </td>
0
       </tr>
0
     </tbody>
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ ActionController::Routing::Routes.draw do |map|
0
   map.resources :events
0
   map.resources :forums
0
   map.resources :headers, :member => { :vote_up => :post, :vote_down => :post }
0
- map.resources :posts, :member => { :quote => :get }
0
+ map.resources :posts, :member => { :quote => :get, :locate => :get }
0
   map.resources :subscriptions
0
   map.resources :themes, :member => { :select => :post, :deselect => :post }
0
   map.resources :topics, :member => { :show_new => :get }
...
87
88
89
 
 
 
 
 
90
...
87
88
89
90
91
92
93
94
95
0
@@ -87,4 +87,9 @@ class PostsControllerTest < Test::Unit::TestCase
0
     assert_equal topics(:Testing).last_post_id, posts(:one2).id
0
   end
0
   
0
+ def test_locate_action_should_work
0
+ get :locate, :id => 1
0
+ assert_redirected_to :controller => 'topics', :action => 'show', :id => '1', :page => '1'
0
+ end
0
+
0
 end

Comments

    No one has commented yet.