Fix various links in to cubbi.es objects

This commit is contained in:
danielgrippi 2011-05-19 15:17:16 -07:00
parent 69e83bb065
commit d7899d10e3
6 changed files with 33 additions and 16 deletions

View file

@ -4,10 +4,11 @@
class ActivityStreams::PhotosController < ApplicationController
before_filter :authenticate_user!
before_filter :redirect_unless_admin
skip_before_filter :verify_authenticity_token
before_filter :redirect_unless_admin, :only => :create
skip_before_filter :verify_authenticity_token, :only => :create
respond_to :json
respond_to :html, :only => [:show, :destroy]
def create
@photo = ActivityStreams::Photo.from_activity(params[:activity])
@ -23,4 +24,17 @@ class ActivityStreams::PhotosController < ApplicationController
render :nothing => true, :status => 201
end
end
def show
@photo = current_user.find_visible_post_by_id(params[:id])
respond_with @photo
end
def destroy
@photo = current_user.posts.where(:id => params[:id]).first
if @photo
current_user.retract(@photo)
end
respond_with @photo
end
end

View file

@ -18,9 +18,15 @@ module ApplicationHelper
def object_path(object, opts={})
return "" if object.nil?
object = object.person if object.is_a? User
object = object.person if object.instance_of? User
object = object.model if object.instance_of? PostsFake::Fake
if object.activity_streams?
class_name = object.class.name.underscore.split('/')
eval("#{class_name.first}_#{class_name.last}_path(object, opts)")
else
eval("#{object.class.name.underscore}_path(object, opts)")
end
end
def object_fields(object)
object.attributes.keys

View file

@ -20,12 +20,4 @@ module StreamHelper
post.created_at
end
end
def show_link_for post
if post.activity_streams?
how_long_ago(post)
else
link_to(how_long_ago(post), status_message_path(post))
end
end
end

View file

@ -38,7 +38,7 @@
= aspect_badges(aspects_with_post(all_aspects, post), :link => true)
%span.timeago
= show_link_for post
= link_to(how_long_ago(post), object_path(post))
%span.via
- if post.activity_streams?

View file

@ -17,4 +17,9 @@
.info
%span.time{:integer => post.created_at.to_i}
= t('ago', :time => time_ago_in_words(post.created_at))
- if post.activity_streams?
= link_to "#{t('comments', :count => post.comments.length)} →", activity_streams_photo_path(post), :class => 'comment_link right'
- else
= link_to "#{t('comments', :count => post.comments.length)} →", status_message_path(post), :class => 'comment_link right'

View file

@ -63,8 +63,8 @@ Diaspora::Application.routes.draw do
# generating a new user token (for devise)
# ActivityStreams routes
scope "/activity_streams", :module => "activity_streams" do
resources :photos, :controller => "photos", :only => :create, :as => "as_photos"
scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
resources :photos, :controller => "photos", :only => [:create, :show, :destroy]
end