From 069b372c19a49d1c143b67171cb38af7af38906e Mon Sep 17 00:00:00 2001
From: danielvincent <danielgrippi@gmail.com>
Date: Sun, 21 Nov 2010 16:08:39 -0800
Subject: [PATCH] photo show links to original post and siblings.  status
 message shows all photos associated with it.  youtube player makes http/s
 call instead of just http.

---
 app/controllers/photos_controller.rb     |  5 ++--
 app/views/photos/show.html.haml          | 14 +++++++++++
 app/views/status_messages/show.html.haml |  8 ++++--
 public/javascripts/view.js               |  2 +-
 public/stylesheets/sass/application.sass | 32 +++++++++++++++++++-----
 5 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 492a673c65..03f6d08708 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -11,7 +11,7 @@ class PhotosController < ApplicationController
   def index
     @aspect = :profile
     @post_type = :photos
-    @person = Person.find(params[:person_id].to_id)
+    @person = Person.find_by_id(params[:person_id])
 
     if @person
       @profile = @person.profile
@@ -24,7 +24,8 @@ class PhotosController < ApplicationController
         @pending_request = current_user.pending_requests.find_by_person_id(@person.id)
       end
 
-      @posts = current_user.visible_posts(:_type => 'Photo', :person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
+      @posts = current_user.raw_visible_posts.all(:_type => 'Photo', :person_id => @person.id, :order => 'created_at DESC').paginate :page => params[:page], :order => 'created_at DESC'
+
       render 'people/show'
 
     else
diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml
index c7705fecc1..cfc70a5c97 100644
--- a/app/views/photos/show.html.haml
+++ b/app/views/photos/show.html.haml
@@ -56,6 +56,20 @@
     = link_to t('.delete_photo'), @photo, :confirm => t('are_you_sure'), :method => :delete, :class => 'button'
 
 .span-9.last
+
+  - if @photo.status_message_id
+    #original_post_info
+      %h4{:style=>"margin-bottom:5px;position:relative;"}
+        Original Post
+        =link_to 'view', @photo.status_message
+
+      %p
+        = @photo.status_message.message
+
+      - for photo in @photo.status_message.photos
+        = link_to (image_tag photo.url(:thumb_small)), object_path(photo)
+    %br
+
   %h4{:style=>"margin-bottom:5px;"} Comments
   %div{id => 'photo_stream', :class => 'stream show'}
     %li.message{:data=>{:guid=>@photo.id}}
diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml
index b7a0ce1fc9..3ffde4d075 100644
--- a/app/views/status_messages/show.html.haml
+++ b/app/views/status_messages/show.html.haml
@@ -9,8 +9,12 @@
   #show_text
     %p
       = markdownify(@status_message.message)
-    .time
-      = how_long_ago(@status_message)
+
+    - for photo in @status_message.photos
+      = link_to (image_tag photo.url(:thumb_small)), object_path(photo)
+
+  .time
+    = how_long_ago(@status_message)
   - if current_user.owns? @status_message
     = link_to t('.destroy'), @status_message, :confirm => t('are_you_sure'), :method => :delete
 
diff --git a/public/javascripts/view.js b/public/javascripts/view.js
index 8125df392a..b11da0a457 100644
--- a/public/javascripts/view.js
+++ b/public/javascripts/view.js
@@ -124,7 +124,7 @@ function openVideo(type, videoid, link) {
   var container = document.createElement('div'),
       $container = $(container);
   if(type == 'youtube.com') {
-    $container.html('<a href="http://www.youtube.com/watch?v='+videoid+'" target="_blank">Watch this video on Youtube</a><br><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+videoid+'?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+videoid+'?fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>');
+    $container.html('<a href="//www.youtube.com/watch?v='+videoid+'" target="_blank">Watch this video on Youtube</a><br><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+videoid+'?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+videoid+'?fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>');
   } else {
     $container.html('Invalid videotype <i>'+type+'</i> (ID: '+videoid+')');
   }
diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
index 1fd711c7f0..d503f8e08f 100644
--- a/public/stylesheets/sass/application.sass
+++ b/public/stylesheets/sass/application.sass
@@ -240,12 +240,6 @@ header
     :-moz-border-radius 5px
     :border-radius 5px
 
-  .stream_photo
-    img
-      :height 200px
-      :width 200px
-
-
 .from
   :font
     :family 'Helvetica neue', Arial, Helvetica, sans-serif
@@ -1329,6 +1323,14 @@ input[type="search"]
       :size 18px
       :weight bold
 
+  img
+    :-webkit-box-shadow 0 1px 2px #666
+    :-moz-box-shadow 0 1px 2px #666
+
+    :-webkit-border-radius 5px
+    :-moz-border-radius 5px
+    :border-radius 5px
+
 
 .edit_pane
   :display inline
@@ -1912,3 +1914,21 @@ h3,h4
   input
     :width 100%
 
+#original_post_info
+  p
+    :color #999
+
+  h4
+    a
+      :font
+        :size 12px
+
+
+  img
+    :-webkit-box-shadow 0 1px 2px #666
+    :-moz-box-shadow 0 1px 2px #666
+
+    :-webkit-border-radius 5px
+    :-moz-border-radius 5px
+    :border-radius 5px
+
-- 
GitLab