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
making s3 file storage optional for photos, renaming application_helper to 
base_helper for consistency
bborn (author)
Sun Mar 30 18:40:04 -0700 2008
commit  1353701f35da7de5e4474123c95c2c5819c7b9ff
tree    9c11f556a7e96e9b58d9d1e2a93d25eee38e9bad
parent  ab50c1d94f2419e1c4593a5210c0c0b9573344c4
0
...
3
4
5
6
7
8
9
10
11
12
13
...
28
29
30
31
32
33
34
35
36
 
 
 
 
37
38
39
 
 
40
41
42
 
43
44
45
46
47
 
48
49
50
...
77
78
79
80
81
 
 
82
83
84
85
 
 
 
 
 
 
 
 
 
86
87
88
...
93
94
95
96
97
98
99
100
 
 
 
101
...
3
4
5
 
6
7
8
 
9
10
11
...
26
27
28
 
 
 
 
 
 
29
30
31
32
33
 
 
34
35
36
37
 
38
39
40
41
42
43
44
45
46
47
...
74
75
76
 
 
77
78
79
80
 
 
81
82
83
84
85
86
87
88
89
90
91
92
...
97
98
99
 
 
 
100
 
101
102
103
104
0
@@ -3,11 +3,9 @@ COMMUNITY ENGINE
0
 Requirements:
0
   - RAILS VERSION 2.0.2
0
   - The engines plugin (http://rails-engines.org/news/2007/12/11/engines-2-0-ish/)
0
- - An S3 account (for uploading photos)
0
   - ImageMagick
0
   - Several gems:
0
     rmagick
0
- aws-s3
0
     hpricot
0
     mime-types
0
     htmlentities
0
@@ -28,23 +26,22 @@ GETTING COMMUNITY ENGINE RUNNING
0
     # http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#submodules
0
 
0
 4. Create your database and modify your config/database.yml appropriately.
0
-5. Delete your application.rb and application_helper.rb
0
-6. Delete public/index.html (if you haven't already)
0
-7. Modify your environment.rb and environment files as indicated below
0
-8. Modify your routes.rb as indicated below
0
-9. Add amazon_s3.yml (required) to root config directory (examples are in /sample_files). You'll need an S3 account for photo uploading.
0
-10. Generate community engine migrations:
0
+5. Delete public/index.html (if you haven't already)
0
+6. Modify your environment.rb and environment files as indicated below.
0
+7. Modify your routes.rb as indicated below.
0
+8. Generate community engine migrations:
0
     script/generate plugin_migration
0
-11. rake db:migrate
0
-12. Run tests (if you want):
0
+9. rake db:migrate
0
+10. Run tests (if you want):
0
     rake test
0
     rake community_engine:test
0
-13. Start your server and check out your site!
0
+11. Start your server and check out your site!
0
     mongrel_rails start
0
     or
0
     ./script/server
0
 
0
 
0
+
0
 ## Modifying your environment.rb and environment files ##
0
 environment.rb should look something like this:
0
 ===============================================================
0
@@ -77,12 +74,19 @@ Adding this after any of your own existing routes:
0
 map.from_plugin :community_engine
0
 
0
 
0
-## CONFIGURATION ##
0
-Create an application.yml file in RAILS_ROOT/config (OPTIONAL)
0
+## CONFIGURATION (OPTIONAL) ##
0
+To override the default configuration, create an application.yml file in RAILS_ROOT/config
0
 ===============================================================
0
 The application configuration defined in this file overrides the one defined in /community_engine/engine_config/application.yml
0
-This is where you can change commonly used config variables, like AppConfig.community_name, etc.
0
-This YAML file will get converted into an OpenStruct, giving you things like AppConfig.whatever_variable_you_like
0
+This is where you can change commonly used configuration variables, like AppConfig.community_name, etc.
0
+This YAML file will get converted into an OpenStruct, giving you things like AppConfig.community_name, AppConfig.support_email, etc.
0
+
0
+## PHOTO UPLOADING ##
0
+By default CommunityEngine uses the filesystem to store photos.
0
+To use Amazon S3 as the backend for your file uploads, you'll need the aws-s3 gem installed, and you'll need to add a file called
0
+amazon_s3.yml to the application's root config directory (examples are in /community_engine/sample_files).
0
+You'll need to change your configuration in you application.yml to tell CommunityEngine to use s3 as the photo backend.
0
+You'll need an S3 account for S3 photo uploading.
0
 
0
 
0
 ## Create an s3.yml file in RAILS_ROOT/config (OPTIONAL) ##
0
@@ -93,8 +97,7 @@ in RAILS_ROOT/config/s3.yml. (Sample in engine_config/s3.yml)
0
 
0
 ## Other notes ##
0
 ===============================================================
0
-If you have an existing application.rb, nothing will work unless you modify it to
0
-include the methods in community_engine's application.rb (your application.rb takes precedence)
0
-
0
 To customize your application, just create views to override those in community_engine/app/views.
0
-For example, you could create RAILS_ROOT/app/views/layouts/application.haml and have that include your own stylesheets, etc.
0
+For example, you could create RAILS_ROOT/app/views/layouts/application.html.haml and have that include your own stylesheets, etc.
0
+
0
+You can also override CommunityEngine's controllers by creating identically-named controllers in your applications app/controllers directory.
0
\ No newline at end of file
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 
146
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
0
@@ -1,144 +1,2 @@
0
 class ApplicationController < ActionController::Base
0
-end
0
-
0
-# require 'hpricot'
0
-# require 'open-uri'
0
-# require 'pp'
0
-#
0
-# # Filters added to this controller will be run for all controllers in the application.
0
-# # Likewise, all the methods added will be available for all controllers.
0
-# class ApplicationController < ActionController::Base
0
-# helper :advertising
0
-# include AuthenticatedSystem
0
-# before_filter :login_from_cookie
0
-#
0
-# caches_action :site_index, :footer_content
0
-#
0
-# def cache_action?(action_name)
0
-# !logged_in? && controller_name.eql?('application') && params[:format].blank?
0
-# end
0
-# def action_fragment_key(options)
0
-# url = url_for(options).split('://').last
0
-# url = (url =~ /^.*\/$/) ? "#{url}index" : url
0
-# url
0
-# end
0
-#
0
-# if AppConfig.closed_beta_mode
0
-# before_filter :beta_login_required, :except => [:teaser]
0
-# end
0
-#
0
-# def teaser
0
-# redirect_to home_path and return if current_user
0
-# render :layout => 'beta'
0
-# end
0
-#
0
-# def rss_site_index
0
-# redirect_to :controller => 'application', :action => 'site_index', :format => 'rss'
0
-# end
0
-#
0
-# def plaxo
0
-# render :layout => false
0
-# end
0
-#
0
-# def site_index
0
-# @posts = Post.find_recent(:limit => 16)
0
-#
0
-# @rss_title = "Curbly Recent Posts"
0
-# @rss_url = rss_url
0
-# respond_to do |format|
0
-# format.html { get_additional_homepage_data }
0
-# format.rss do
0
-# render_rss_feed_for(@posts, { :feed => {:title => "#{AppConfig.community_name} Recent Posts", :link => recent_url},
0
-# :item => {:title => :title, :link => :link_for_rss, :description => :post, :pub_date => :created_at}
0
-# })
0
-# end
0
-# end
0
-# end
0
-#
0
-# def footer_content
0
-# get_recent_footer_content
0
-# render :partial => 'shared/footer_content' and return
0
-# end
0
-#
0
-# def homepage_features
0
-# @homepage_features = HomepageFeature.find_features
0
-# @homepage_features.shift
0
-# render :partial => 'homepage_feature', :collection => @homepage_features and return
0
-# end
0
-#
0
-# def about
0
-# end
0
-#
0
-# def advertise
0
-# end
0
-#
0
-# def faq
0
-# end
0
-#
0
-# def css_help
0
-# end
0
-#
0
-# def admin_required
0
-# current_user && current_user.admin? ? true : access_denied
0
-# end
0
-#
0
-# def find_user
0
-# if @user = User.find(params[:user_id] || params[:id])
0
-# @is_current_user = (@user && @user.eql?(current_user))
0
-# unless logged_in? || @user.profile_public?
0
-# flash.now[:error] = "This user's profile is not public. You'll need to create an account and log in to access it."
0
-# redirect_to :controller => 'sessions', :action => 'new'
0
-# end
0
-# return @user
0
-# else
0
-# flash.now[:error] = "Please log in."
0
-# redirect_to :controller => 'sessions', :action => 'new'
0
-# return false
0
-# end
0
-# end
0
-#
0
-# def require_current_user
0
-# @user ||= User.find(params[:user_id] || params[:id] )
0
-# unless admin? || (@user && (@user.eql?(current_user)))
0
-# redirect_to :controller => 'sessions', :action => 'new' and return false
0
-# end
0
-# return @user
0
-# end
0
-#
0
-# def popular_tags(limit = nil, order = ' tags.name ASC', type = nil)
0
-# sql = "SELECT tags.id, tags.name, count(*) AS count
0
-# FROM taggings, tags
0
-# WHERE tags.id = taggings.tag_id "
0
-# sql += " AND taggings.taggable_type = '#{type}'" unless type.nil?
0
-# sql += " GROUP BY tag_id"
0
-# sql += " ORDER BY #{order}"
0
-# sql += " LIMIT #{limit}" if limit
0
-# Tag.find_by_sql(sql).sort{ |a,b| a.name.downcase <=> b.name.downcase}
0
-# end
0
-#
0
-#
0
-# def get_recent_footer_content
0
-# @recent_clippings = Clipping.find_recent(:limit => 10)
0
-# @recent_photos = Photo.find_recent(:limit => 10)
0
-# @recent_comments = Comment.find_recent(:limit => 13)
0
-# @popular_tags = popular_tags(30, ' count DESC')
0
-# end
0
-#
0
-# def get_additional_homepage_data
0
-# @sidebar_right = true
0
-# @homepage_features = HomepageFeature.find_features
0
-# @homepage_features_data = @homepage_features.collect {|f| [f.id, f.public_filename(:large) ] }
0
-#
0
-# @active_users = User.find_by_activity({:limit => 5, :require_avatar => false})
0
-# @featured_writers = User.find_featured
0
-#
0
-# @featured_posts = Post.find_featured
0
-#
0
-# @topics = Topic.find(:all, :limit => 5, :order => "replied_at DESC")
0
-#
0
-# @active_contest = Contest.get_active
0
-# @popular_posts = Post.find_popular({:limit => 10})
0
-# @popular_polls = Poll.find_popular(:limit => 8)
0
-# end
0
-#
0
-# end
0
\ No newline at end of file
0
+end
0
\ No newline at end of file
...
1
2
 
 
 
3
4
5
6
7
8
9
 
10
11
12
...
1
2
3
4
5
6
 
 
 
 
 
 
7
8
9
10
0
@@ -1,12 +1,10 @@
0
 class Photo < ActiveRecord::Base
0
   acts_as_commentable
0
+
0
+ attachment_fu_options = AppConfig.photo['attachment_fu_options']
0
+ attachment_fu_options = attachment_fu_options.symbolize_keys.merge({:storage => attachment_fu_options['storage'].to_sym, :max_size => attachment_fu_options['max_size'].to_i.megabytes })
0
   
0
- has_attachment :storage => :s3,
0
- :min_size => 1,
0
- :max_size => AppConfig.photo['max_size'].megabytes,
0
- :resize_to => AppConfig.photo['resize_to'],
0
- :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png'],
0
- :thumbnails => AppConfig.photo['thumbs']
0
+ has_attachment attachment_fu_options
0
 
0
   acts_as_taggable
0
 
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ class UserNotifier < ActionMailer::Base
0
   include ActionController::UrlWriter
0
   include ActionView::Helpers::TextHelper
0
   include ActionView::Helpers::SanitizeHelper
0
- include ApplicationHelper
0
+ include BaseHelper
0
   
0
   def signup_invitation(email, user, message)
0
     setup_sender_info
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-<div class="banner_message" style="background:#E1DAFD;">
0
+<div class="banner_message">
0
   <div class="yui-gc">
0
     <div class="yui-u first">
0
       <h1>This is a phrase that explains the community.</h1>
...
37
38
39
40
 
41
42
43
...
37
38
39
 
40
41
42
43
0
@@ -37,7 +37,7 @@
0
       <% form_for(:photo, :url => user_photos_path({:user_id => @user, :inline => true}), :html => {:multipart =>true} ) do |f| %>
0
 
0
         <p><%= f.file_field :uploaded_data, :size=> '20' %>
0
- <br /><small><%= (AppConfig.photo['max_size']/1.megabyte) || '1' %> megabyte upload limit</small>
0
+ <br /><small><%= (AppConfig.photo['attachment_fu_options']['max_size']/1024) %> megabyte upload limit</small>
0
         </p>
0
 
0
         <p>
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@
0
       <% form_for(:photo, :url => user_photos_path, :html => {:multipart =>true} ) do |f| %>
0
 
0
         <p><%= f.file_field :uploaded_data %>
0
- <br /><small><%= (AppConfig.photo['max_size']/1.megabyte) || '1' %> megabyte upload limit</small>
0
+ <br /><small><%= (AppConfig.photo['attachment_fu_options']['max_size']) %> megabyte upload limit</small>
0
         </p>
0
 
0
         <p>
...
9
10
11
12
13
14
15
16
17
 
 
 
 
 
 
 
 
 
 
18
19
20
21
22
23
24
25
 
 
...
9
10
11
 
 
 
 
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
30
31
32
0
@@ -9,16 +9,23 @@ meta_keywords: 'keywords for use in META tags'
0
 featured_writer_label: 'Featured Writer'
0
 
0
 photo:
0
- resize_to: "465>"
0
- #size in megabytes
0
- max_size: 3
0
- thumbs: {thumb: "100x100!", medium: "290x320!", large: "664>"}
0
   missing_thumb: '/plugin_assets/community_engine/images/icon_missing_thumb.png'
0
   missing_medium: "/plugin_assets/community_engine/images/icon_missing_medium.png"
0
+ attachment_fu_options:
0
+ resize_to: "465>"
0
+ min_size: 1
0
+ #size in megabytes
0
+ max_size: 3
0
+ thumbnails: {thumb: "100x100!", medium: "290x320!", large: "664>"}
0
+ #options - 's3', 'file_system', 'db_system' - see attachment_fu for details
0
+ storage: 'file_system'
0
+ content_type: ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']
0
+
0
 feature:
0
   thumbs: {thumb: [45,45], large: [635,150]}
0
   use_thumbs: false
0
   dimensions: [150, 635]
0
 sections_enabled: ['photos', 'posts', 'clippings', 'contests', 'categories', 'events']
0
 show_advertising: false
0
-closed_beta_mode: false
0
\ No newline at end of file
0
+closed_beta_mode: false
0
+
...
1
2
3
4
5
6
7
8
9
10
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
 
16
17
18
19
 
 
 
 
20
21
...
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
18
19
 
20
 
21
22
23
24
25
26
0
@@ -1,20 +1,25 @@
0
-require 'aws/s3'
0
-
0
-# Adds expiration headers to all stored S3 objects through duck-punching.
0
-# Based on Keaka Jackson's original work.
0
-#
0
-module AWS::S3
0
- class S3Object
0
- class << self
0
- MAX_AGE = 8.years
0
- def store_with_cache_control(key, data, bucket = nil, options = {})
0
- if (options['Cache-Control'].blank?)
0
- options[:cache_control] = "max-age=#{MAX_AGE.to_i}"
0
- options[:expires] = MAX_AGE.from_now.httpdate
0
+begin
0
+ require 'aws/s3'
0
+
0
+ # Adds expiration headers to all stored S3 objects through duck-punching.
0
+ # Based on Keaka Jackson's original work.
0
+ #
0
+ module AWS::S3
0
+ class S3Object
0
+ class << self
0
+ MAX_AGE = 8.years
0
+ def store_with_cache_control(key, data, bucket = nil, options = {})
0
+ if (options['Cache-Control'].blank?)
0
+ options[:cache_control] = "max-age=#{MAX_AGE.to_i}"
0
+ options[:expires] = MAX_AGE.from_now.httpdate
0
+ end
0
+ store_without_cache_control(key, data, bucket, options)
0
         end
0
- store_without_cache_control(key, data, bucket, options)
0
+ alias_method_chain :store, :cache_control
0
       end
0
- alias_method_chain :store, :cache_control
0
     end
0
- end
0
+ end
0
+
0
+rescue LoadError
0
+ # silently fail here
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.