a person now has a photos#index page.

This commit is contained in:
danielvincent 2010-10-23 21:49:53 -07:00
parent aaff5083f0
commit 2b4e3e3a41
11 changed files with 140 additions and 80 deletions

View file

@ -8,6 +8,16 @@ class PhotosController < ApplicationController
respond_to :html respond_to :html
respond_to :json, :only => :show respond_to :json, :only => :show
def index
if params[:person_id]
@person = current_user.visible_people.find_by_person_id(params[:person_id])
end
@person ||= current_user.person
@photos = current_user.visible_posts(:_type => "Photo", :person_id => @person.id)
@albums = current_user.visible_posts(:_type => "Album", :person_id => @person.id)
end
def create def create
album = current_user.find_visible_post_by_id( params[:album_id] ) album = current_user.find_visible_post_by_id( params[:album_id] )
@ -78,6 +88,8 @@ class PhotosController < ApplicationController
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else else
@album = @photo.album @album = @photo.album
@ownership = current_user.owns? @photo
respond_with @photo, @album respond_with @photo, @album
end end
end end

View file

@ -78,4 +78,11 @@ module ApplicationHelper
def post_yield_tag(post) def post_yield_tag(post)
(':' + post.id.to_s).to_sym (':' + post.id.to_s).to_sym
end end
def person_photos_path person
person_id = person.id if person.respond_to?(:id)
person_id ||= person
"#{photos_path}?person_id=#{person_id}"
end
end end

View file

@ -2,12 +2,6 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
- content_for :head do
:javascript
$(document).ready(function(){
$("#add_album_button").fancybox();
});
.span-4.append-1.last .span-4.append-1.last
= render "shared/aspect_friends" = render "shared/aspect_friends"

View file

@ -10,10 +10,10 @@
}); });
= render 'shared/author_info', :post => @album = render 'shared/author_info', :person => @album.person, :post => @album
%ul#breadcrumb %ul#breadcrumb
%li= link_to "#{@album.person.profile.first_name}'s Photos", '#' %li= link_to "#{@album.person.profile.first_name}'s Photos", person_photos_path(@album.person)
%li= @album.name %li= @album.name

View file

@ -0,0 +1,34 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
:javascript
$(document).ready(function(){
$(".image_thumb img").load( function() {
$(this).fadeIn("slow");
});
});
= render 'shared/author_info', :person => @person
%ul#breadcrumb
%li= link_to "#{@person.profile.first_name}'s Photos", person_photos_path(@person)
.span-24.last
#thumbnails
- for photo in @photos
.image_thumb
= link_to (image_tag photo.url(:thumb_medium)), object_path(photo)
.span-24.last
%h3
Photos
%div
- for album in @albums
= render "albums/album", :post => album
.span-24.last
%h3
Albums

View file

@ -3,93 +3,46 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
- content_for :head do - content_for :head do
:javascript =javascript_include_tag 'photo'
$(document).keydown(function(e){
switch(e.keyCode) {
case 37:
if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus
window.location.replace( "#{url_to_prev(@photo,@album)}" );
}
break;
case 39:
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 = render 'shared/author_info', :person => @photo.person, :post => @photo
$(".edit-desc").click(function(){
$(".edit_photo").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());
$(".edit_photo").toggle();
$.ajax({
type: method,
url: url,
data: data,
success: function(response){
$("#add-description").remove();
}
});
});
});//end document ready
= render 'shared/author_info', :post => @photo
%ul#breadcrumb %ul#breadcrumb
%li= link_to "#{@album.person.profile.first_name}'s Photos", '#' %li= link_to "#{@album.person.profile.first_name}'s Photos", person_photos_path(@photo.person)
%li= link_to @album.name, album_path(@album) %li= link_to @album.name, album_path(@album)
%li= @photo.caption %li= @photo.caption
= link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch' = link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch', :id => "prev_photo"
| |
= link_to "#{t('.full_size')}", @photo.url = link_to "#{t('.full_size')}", @photo.url
| |
= link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch' = link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch', :id => "next_photo"
.span-14.append-1.last .span-14.append-1.last
%div{:data=>{:guid=>@photo.id}} %div{:data=>{:guid=>@photo.id}}
#show_photo #show_photo
-if current_user.owns? @photo -if @ownership
.edit_pane .edit_pane
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}} .controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
= link_to 'make profile photo', '#', :class => "make_profile_photo" = link_to 'make profile photo', '#', :class => "make_profile_photo"
= linked_scaled_photo @photo, @album = linked_scaled_photo @photo, @album
-else -else
= linked_scaled_photo @photo, @album = linked_scaled_photo @photo, @album
.caption .caption
-if current_user.owns? @photo -if @ownership
-if @photo.caption and @photo.caption != "" -if @photo.caption and @photo.caption != ""
= link_to 'Edit','javascript:void(0)', :id => "edit-desc", :class => "edit-desc" = link_to 'Edit','javascript:void(0)', :id => "edit-desc", :class => "edit-desc"
.description .description
= @photo.caption = @photo.caption
-if current_user.owns? @photo -if @ownership
%div{:class => 'clear'} %div{:class => 'clear'}
-if !@photo.caption or @photo.caption == "" -if !@photo.caption or @photo.caption == ""
= link_to 'Add a description','javascript:void(0)', :id => "add-description", :class => "edit-desc" = link_to 'Add a description','javascript:void(0)', :id => "add-description", :class => "edit-desc"
%br %br
%br %br
@ -98,7 +51,7 @@
= p.submit = p.submit
%div{:class => 'clear'} %div{:class => 'clear'}
-if current_user.owns? @album -if @ownership
= link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button' = link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button'
.span-9.last .span-9.last

View file

@ -1,15 +1,16 @@
#author_info #author_info
= owner_image_link = person_image_link(person)
.from .from
%h2 %h2
= post.person.real_name = person.real_name
.aspect - if defined?(post)
.aspect
%ul
- if post.public? %ul
the world - if post.public?
- else the world
- for aspect in current_user.aspects_with_post( post.id ) - else
%li= link_to aspect.name, aspect - for aspect in current_user.aspects_with_post( post.id )
%li= link_to aspect.name, aspect
= link_to "view profile", person_path(post.person) = link_to "view profile", person_path(person)

View file

@ -3,7 +3,7 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
= render 'shared/author_info', :post => @status_message = render 'shared/author_info', :person => @status_message.person, :post => @status_message
.span-14.append-1.last .span-14.append-1.last
%h1.show_text %h1.show_text

View file

@ -7,7 +7,7 @@ Diaspora::Application.routes.draw do
resources :status_messages, :only => [:create, :destroy, :show] resources :status_messages, :only => [:create, :destroy, :show]
resources :comments, :except => [:index] resources :comments, :except => [:index]
resources :requests, :except => [:edit, :update] resources :requests, :except => [:edit, :update]
resources :photos, :except => [:index] resources :photos
resources :albums resources :albums
resources :services resources :services

View file

@ -0,0 +1,57 @@
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
$(document).keydown(function(e){
switch(e.keyCode) {
case 37:
if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus
window.location = $("#prev_photo").attr('href');
}
break;
case 39:
if(!$("textarea").hasClass("hasfocus")){
window.location = $("#next_photo").attr('href');
}
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();
});
//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());
$(".edit_photo").toggle();
$.ajax({
type: method,
url: url,
data: data,
success: function(response){
$("#add-description").remove();
}
});
});
});

View file

@ -723,6 +723,8 @@ label
/* cycle it! */ /* cycle it! */
.album .album
:margin
:right 3px
:position relative :position relative
:height 200px :height 200px
:width 200px :width 200px