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
fixed multiple uploader, using swfupload now

Removed old flash multiple uploader in favor of swfupload, which seems 
more developed and better supported.
If you've over-ridden the default /photos/new.html.haml, you'll need to 
make some modifications in your version to keep up to date. See CE's 
version for an example of what to include in that view.
bborn (author)
Thu May 29 08:56:50 -0700 2008
commit  871f5a37a0d1c0a49db2fa3ad6490b2f471d320a
tree    ca5823262c3d77e31550d15c538bca40d89fe7ed
parent  1a6c5458b10b32ddf3841efe55b2909cb7ee2783
0
...
9
10
11
12
13
14
15
...
9
10
11
 
12
13
14
0
@@ -9,7 +9,6 @@ Requirements:
0
   - Several gems:
0
       rmagick
0
       hpricot
0
- mime-types
0
       htmlentities
0
       RedCloth
0
       rake 0.8.1
...
1
2
3
4
5
6
7
8
9
 
 
 
 
10
11
12
...
136
137
138
139
140
141
142
143
144
145
146
 
 
 
 
 
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 
 
 
 
 
167
168
169
...
206
207
208
209
210
211
212
213
214
...
1
 
2
3
4
5
6
 
 
7
8
9
10
11
12
13
...
137
138
139
 
 
 
 
 
 
 
 
140
141
142
143
144
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
147
148
149
150
151
152
153
...
190
191
192
 
 
 
193
194
195
0
@@ -1,12 +1,13 @@
0
 require 'pp'
0
-require 'mime/types'
0
 
0
 class PhotosController < BaseController
0
   before_filter :login_required, :only => [:new, :edit, :update, :destroy, :create, :manage_photos]
0
   before_filter :find_user, :only => [:new, :edit, :index, :show, :slideshow]
0
   before_filter :require_current_user, :only => [:new, :edit, :update, :destroy]
0
- before_filter :require_fake_session, :only => [:create_multiple]
0
- skip_before_filter :login_required, :only => [:create_multiple]
0
+
0
+ before_filter :require_fake_session, :only => [:swfupload]
0
+ skip_before_filter :login_required, :only => [:swfupload]
0
+
0
   uses_tiny_mce(:options => AppConfig.simple_mce_options, :only => [:show])
0
   
0
   def recent
0
@@ -136,34 +137,17 @@ class PhotosController < BaseController
0
     end
0
   end
0
   
0
- def create_multiple
0
- begin
0
- # capture incoming file params from flash
0
- unless data = params[:Filedata] and name = params[:Filename]
0
- render :nothing => true, :status => 500 and return
0
- end
0
-
0
- content_type = MIME::Types.of(name).first.content_type
0
+ def swfupload
0
+ # swfupload action set in routes.rb
0
+ @photo = Photo.new :uploaded_data => params[:Filedata]
0
+ @photo.user_id = @user
0
+ @photo.save!
0
     
0
- @photo = Photo.new
0
- return if data.nil? || data.size == 0
0
- @photo.content_type = content_type.strip
0
- @photo.filename = name.strip
0
- @photo.temp_data = data.read
0
- # @user should be set in the before filter
0
- @photo.user_id = @user
0
- if @photo.save!
0
- #start the garbage collector
0
- GC.start
0
- @photo.tag_with(params[:tag_list] || '')
0
- render :nothing => true, :status => 200 and return
0
- else
0
- render :nothing => true, :status => 500 and return
0
- end
0
- rescue
0
- raise
0
- end
0
- end
0
+ # This returns the thumbnail url for handlers.js to use to display the thumbnail
0
+ render :text => @photo.public_filename(:thumb)
0
+ rescue
0
+ render :text => "Error: #{$!}", :status => 500
0
+ end
0
   
0
   # PUT /photos/1
0
   # PUT /photos/1.xml
0
@@ -206,9 +190,6 @@ class PhotosController < BaseController
0
   protected
0
   def require_fake_session
0
     begin
0
- if RAILS_ENV.eql?('development') and params[:development]
0
- return @user = User.find(:first).id
0
- end
0
       fake_session = SqlSessionStore.session_class.find_session(params[:_session_id])
0
       @user = Marshal.load(Base64.decode64(fake_session.data))[:user]
0
       return @user
...
44
45
46
47
48
49
50
51
52
53
 
 
 
 
 
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
...
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
0
@@ -44,12 +44,24 @@
0
       Just uploading one photo?
0
 
0
     %p.centered
0
- %script{"type"=>"text/javascript"}
0
- function getCookie(){
0
- ="return \"_session_id=\" + Cookie.get(\"#{ActionController::Base.session.first[:session_key]}\");"
0
- }
0
- function getAppHost(){
0
- ="return '#{APP_URL}';"
0
- }
0
+ %script{:type=>'text/javascript'}
0
+ var uploader;
0
+ window.onload = function (){
0
+ ="uploader = new CommunityEngine.SwfUpload('#{swfupload_user_photos_path(:_session_id => session.session_id)}');"
0
+ };
0
         
0
- AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','500','height','300','src','/plugin_assets/community_engine/images/swf/upload','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','/plugin_assets/community_engine/images/swf/upload' ); //end AC code
0
\ No newline at end of file
0
+ %div{:style=>"margin: 0px 10px;"}
0
+ %div
0
+ %form.MainForm
0
+ %p
0
+ %button{:id=>"btnBrowse", :type=>"button", :style=>"padding: 5px;", :onclick=>"uploader.swfu.selectFiles(); this.blur();"}
0
+ =image_tag '/icons/add.png', :plugin => 'community_engine'
0
+ Select Images to Upload
0
+ %label
0
+ %em
0
+ You can select up to 5 files at a time.
0
+ %br
0
+ = (AppConfig.photo['attachment_fu_options']['max_size'])
0
+ megabyte upload limit per file.
0
+ #divFileProgressContainer{:style=>"height: 75px;"}
0
+ #thumbnails
0
\ No newline at end of file
...
11
12
13
 
 
 
 
 
14
15
16
...
11
12
13
14
15
16
17
18
19
20
21
0
@@ -11,6 +11,11 @@
0
 = javascript_include_tag "rounder", :plugin => "community_engine"
0
 = javascript_include_tag "AC_RunActiveContent", :plugin => "community_engine" if current_page?(:controller => 'photos', :action => 'new') or current_page?(:controller => 'statistics', :action => 'index')    
0
 
0
+- if current_page?(:controller => 'photos', :action => 'new')
0
+ = javascript_include_tag 'swfupload', :plugin => "community_engine"
0
+ = javascript_include_tag 'uploader', :plugin => "community_engine"
0
+
0
+
0
 = stylesheet_link_tag 'http://yui.yahooapis.com/2.5.1/build/reset-fonts-grids/reset-fonts-grids.css'
0
 = stylesheet_link_tag 'screen', :plugin => :community_engine
0
 
...
506
507
508
509
 
510
511
512
...
815
816
817
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
506
507
508
 
509
510
511
512
...
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
0
@@ -506,7 +506,7 @@ background: #ffd5d5;
0
 }
0
 
0
 /* submit */
0
-.MainForm p input{
0
+.MainForm p input, .MainForm p button {
0
 padding-left: 1em;
0
 padding-right: 1em;
0
 background: #008000;
0
@@ -815,3 +815,83 @@ div.user_list div.vcard {
0
     ul.subnav li a.active {
0
       color:#000;
0
       text-decoration:none;}
0
+
0
+
0
+/*SWF UPLOAD*/
0
+.progressWrapper {
0
+ width: 357px;
0
+ overflow: hidden;
0
+}
0
+.progressContainer {
0
+ margin: 5px;
0
+ padding: 4px;
0
+ border: solid 1px #E8E8E8;
0
+ background-color: #F7F7F7;
0
+ overflow: hidden;
0
+}
0
+.progressContainer .red {
0
+ border: solid 1px #B50000;
0
+ background-color: #FFEBEB;
0
+}
0
+.progressContainer .green {
0
+ border: solid 1px #DDF0DD;
0
+ background-color: #EBFFEB;
0
+}
0
+.progressContainer .blue {
0
+ border: solid 1px #CEE2F2;
0
+ background-color: #F0F5FF;
0
+}
0
+.progressName {
0
+ font-size: 8pt;
0
+ font-weight: bold;
0
+ color: #555555;
0
+ width: 323px;
0
+ height: 14px;
0
+ text-align: left;
0
+ white-space: nowrap;
0
+ overflow: hidden;
0
+}
0
+.progressBarInProgress,
0
+.progressBarComplete,
0
+.progressBarError {
0
+ font-size: 0px;
0
+ width: 0%;
0
+ height: 2px;
0
+ background-color: blue;
0
+ margin-top: 2px;
0
+}
0
+.progressBarComplete {
0
+ width: 100%;
0
+ background-color: green;
0
+ visibility: hidden;
0
+}
0
+.progressBarError {
0
+ width: 100%;
0
+ background-color: red;
0
+ visibility: hidden;
0
+}
0
+.progressBarStatus {
0
+ margin-top: 2px;
0
+ width: 337px;
0
+ font-size: 7pt;
0
+ font-family: Verdana;
0
+ text-align: left;
0
+ white-space: nowrap;
0
+}
0
+div.uploadStatus {
0
+ margin: 5px;
0
+}
0
+div.progressBar {
0
+ margin: 5px;
0
+}
0
+div.progressBar div.border {
0
+ background-color: #fff;
0
+ border: 1px solid gray;
0
+ width: 100%;
0
+}
0
+div.progressBar div.background {
0
+ background-color: #333;
0
+ height: 18px;
0
+ width: 0%;
0
+}
0
+
...
103
104
105
106
 
107
108
109
...
103
104
105
 
106
107
108
109
0
@@ -103,7 +103,7 @@ resources :users, :member_path => '/:id', :nested_member_path => '/:user_id', :m
0
     :statistics => :any
0
      } do |user|
0
   user.resources :friendships, :member => { :accept => :put, :deny => :put }, :collection => { :accepted => :get, :pending => :get, :denied => :get }
0
- user.resources :photos, :member => {:create_multiple => [:post, :get]}, :collection => {:slideshow => :get}
0
+ user.resources :photos, :collection => {:swfupload => :post, :slideshow => :get}
0
   user.resources :posts, :collection => {:manage => :get}, :member => {:contest => :get, :send_to_friend => :any, :update_views => :any}
0
   user.resources :clippings
0
   user.resources :activities, :collection => {:network => :get}

Comments

    No one has commented yet.