From ad348ed24cdff569a9ad38944dc5f06062c18dac Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 7 Oct 2010 16:54:19 -0700 Subject: [PATCH 1/3] trying the mailer_condig --- config/environments/development.rb | 12 ------------ config/initializers/mailer_config.rb | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 config/initializers/mailer_config.rb diff --git a/config/environments/development.rb b/config/environments/development.rb index ee08a058f..80022947e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -24,16 +24,4 @@ Diaspora::Application.configure do config.active_support.deprecation = :log config.middleware.use MongoMapper::ClearDevMemory #config.threadsafe! - - config.action_mailer.delivery_method = :smtp - config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} - config.action_mailer.smtp_settings = { - :address => 'smtp.gmail.com', - :port => 587, - :domain => 'mail.joindiaspora.com', - :authentication => 'plain', - :user_name => 'diaspora-pivots@joindiaspora.com', - :password => "xy289|]G+R*-kA", - :enable_starttls_auto => true - } end diff --git a/config/initializers/mailer_config.rb b/config/initializers/mailer_config.rb new file mode 100644 index 000000000..46535ef84 --- /dev/null +++ b/config/initializers/mailer_config.rb @@ -0,0 +1,17 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +Diaspora::Application.configure do + config.action_mailer.delivery_method = :smtp + config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} + config.action_mailer.smtp_settings = { + :address => 'smtp.gmail.com', + :port => 587, + :domain => 'mail.joindiaspora.com', + :authentication => 'plain', + :user_name => 'diaspora-pivots@joindiaspora.com', + :password => "xy289|]G+R*-kA", + :enable_starttls_auto => true + } +end From 4deea9505734f6cbd7194fef119cef2721cc2a3c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 7 Oct 2010 16:56:10 -0700 Subject: [PATCH 2/3] DG MS; export photos button in users#edit --- app/controllers/users_controller.rb | 6 ++++++ app/views/users/edit.html.haml | 3 ++- config/routes.rb | 1 + lib/collect_user_photos.rb | 30 +++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 lib/collect_user_photos.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ac22a32b7..1efd61830 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,6 +5,7 @@ class UsersController < ApplicationController require File.expand_path('../../../lib/diaspora/ostatus_builder', __FILE__) require File.expand_path('../../../lib/diaspora/exporter', __FILE__) + require File.expand_path('../../../lib/collect_user_photos', __FILE__) before_filter :authenticate_user!, :except => [:new, :create, :public] @@ -62,6 +63,11 @@ class UsersController < ApplicationController send_data exporter.execute(current_user), :filename => "#{current_user.username}_diaspora_data.xml", :type => :xml end + def export_photos + tar_path = PhotoMover::move_photos(current_user) + send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" ) + end + private def prep_image_url(params) url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/' diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index e3fdca4ff..0c2f5b3e4 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -26,7 +26,8 @@ = render 'users/profile' #account.settings_pane - = link_to "download my stuff", users_export_path, :class => "button" + = link_to "download my xml", users_export_path, :class => "button" + = link_to "download my photos", users_export_photos_path, :class => "button" #services.settings_pane = render 'users/services' diff --git a/config/routes.rb b/config/routes.rb index 6f9f529db..3c5dd0755 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ Diaspora::Application.routes.draw do # added public route to user match 'public/:username', :to => 'users#public' match 'users/export', :to => 'users#export' + match 'users/export_photos', :to => 'users#export_photos' resources :users, :except => [:create, :new, :show] match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' diff --git a/lib/collect_user_photos.rb b/lib/collect_user_photos.rb new file mode 100644 index 000000000..f379e9ff1 --- /dev/null +++ b/lib/collect_user_photos.rb @@ -0,0 +1,30 @@ +module PhotoMover + + def self.move_photos(user) + + Dir.chdir Rails.root + temp_dir = "tmp/exports/#{user.id}" + FileUtils::mkdir_p temp_dir + Dir.chdir 'tmp/exports' + + albums = user.visible_posts(:person_id => user.person.id, :_type => 'Album') + + albums.each do |album| + album_dir = "#{user.id}/#{album.name}" + `mkdir #{album_dir}` + + album.photos.each do |photo| + current_photo_location = "#{Rails.root}/public/uploads/images/#{photo.image_filename}" + new_photo_location = "#{album_dir}/#{photo.image_filename}" + + `cp #{current_photo_location} #{new_photo_location}` + end + end + + `tar cf #{user.id}.tar #{user.id}` + `rm -r #{user.id}` + + "#{Rails.root}/#{temp_dir}.tar" + end + +end From 97f058c6251c078f2265ff418a087c6bdb89bb01 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 7 Oct 2010 17:00:38 -0700 Subject: [PATCH 3/3] moving to app config yml --- config/initializers/mailer_config.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/initializers/mailer_config.rb b/config/initializers/mailer_config.rb index 46535ef84..73928f740 100644 --- a/config/initializers/mailer_config.rb +++ b/config/initializers/mailer_config.rb @@ -4,14 +4,14 @@ Diaspora::Application.configure do config.action_mailer.delivery_method = :smtp - config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} + config.action_mailer.default_url_options = {:host => APP_CONFIG[:terse_pod_url]} config.action_mailer.smtp_settings = { - :address => 'smtp.gmail.com', - :port => 587, - :domain => 'mail.joindiaspora.com', - :authentication => 'plain', - :user_name => 'diaspora-pivots@joindiaspora.com', - :password => "xy289|]G+R*-kA", + :address => APP_CONFIG[:smtp_address], + :port => APP_CONFIG[:smtp_port], + :domain => APP_CONFIG[:smtp_domain], + :authentication => APP_CONFIG[:smtp_authentication], + :user_name => APP_CONFIG[:smtp_username], + :password => APP_CONFIG[:smtp_password], :enable_starttls_auto => true } end