public
Description: Blogging software
Homepage: http://tabularasa.petnuch.com
Clone URL: git://github.com/mpetnuch/tabula-rasa.git
Modified the post_controller to allow filtering by user_id.  Fixed up
the views for profiles.  Made modification to the menu migration file so
that update menus are populate (in case there was an error updating a
post/album/etc...).  Also added a profile menu to the root menubar.
Fixed permissions of the image files (removed execute permission on some
of the image files).
mpetnuch (author)
Sun Sep 14 10:55:27 -0700 2008
commit  ce6f1e87535589d7645b2ced372a939de1c8bce3
tree    c18f47ed426883e7522aa90dbd42ac2316ab6288
parent  f52eff38131ee00e7e4ff074bc6ed49ae2c65e18
...
14
15
16
17
 
18
19
20
...
14
15
16
 
17
18
19
20
0
@@ -14,7 +14,7 @@ class PostsController < ApplicationController
0
   # GET /posts.xml
0
   def index
0
 
0
- @posts = Post.search(params[:search], params[:page])
0
+ @posts = Post.search(params[:user], params[:page])
0
     @meta_title = "Posts - "
0
 
0
     respond_to do |format|
...
25
26
27
 
 
28
29
30
...
25
26
27
28
29
30
31
32
0
@@ -25,6 +25,8 @@ class UserService
0
   end
0
 
0
   def valid?
0
+ logger.warn('User not valid') unless @user.valid?
0
+ logger.warn('Photo not valid') unless @photo.valid?
0
     @user.valid? && @photo.valid?
0
   end
0
 
...
17
18
19
20
 
21
22
23
...
54
55
56
 
57
58
59
...
61
62
63
64
65
66
67
...
17
18
19
 
20
21
22
23
...
54
55
56
57
58
59
60
...
62
63
64
 
65
66
67
0
@@ -17,7 +17,7 @@ class UsersController < ApplicationController
0
   # GET /users.xml
0
   def index
0
 
0
- @users = User.find(:all)
0
+ @users = User.search(params[:search], params[:page])
0
 
0
     respond_to do |format|
0
       format.html # index.html.erb
0
@@ -54,6 +54,7 @@ class UsersController < ApplicationController
0
         format.xml { head :ok }
0
       else
0
         @user = @service.user
0
+ flash[:error] = 'User could not be updated.'
0
         format.html { render :action => "edit" }
0
         format.xml { render :xml => @user.errors,
0
           :status => :unprocessable_entity }
0
@@ -61,7 +62,6 @@ class UsersController < ApplicationController
0
     end
0
   end
0
 
0
-
0
   def create
0
     logout_keeping_session!
0
     @user = User.new(params[:user])
...
1
2
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1,5 +1,10 @@
0
 module UsersHelper
0
   
0
+ def edit_profile_link(user)
0
+ if(user == current_user)
0
+ link_to edit_icon, edit_user_path(user)
0
+ end
0
+ end
0
   #
0
   # Use this to wrap view elements that the user can't access.
0
   # !! Note: this is an *interface*, not *security* feature !!
...
28
29
30
31
 
 
 
 
 
32
33
34
...
28
29
30
 
31
32
33
34
35
36
37
38
0
@@ -28,7 +28,11 @@ class Post < ActiveRecord::Base
0
   end
0
 
0
   def self.search(search, page)
0
- paginate :per_page => 5, :page => page, :order => 'created_at DESC'
0
+ if search
0
+ paginate :per_page => 5, :page => page, :order => 'created_at DESC', :conditions => ['user_id = ?', search]
0
+ else
0
+ paginate :per_page => 5, :page => page, :order => 'created_at DESC'
0
+ end
0
   end
0
 
0
   def self.find_latest(limit = 5)
...
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66
67
...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
0
@@ -62,6 +62,21 @@ class User < ActiveRecord::Base
0
     [self.first_name, self.last_name].join(' ')
0
   end
0
 
0
+ def self.search(search, page)
0
+ paginate :per_page => 5, :page => page, :order => 'created_at'
0
+ end
0
+
0
+ private
0
+
0
+ def create_menu
0
+ parent_menu = Menu.find(:first, :conditions => ['controller = ? and action = ?', 'users', 'index'])
0
+ new_menu = Menu.new(:name => self.login, :controller => 'users', :action => 'show', :proposed_parent_id => parent_menu )
0
+ self.menu = new_menu
0
+
0
+ # Create edit/comment menus
0
+ Menu.create :name => 'Edit', :controller => 'users', :action => 'edit', :menuable_type => self.class.to_s, :menuable_id => self.id, :proposed_parent_id => new_menu
0
+ end
0
+
0
   protected
0
     
0
     def make_activation_code
...
3
4
5
 
6
7
8
...
3
4
5
6
7
8
9
0
@@ -3,6 +3,7 @@
0
     <ul class="simple_nav" id="main">
0
       <% Menu.root.children.each do |menu| %>
0
         <% next if self.logged_in? && menu.name =~ /Login/ %>
0
+ <% next if self.logged_in? && menu.name =~ /Register/ %>
0
         <% next if !self.logged_in? && menu.name =~ /Logout/ %>
0
         <% unless menu == current_menu.self_and_ancestors[1] %>
0
           <li><%= link_to menu.name, :controller => menu.controller, :action => menu.action %></li>
...
1
 
 
 
 
 
 
 
 
 
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
...
 
1
2
3
4
5
6
7
8
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
0
@@ -1,17 +1,12 @@
0
-<h2 class="border-red">Users</h2>
0
+<ul id="gallery" class="span-23 last">
0
+ <% @users.each do |user| %>
0
+ <li class="span-5 center">
0
+ <%= link_to profile_photo(user), user %>
0
+ <p class="span-5 center">
0
+ <%= link_to user.login, user %>
0
+ </p>
0
+ </li>
0
+ <% end %>
0
+</ul>
0
 
0
-<table>
0
- <tr>
0
- <th>User</th>
0
- <th>Image</th>
0
- </tr>
0
- <% for user in @users -%>
0
- <tr>
0
- <td><%=h user.login %></td>
0
- <td><%= profile_photo(user) %></td>
0
- <td><%= link_to 'Show', user %></td>
0
- <td><%= link_to 'Edit', edit_user_path(user) %></td>
0
- <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
0
- </tr>
0
- <% end -%>
0
-</table>
0
+<%= will_paginate @users %>
...
1
2
 
3
4
5
...
9
10
11
12
 
13
14
15
...
1
 
2
3
4
5
...
9
10
11
 
12
13
14
15
0
@@ -1,5 +1,5 @@
0
 <h2 class="border-red">
0
- <%= link_to edit_icon, edit_user_path(@user) %>
0
+ <%= edit_profile_link(@user) %>
0
   Profile for <%= @user.name %>
0
 </h2>
0
 
0
@@ -9,7 +9,7 @@
0
   <li><b>|</b></li>
0
   Total posts: <%= @user.posts.size %>
0
   <li><b>|</b></li>
0
- <li><%= link_to "Find all posts by #{@user.login}", posts_url(:search => @user) %></li>
0
+ <li><%= link_to "Find all posts by #{@user.login}", posts_url(:user => @user) %></li>
0
 </ul>
0
 <p class="post span-17">
0
 <%= @user.profile %>
...
21
22
23
 
24
25
26
...
32
33
34
 
35
36
37
...
46
47
48
 
49
50
51
...
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
59
60
...
21
22
23
24
25
26
27
...
33
34
35
36
37
38
39
...
48
49
50
51
52
53
54
...
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
0
@@ -21,6 +21,7 @@ class CreateMenus < ActiveRecord::Migration
0
 
0
       # Create edit/comment menus
0
       Menu.create :name => 'Edit', :controller => 'posts', :action => 'edit', :menuable_type => post.class.to_s, :menuable_id => post.id, :proposed_parent_id => post_menu
0
+ Menu.create :name => 'Update', :controller => 'posts', :action => 'update', :menuable_type => post.class.to_s, :menuable_id => post.id, :proposed_parent_id => post_menu
0
       Menu.create :name => 'Discuss', :controller => 'posts', :action => 'comment', :menuable_type => post.class.to_s, :menuable_id => post.id, :proposed_parent_id => post_menu
0
     end
0
 
0
@@ -32,6 +33,7 @@ class CreateMenus < ActiveRecord::Migration
0
 
0
       # Create edit/comment menus
0
       Menu.create :name => 'Edit', :controller => 'albums', :action => 'edit', :menuable_type => album.class.to_s, :menuable_id => album.id, :proposed_parent_id => album_menu
0
+ Menu.create :name => 'Update', :controller => 'albums', :action => 'update', :menuable_type => album.class.to_s, :menuable_id => album.id, :proposed_parent_id => album_menu
0
       Menu.create :name => 'Discuss', :controller => 'albums', :action => 'comment', :menuable_type => album.class.to_s, :menuable_id => album.id, :proposed_parent_id => album_menu
0
     end
0
 
0
@@ -46,6 +48,7 @@ class CreateMenus < ActiveRecord::Migration
0
 
0
       # Create edit/comment menus
0
       Menu.create :name => 'Edit', :controller => 'topics', :action => 'edit', :menuable_type => topic.class.to_s, :menuable_id => topic.id, :proposed_parent_id => topic_menu
0
+ Menu.create :name => 'Update', :controller => 'topics', :action => 'update', :menuable_type => topic.class.to_s, :menuable_id => topic.id, :proposed_parent_id => topic_menu
0
     end
0
 
0
     tags = Menu.create :name => 'Tags', :controller => 'tags', :action => 'index', :proposed_parent_id => searches
0
@@ -54,7 +57,20 @@ class CreateMenus < ActiveRecord::Migration
0
       tag.menu = tag_menu
0
     end
0
 
0
+ profiles = Menu.create :name => 'Profiles', :controller => 'users', :action => 'index', :proposed_parent_id => home
0
+ User.find(:all).each do |profile|
0
+ profile_menu = Menu.new :name => profile.login, :controller => 'users', :action => 'show', :proposed_parent_id => profiles
0
+ profile.menu = profile_menu
0
+
0
+ # Create edit menus
0
+ Menu.create :name => 'Edit', :controller => 'users', :action => 'edit', :menuable_type => profile.class.to_s,
0
+ :menuable_id => profile.id, :proposed_parent_id => profile_menu
0
+ Menu.create :name => 'Update', :controller => 'users', :action => 'update', :menuable_type => profile.class.to_s,
0
+ :menuable_id => profile.id, :proposed_parent_id => profile_menu
0
+ end
0
+
0
     Menu.create :name => 'Register', :controller => 'users', :action => 'new', :proposed_parent_id => home
0
+
0
     login = Menu.create :name => 'Login', :controller => 'sessions', :action => 'new', :proposed_parent_id => home
0
     Menu.create :name => 'Login Error', :controller => 'sessions', :action => 'create', :proposed_parent_id => login
0
     Menu.create :name => 'Logout', :controller => 'sessions', :action => 'logout', :proposed_parent_id => home
0
0
public/images/icons/grid.png 100644 → 100755
0
0
0
0
0
public/images/icons/rss.png 100644 → 100755
0
0
public/images/icons/srch_l.gif 100644 → 100755
0
public/images/icons/srch_r.gif 100644 → 100755
0
0
public/images/icons/star.gif 100644 → 100755
0
public/images/icons/tag.gif 100644 → 100755
0
0
0
public/images/site/gridbg.gif 100644 → 100755
0
public/images/site/sides.png 100644 → 100755
0
0
public/javascripts/effects.js 100755 → 100644
0
public/javascripts/lightbox.js 100755 → 100644
0
0

Comments

    No one has commented yet.