Fix various links in to cubbi.es objects
This commit is contained in:
parent
69e83bb065
commit
d7899d10e3
6 changed files with 33 additions and 16 deletions
|
|
@ -4,10 +4,11 @@
|
||||||
|
|
||||||
class ActivityStreams::PhotosController < ApplicationController
|
class ActivityStreams::PhotosController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :redirect_unless_admin
|
before_filter :redirect_unless_admin, :only => :create
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_filter :verify_authenticity_token, :only => :create
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
respond_to :html, :only => [:show, :destroy]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@photo = ActivityStreams::Photo.from_activity(params[:activity])
|
@photo = ActivityStreams::Photo.from_activity(params[:activity])
|
||||||
|
|
@ -23,4 +24,17 @@ class ActivityStreams::PhotosController < ApplicationController
|
||||||
render :nothing => true, :status => 201
|
render :nothing => true, :status => 201
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,14 @@ module ApplicationHelper
|
||||||
|
|
||||||
def object_path(object, opts={})
|
def object_path(object, opts={})
|
||||||
return "" if object.nil?
|
return "" if object.nil?
|
||||||
object = object.person if object.is_a? User
|
object = object.person if object.instance_of? User
|
||||||
eval("#{object.class.name.underscore}_path(object, opts)")
|
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
|
end
|
||||||
|
|
||||||
def object_fields(object)
|
def object_fields(object)
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,4 @@ module StreamHelper
|
||||||
post.created_at
|
post.created_at
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
= aspect_badges(aspects_with_post(all_aspects, post), :link => true)
|
= aspect_badges(aspects_with_post(all_aspects, post), :link => true)
|
||||||
|
|
||||||
%span.timeago
|
%span.timeago
|
||||||
= show_link_for post
|
= link_to(how_long_ago(post), object_path(post))
|
||||||
|
|
||||||
%span.via
|
%span.via
|
||||||
- if post.activity_streams?
|
- if post.activity_streams?
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,9 @@
|
||||||
.info
|
.info
|
||||||
%span.time{:integer => post.created_at.to_i}
|
%span.time{:integer => post.created_at.to_i}
|
||||||
= t('ago', :time => time_ago_in_words(post.created_at))
|
= t('ago', :time => time_ago_in_words(post.created_at))
|
||||||
= link_to "#{t('comments', :count => post.comments.length)} →", status_message_path(post), :class => 'comment_link right'
|
|
||||||
|
- 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'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ Diaspora::Application.routes.draw do
|
||||||
# generating a new user token (for devise)
|
# generating a new user token (for devise)
|
||||||
|
|
||||||
# ActivityStreams routes
|
# ActivityStreams routes
|
||||||
scope "/activity_streams", :module => "activity_streams" do
|
scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
|
||||||
resources :photos, :controller => "photos", :only => :create, :as => "as_photos"
|
resources :photos, :controller => "photos", :only => [:create, :show, :destroy]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue