Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
Raphael 2010-10-07 17:34:03 -07:00
commit 399e437655
6 changed files with 56 additions and 13 deletions

View file

@ -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] == '/'

View file

@ -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'

View file

@ -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

View file

@ -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 => APP_CONFIG[:terse_pod_url]}
config.action_mailer.smtp_settings = {
: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

View file

@ -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'

View file

@ -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