public
Description: Adds basic social networking capabilities to your existing application, including users, blogs, photos, clippings, favorites, and more.
Homepage: http://www.communityengine.org
Clone URL: git://github.com/bborn/communityengine.git
javascript fix to clipping create page (lightbox wasn't working), starting to 
use some nice named scoped on the post model (yay named scope!)
bborn (author)
Thu Aug 14 13:13:18 -0700 2008
commit  7c513ce9fb5abe1c5e89d84842a8bb3767731156
tree    b0a929b1b2df9f51c85bc75c1ef69665ee2b30e9
parent  a3f6244dd412a1574d8550cb1752e388a48bf30e
...
46
47
48
49
50
51
52
53
54
...
207
208
209
210
 
211
212
213
...
46
47
48
 
 
 
49
50
51
...
204
205
206
 
207
208
209
210
0
@@ -46,9 +46,6 @@ class PostsController < BaseController
0
     end
0
   end
0
   
0
-  def popular
0
-    @posts = Post.find(:all, :conditions => "published_at > '#{1.days.ago.to_s :db}'", :order => "view_count DESC")
0
-  end
0
     
0
   # GET /posts/1
0
   # GET /posts/1.xml
0
@@ -207,7 +204,7 @@ class PostsController < BaseController
0
   end
0
   
0
   def featured
0
-    @pages, @posts = paginate :posts, :order => "posts.published_at DESC", :conditions => ["users.featured_writer = ?", true], :include => :user
0
+    @pages, @posts = paginate :posts, :order => "posts.published_at DESC", :conditions => ["users.featured_writer = ?", 1], :include => :user
0
     @featured_writers = User.find_featured    
0
         
0
     @rss_title = "#{AppConfig.community_name} Featured Posts"
...
34
35
36
 
 
 
 
 
 
 
 
37
38
39
...
50
51
52
53
 
54
55
56
57
58
 
 
59
60
61
62
 
63
64
65
...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
...
58
59
60
 
61
62
63
64
65
 
66
67
68
69
70
 
71
72
73
74
0
@@ -34,6 +34,14 @@ class Post < ActiveRecord::Base
0
     
0
   attr_accessor :invalid_emails
0
   
0
+  #Named scopes
0
+  named_scope :by_featured_writers, :conditions => ["users.featured_writer = ?", 1], :include => :user
0
+  named_scope :recent, :order => 'published_at DESC'
0
+  named_scope :popular, :order => 'view_count DESC'
0
+  named_scope :since, lambda { |days|
0
+    {:conditions => "published_at > '#{days.ago.to_s :db}'" }
0
+  }
0
+  
0
   def self.find_related_to(post, options = {})
0
     merged_options = options.merge({:limit => 8, 
0
         :order => 'published_at DESC', 
0
@@ -50,16 +58,17 @@ class Post < ActiveRecord::Base
0
   end
0
   
0
   def self.find_recent(options = {:limit => 5})
0
-    find(:all, :order => "published_at desc", :limit => options[:limit], :include => :user)
0
+    self.recent.find :all, :limit => options[:limit]
0
   end
0
   
0
   def self.find_popular(options = {} )
0
     options.reverse_merge! :limit => 5, :since => 7.days
0
-    find(:all, :conditions => "published_at > '#{options[:since].ago.to_s :db}'", :order => "view_count desc", :limit => options[:limit])
0
+    
0
+    self.popular.since(options[:since]).find :all, :limit => options[:limit]
0
   end
0
 
0
   def self.find_featured(options = {:limit => 10})
0
-    find(:all, :order => "posts.published_at desc", :conditions => ["users.featured_writer = ?", true], :limit => options[:limit], :include => :user)    
0
+    self.recent.by_featured_writers.find(:all, :limit => options[:limit] )    
0
   end
0
 
0
   def self.find_most_commented(limit = 10, since = 7.days.ago)
...
132
133
134
135
 
136
137
138
...
132
133
134
 
135
136
137
138
0
@@ -132,7 +132,7 @@ class User < ActiveRecord::Base
0
   end  
0
     
0
   def self.find_featured
0
-    self.find(:all, :conditions => "featured_writer = 1")
0
+    self.find(:all, :conditions => ["featured_writer = ?", 1])
0
   end
0
   
0
   def this_months_posts
...
3
4
5
6
 
7
8
9
10
11
12
13
 
14
15
16
...
3
4
5
 
6
7
8
9
10
11
12
 
13
14
15
16
0
@@ -3,14 +3,14 @@
0
 .yui-b
0
 
0
   .box.alt.first_alt
0
-    %h3 Featured Writers
0
+    %h3=:staff_writers.l
0
     - @featured_writers.each do |user|
0
       = render :partial => "users/sidebar_user", :locals => {:user => user}
0
 
0
 #yui-main
0
   .yui-b
0
     .box.hfeed
0
-      %h3 Featured Posts
0
+      %h3="Featured Posts".l
0
 
0
       .pagination
0
         =pagination_links
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@
0
   .yui-b
0
     .box.hfeed
0
       %h3
0
-        =:recent_posts.l
0
+        =:recent_posts.l "Recent Posts"
0
         %ul.subnav
0
           %li= "(looking for {link}?)".l :looking_for_most_x, :link => link_to("popular".l, popular_path)
0
 
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@ var Lightbox = {
0
   /* hideAll - closes all open lightbox windows */
0
   hideAll: function(){
0
     lboxes = document.getElementsByClassName('lbox')
0
-    lboxes.each(function(box){
0
+    $A(lboxes).each(function(box){
0
         Element.hide(box)
0
       }
0
     )
...
10
11
12
 
 
13
14
15
...
10
11
12
13
14
15
16
17
0
@@ -10,6 +10,8 @@ all_clippings_tagged: All clippings tagged {tag_name}
0
 all_photos_tagged: All photos tagged {tag_name}
0
 #en: all_posts_tagged: All posts tagged {tag_name}
0
 all_posts_tagged: All posts tagged {tag_name}
0
+#en: all_tags: All tags
0
+all_tags: All tags
0
 #en: all_users_tagged: All users tagged {tag_name}
0
 all_users_tagged: All users tagged {tag_name}
0
 #en: comments_count: "{count} pluralize{{count}, comment}"
...
10
11
12
 
 
13
14
15
...
10
11
12
13
14
15
16
17
0
@@ -10,6 +10,8 @@ all_clippings_tagged: All clippings tagged {tag_name}
0
 all_photos_tagged: All photos tagged {tag_name}
0
 #en: all_posts_tagged: All posts tagged {tag_name}
0
 all_posts_tagged: All posts tagged {tag_name}
0
+#en: all_tags: All tags
0
+all_tags: All tags
0
 #en: all_users_tagged: All users tagged {tag_name}
0
 all_users_tagged: All users tagged {tag_name}
0
 #en: comments_count: "{count} pluralize{{count}, comment}"
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
0
 how_to:
0
   id: 1
0
-  name: How To
0
+  name: How to
0
 inspiration:
0
   id: 2
0
   name: Inspiration
...
16
17
18
19
 
20
21
22
...
16
17
18
 
19
20
21
22
0
@@ -16,7 +16,7 @@ class CommentTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_generate_commetable_url
0
-    assert_equal "http://localhost:3000/quentin/posts/1-Building-communities-is-all-about-love-#comment_1", comments(:quentins_comment_on_his_own_post).generate_commentable_url
0
+    assert_equal "http://#{APP_URL}/quentin/posts/1-Building-communities-is-all-about-love-#comment_1", comments(:quentins_comment_on_his_own_post).generate_commentable_url
0
   end
0
 
0
 end

Comments