diff --git a/app/views/photos/edit.html.haml b/app/views/photos/edit.html.haml index 06556039c..e70030562 100644 --- a/app/views/photos/edit.html.haml +++ b/app/views/photos/edit.html.haml @@ -16,6 +16,7 @@ = p.label :caption = p.text_field :caption, :value => @photo.caption = p.submit + %div{:class => 'clear'} #content_bottom .back diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 787f5861d..53cda49ba 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -6,14 +6,56 @@ $(document).keydown(function(e){ switch(e.keyCode) { 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; case 39: - window.location.replace( "#{url_to_next(@photo,@album)}" ); + if(!$("textarea").hasClass("hasfocus")){ + window.location.replace( "#{url_to_next(@photo,@album)}" ); + } 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 = link_to "◂ #{@photo.album.name}", @photo.album @@ -38,7 +80,21 @@ #show_photo = linked_scaled_photo @photo, @album .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 .back diff --git a/config/routes.rb b/config/routes.rb index 12fae72e6..bcb237671 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,8 @@ Diaspora::Application.routes.draw do resources :photos, :except => [:index] resources :albums + devise_for :users, :controllers => {:registrations => "registrations", + :password => "devise/passwords"} # added public route to user match 'public/:username', :to => 'users#public' resources :users, :except => [:create, :new, :show] @@ -31,7 +33,6 @@ Diaspora::Application.routes.draw do 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, #non mutable stuff in anohter file - devise_for :users, :controllers => {:registrations => "registrations"} match 'login', :to => 'devise/sessions#new', :as => "new_user_session" match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" match 'signup', :to => 'registrations#new', :as => "new_user_registration" diff --git a/spec/lib/exporter_spec.rb b/spec/lib/exporter_spec.rb new file mode 100644 index 000000000..2831b8ef7 --- /dev/null +++ b/spec/lib/exporter_spec.rb @@ -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 +