a person now has a photos#index page.
This commit is contained in:
parent
aaff5083f0
commit
2b4e3e3a41
11 changed files with 140 additions and 80 deletions
|
|
@ -8,6 +8,16 @@ class PhotosController < ApplicationController
|
|||
respond_to :html
|
||||
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
|
||||
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
|
||||
else
|
||||
@album = @photo.album
|
||||
@ownership = current_user.owns? @photo
|
||||
|
||||
respond_with @photo, @album
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -78,4 +78,11 @@ module ApplicationHelper
|
|||
def post_yield_tag(post)
|
||||
(':' + post.id.to_s).to_sym
|
||||
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
|
||||
|
|
|
|||
|
|
@ -2,12 +2,6 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
- content_for :head do
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
$("#add_album_button").fancybox();
|
||||
});
|
||||
|
||||
.span-4.append-1.last
|
||||
= render "shared/aspect_friends"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
});
|
||||
|
||||
|
||||
= render 'shared/author_info', :post => @album
|
||||
= render 'shared/author_info', :person => @album.person, :post => @album
|
||||
|
||||
%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
|
||||
|
||||
|
||||
|
|
|
|||
34
app/views/photos/index.html.haml
Normal file
34
app/views/photos/index.html.haml
Normal 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
|
||||
|
||||
|
|
@ -3,93 +3,46 @@
|
|||
-# the COPYRIGHT file.
|
||||
|
||||
- content_for :head do
|
||||
:javascript
|
||||
$(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;
|
||||
}
|
||||
});
|
||||
=javascript_include_tag 'photo'
|
||||
|
||||
|
||||
$(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();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});//end document ready
|
||||
|
||||
= render 'shared/author_info', :post => @photo
|
||||
= render 'shared/author_info', :person => @photo.person, :post => @photo
|
||||
|
||||
%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= @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('.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
|
||||
%div{:data=>{:guid=>@photo.id}}
|
||||
#show_photo
|
||||
|
||||
-if current_user.owns? @photo
|
||||
-if @ownership
|
||||
.edit_pane
|
||||
.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"
|
||||
= linked_scaled_photo @photo, @album
|
||||
-else
|
||||
= linked_scaled_photo @photo, @album
|
||||
|
||||
.caption
|
||||
-if current_user.owns? @photo
|
||||
-if @ownership
|
||||
-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? @photo
|
||||
-if @ownership
|
||||
%div{:class => 'clear'}
|
||||
-if !@photo.caption or @photo.caption == ""
|
||||
= link_to 'Add a description','javascript:void(0)', :id => "add-description", :class => "edit-desc"
|
||||
|
||||
%br
|
||||
%br
|
||||
|
||||
|
|
@ -98,7 +51,7 @@
|
|||
= p.submit
|
||||
%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'
|
||||
|
||||
.span-9.last
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
#author_info
|
||||
= owner_image_link
|
||||
= person_image_link(person)
|
||||
.from
|
||||
%h2
|
||||
= post.person.real_name
|
||||
.aspect
|
||||
➔
|
||||
%ul
|
||||
- if post.public?
|
||||
the world
|
||||
- else
|
||||
- for aspect in current_user.aspects_with_post( post.id )
|
||||
%li= link_to aspect.name, aspect
|
||||
= person.real_name
|
||||
- if defined?(post)
|
||||
.aspect
|
||||
➔
|
||||
%ul
|
||||
- if post.public?
|
||||
the world
|
||||
- else
|
||||
- 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)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-# 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
|
||||
%h1.show_text
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Diaspora::Application.routes.draw do
|
|||
resources :status_messages, :only => [:create, :destroy, :show]
|
||||
resources :comments, :except => [:index]
|
||||
resources :requests, :except => [:edit, :update]
|
||||
resources :photos, :except => [:index]
|
||||
resources :photos
|
||||
resources :albums
|
||||
resources :services
|
||||
|
||||
|
|
|
|||
57
public/javascripts/photo.js
Normal file
57
public/javascripts/photo.js
Normal 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();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -723,6 +723,8 @@ label
|
|||
|
||||
/* cycle it! */
|
||||
.album
|
||||
:margin
|
||||
:right 3px
|
||||
:position relative
|
||||
:height 200px
|
||||
:width 200px
|
||||
|
|
|
|||
Loading…
Reference in a new issue