Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
b63fb5d7a6
8 changed files with 127 additions and 28 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
require File.expand_path('../../../lib/diaspora/ostatus_builder', __FILE__)
|
require File.expand_path('../../../lib/diaspora/ostatus_builder', __FILE__)
|
||||||
|
require File.expand_path('../../../lib/diaspora/exporter', __FILE__)
|
||||||
|
|
||||||
before_filter :authenticate_user!, :except => [:new, :create, :public]
|
before_filter :authenticate_user!, :except => [:new, :create, :public]
|
||||||
|
|
||||||
|
|
@ -56,6 +57,11 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def export
|
||||||
|
exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML)
|
||||||
|
render :xml => exporter.execute(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def prep_image_url(params)
|
def prep_image_url(params)
|
||||||
url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'
|
url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
= p.label :caption
|
= p.label :caption
|
||||||
= p.text_field :caption, :value => @photo.caption
|
= p.text_field :caption, :value => @photo.caption
|
||||||
= p.submit
|
= p.submit
|
||||||
|
%div{:class => 'clear'}
|
||||||
|
|
||||||
#content_bottom
|
#content_bottom
|
||||||
.back
|
.back
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,56 @@
|
||||||
$(document).keydown(function(e){
|
$(document).keydown(function(e){
|
||||||
switch(e.keyCode) {
|
switch(e.keyCode) {
|
||||||
case 37:
|
case 37:
|
||||||
window.location.replace( "#{url_to_prev(@photo,@album)}" );
|
if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus
|
||||||
|
window.location.replace( "#{url_to_prev(@photo,@album)}" );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 39:
|
case 39:
|
||||||
window.location.replace( "#{url_to_next(@photo,@album)}" );
|
if(!$("textarea").hasClass("hasfocus")){
|
||||||
|
window.location.replace( "#{url_to_next(@photo,@album)}" );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
//add a clas to verify if a textarea has focus
|
||||||
|
$("textarea").live('focus',function(){
|
||||||
|
$(this).addClass("hasfocus");
|
||||||
|
});
|
||||||
|
$("textarea").live('blur',function(){
|
||||||
|
$(this).removeClass("hasfocus");
|
||||||
|
});
|
||||||
|
|
||||||
|
//show form to add description
|
||||||
|
$(".edit-desc").click(function(){
|
||||||
|
$(".edit_photo").toggle();
|
||||||
|
//$(".caption").toggle();
|
||||||
|
});
|
||||||
|
|
||||||
|
//Add a description with ajax request
|
||||||
|
$("#photo_submit").click(function(evenet){
|
||||||
|
event.preventDefault();
|
||||||
|
var method = $(".edit_photo").attr("method");
|
||||||
|
var url = $(".edit_photo").attr("action");
|
||||||
|
var data = $(".edit_photo").serialize();
|
||||||
|
$(".description").text($("#photo_caption").val());
|
||||||
|
//$(".caption").toggle();
|
||||||
|
$(".edit_photo").toggle();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: method,
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: function(response){
|
||||||
|
$("#add-description").remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});//end document ready
|
||||||
|
|
||||||
= content_for :page_title do
|
= content_for :page_title do
|
||||||
= link_to "◂ #{@photo.album.name}", @photo.album
|
= link_to "◂ #{@photo.album.name}", @photo.album
|
||||||
|
|
||||||
|
|
@ -38,7 +80,21 @@
|
||||||
#show_photo
|
#show_photo
|
||||||
= linked_scaled_photo @photo, @album
|
= linked_scaled_photo @photo, @album
|
||||||
.caption
|
.caption
|
||||||
= @photo.caption
|
-if current_user.owns? @album
|
||||||
|
-if @photo.caption and @photo.caption != ""
|
||||||
|
= link_to 'Edit','javascript:void(0)', :id => "edit-desc", :class => "edit-desc"
|
||||||
|
.description
|
||||||
|
= @photo.caption
|
||||||
|
|
||||||
|
-if current_user.owns? @album
|
||||||
|
%div{:class => 'clear'}
|
||||||
|
-if !@photo.caption or @photo.caption == ""
|
||||||
|
= link_to 'Add a description','javascript:void(0)', :id => "add-description", :class => "edit-desc"
|
||||||
|
|
||||||
|
= form_for @photo do |p|
|
||||||
|
= p.text_field :caption, :value => @photo.caption
|
||||||
|
= p.submit
|
||||||
|
%div{:class => 'clear'}
|
||||||
|
|
||||||
#content_bottom
|
#content_bottom
|
||||||
.back
|
.back
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,15 @@ Diaspora::Application.configure do
|
||||||
config.active_support.deprecation = :log
|
config.active_support.deprecation = :log
|
||||||
config.middleware.use MongoMapper::ClearDevMemory
|
config.middleware.use MongoMapper::ClearDevMemory
|
||||||
#config.threadsafe!
|
#config.threadsafe!
|
||||||
config.action_mailer.delivery_method = :smtp
|
config.action_mailer.delivery_method = :smtp
|
||||||
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
|
config.action_mailer.default_url_options = {:host => APP_CONFIG[:terse_pod_url]}
|
||||||
config.action_mailer.smtp_settings = {
|
config.action_mailer.smtp_settings = {
|
||||||
:address => 'smtp.gmail.com',
|
:address => APP_CONFIG[:smtp_address],
|
||||||
:port => 587,
|
:port => APP_CONFIG[:smtp_port],
|
||||||
:domain => 'mail.joindiaspora.com',
|
:domain => APP_CONFIG[:smtp_domain],
|
||||||
:authentication => 'plain',
|
:authentication => APP_CONFIG[:smtp_authentication],
|
||||||
:user_name => 'diaspora-pivots@joindiaspora.com',
|
:user_name => APP_CONFIG[:smtp_username],
|
||||||
:password => "xy289|]G+R*-kA",
|
:password => APP_CONFIG[:smtp_password],
|
||||||
:enable_starttls_auto => true
|
:enable_starttls_auto => true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,14 @@ Diaspora::Application.configure do
|
||||||
config.threadsafe!
|
config.threadsafe!
|
||||||
|
|
||||||
config.action_mailer.delivery_method = :smtp
|
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 = {
|
config.action_mailer.smtp_settings = {
|
||||||
:address => 'smtp.gmail.com',
|
:address => APP_CONFIG[:smtp_address],
|
||||||
:port => 587,
|
:port => APP_CONFIG[:smtp_port],
|
||||||
:domain => 'mail.joindiaspora.com',
|
:domain => APP_CONFIG[:smtp_domain],
|
||||||
:authentication => 'plain',
|
:authentication => APP_CONFIG[:smtp_authentication],
|
||||||
:user_name => 'diaspora-pivots@joindiaspora.com',
|
:user_name => APP_CONFIG[:smtp_username],
|
||||||
:password => "xy289|]G+R*-kA",
|
:password => APP_CONFIG[:smtp_password],
|
||||||
:enable_starttls_auto => true
|
:enable_starttls_auto => true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,12 @@ Diaspora::Application.routes.draw do
|
||||||
resources :photos, :except => [:index]
|
resources :photos, :except => [:index]
|
||||||
resources :albums
|
resources :albums
|
||||||
|
|
||||||
|
devise_for :users, :controllers => {:registrations => "registrations",
|
||||||
|
:password => "devise/passwords"}
|
||||||
# added public route to user
|
# added public route to user
|
||||||
match 'public/:username', :to => 'users#public'
|
match 'public/:username', :to => 'users#public'
|
||||||
resources :users, :except => [:create, :new, :show]
|
match 'users/export', :to => 'users#export'
|
||||||
|
resources :users, :except => [:create, :new, :show]
|
||||||
|
|
||||||
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
|
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
|
||||||
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
||||||
|
|
@ -31,7 +34,6 @@ Diaspora::Application.routes.draw do
|
||||||
match 'set_profile_photo', :to => "dev_utilities#set_profile_photo"
|
match 'set_profile_photo', :to => "dev_utilities#set_profile_photo"
|
||||||
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
|
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
|
||||||
#non mutable stuff in anohter file
|
#non mutable stuff in anohter file
|
||||||
devise_for :users, :controllers => {:registrations => "registrations"}
|
|
||||||
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
||||||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
||||||
match 'signup', :to => 'registrations#new', :as => "new_user_registration"
|
match 'signup', :to => 'registrations#new', :as => "new_user_registration"
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,6 @@
|
||||||
|
|
||||||
module Diaspora
|
module Diaspora
|
||||||
|
|
||||||
def self.bone(user)
|
|
||||||
exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML)
|
|
||||||
exporter.execute(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
class Exporter
|
class Exporter
|
||||||
def initialize(strategy)
|
def initialize(strategy)
|
||||||
self.class.send(:include, strategy)
|
self.class.send(:include, strategy)
|
||||||
|
|
@ -22,7 +17,7 @@ module Diaspora
|
||||||
xml.user {
|
xml.user {
|
||||||
xml.username user.username
|
xml.username user.username
|
||||||
xml.serialized_private_key user.serialized_private_key
|
xml.serialized_private_key user.serialized_private_key
|
||||||
xml.person user.person.to_xml
|
xml.parent << user.person.to_xml
|
||||||
|
|
||||||
xml.aspects {
|
xml.aspects {
|
||||||
user.aspects.each do |aspect|
|
user.aspects.each do |aspect|
|
||||||
|
|
@ -36,8 +31,14 @@ module Diaspora
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
xml.posts {
|
xml.posts {
|
||||||
aspect.posts.each do |post|
|
aspect.posts.find_all_by_person_id(user.person.id).each do |post|
|
||||||
xml.post post.to_xml if post.respond_to? :to_xml
|
post_doc = post.to_xml
|
||||||
|
|
||||||
|
post.comments.each do |comment|
|
||||||
|
post_doc << comment.to_xml
|
||||||
|
end
|
||||||
|
|
||||||
|
xml.post post_doc
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
33
spec/lib/exporter_spec.rb
Normal file
33
spec/lib/exporter_spec.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
require File.dirname(__FILE__) + '/../../lib/diaspora/exporter'
|
||||||
|
|
||||||
|
describe Diaspora::Exporter do
|
||||||
|
|
||||||
|
let!(:user1) { Factory(:user) }
|
||||||
|
let!(:user2) { Factory(:user) }
|
||||||
|
|
||||||
|
let(:aspect1) { user1.aspect(:name => "Work") }
|
||||||
|
let(:aspect2) { user2.aspect(:name => "Family") }
|
||||||
|
|
||||||
|
let!(:status_message1) { user1.post(:status_message, :message => "One", :public => true, :to => aspect1.id) }
|
||||||
|
let!(:status_message2) { user1.post(:status_message, :message => "Two", :public => true, :to => aspect1.id) }
|
||||||
|
let!(:status_message3) { user2.post(:status_message, :message => "Three", :public => false, :to => aspect2.id) }
|
||||||
|
|
||||||
|
let!(:exported) { Diaspora::Exporter.new(Diaspora::Exporters::XML).execute(user1) }
|
||||||
|
|
||||||
|
it 'should include a users posts' do
|
||||||
|
exported.should include status_message1.to_xml.to_s
|
||||||
|
exported.should include status_message2.to_xml.to_s
|
||||||
|
exported.should_not include status_message3.to_xml.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should include a users private key' do
|
||||||
|
exported.should include user1.serialized_private_key
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Reference in a new issue