Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Sofaer <raphael@joindiaspora.com>2011-07-11 03:51:29 +0400
committerRaphael Sofaer <raphael@joindiaspora.com>2011-07-11 07:06:31 +0400
commit97ca10dddaac9b956b7b6d8ff99dc7148c6ca40d (patch)
tree695133775f0c9625b980dea79f0a1fb0922e7bdb
parent6a165c0e3d414d39469bef2a80ab7b77bf3b2256 (diff)
Huge commit I know, but move show and destroy routes into PostsController and PostsController#show into PublicsController
-rw-r--r--app/controllers/activity_streams/photos_controller.rb10
-rw-r--r--app/controllers/comments_controller.rb1
-rw-r--r--app/controllers/likes_controller.rb2
-rw-r--r--app/controllers/posts_controller.rb49
-rw-r--r--app/controllers/publics_controller.rb25
-rw-r--r--app/controllers/status_messages_controller.rb16
-rw-r--r--app/helpers/application_helper.rb15
-rw-r--r--app/helpers/notifications_helper.rb8
-rw-r--r--app/views/activity_streams/photos/show.mobile.haml21
-rw-r--r--app/views/apps/show.html.haml2
-rw-r--r--app/views/notifier/also_commented.html.haml4
-rw-r--r--app/views/notifier/comment_on_post.html.haml4
-rw-r--r--app/views/notifier/comment_on_post.text.haml2
-rw-r--r--app/views/notifier/liked.html.haml2
-rw-r--r--app/views/notifier/mentioned.html.haml4
-rw-r--r--app/views/photos/_photo.haml2
-rw-r--r--app/views/photos/show.html.haml4
-rw-r--r--app/views/posts/destroy.js.erb (renamed from app/views/status_messages/destroy.js.erb)2
-rw-r--r--app/views/posts/show.html.haml (renamed from app/views/activity_streams/photos/show.html.haml)4
-rw-r--r--app/views/posts/show.mobile.haml28
-rw-r--r--app/views/publics/photo.html.haml (renamed from app/views/posts/photo.html.haml)6
-rw-r--r--app/views/publics/status_message.haml (renamed from app/views/posts/status_message.haml)4
-rw-r--r--app/views/shared/_stream_element.html.haml4
-rw-r--r--app/views/shared/_stream_element.mobile.haml4
-rw-r--r--app/views/status_messages/show.html.haml11
-rw-r--r--app/views/status_messages/show.mobile.haml25
-rw-r--r--config/locales/diaspora/en.yml10
-rw-r--r--config/routes.rb23
-rw-r--r--features/comments.feature1
-rw-r--r--spec/controllers/activity_streams/photos_controller_spec.rb10
-rw-r--r--spec/controllers/posts_controller_spec.rb74
-rw-r--r--spec/controllers/publics_controller_spec.rb22
-rw-r--r--spec/controllers/status_messages_controller_spec.rb58
-rw-r--r--spec/helpers/notifications_helper_spec.rb6
-rw-r--r--spec/lib/fake_spec.rb2
-rw-r--r--spec/support/i18n_raise_errors.rb2
36 files changed, 211 insertions, 256 deletions
diff --git a/app/controllers/activity_streams/photos_controller.rb b/app/controllers/activity_streams/photos_controller.rb
index e4fdf8327..158125884 100644
--- a/app/controllers/activity_streams/photos_controller.rb
+++ b/app/controllers/activity_streams/photos_controller.rb
@@ -28,7 +28,7 @@ class ActivityStreams::PhotosController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => :create
respond_to :json
- respond_to :html, :only => [:show, :destroy]
+ respond_to :html, :only => [:show]
def create
@photo = ActivityStreams::Photo.from_activity(params[:activity])
@@ -52,14 +52,6 @@ class ActivityStreams::PhotosController < ApplicationController
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
-
def fail!
render :nothing => true, :status => 401
end
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 8953d40b9..d472e457f 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -7,7 +7,6 @@ class CommentsController < ApplicationController
before_filter :authenticate_user!
respond_to :html, :mobile
- respond_to :json, :only => :show
rescue_from ActiveRecord::RecordNotFound do
render :nothing => true, :status => 404
diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb
index 696a0ba3c..4b5d2039c 100644
--- a/app/controllers/likes_controller.rb
+++ b/app/controllers/likes_controller.rb
@@ -21,7 +21,7 @@ class LikesController < ApplicationController
respond_to do |format|
format.js { render :status => 201 }
format.html { render :nothing => true, :status => 201 }
- format.mobile { redirect_to status_message_path(@like.post_id) }
+ format.mobile { redirect_to post_path(@like.post_id) }
end
else
render :nothing => true, :status => 422
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index ff797a907..a65f4eee9 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -3,32 +3,39 @@
# the COPYRIGHT file.
class PostsController < ApplicationController
- skip_before_filter :set_invites
- skip_before_filter :which_action_and_user
- skip_before_filter :set_grammatical_gender
-
+ before_filter :authenticate_user!
+ respond_to :html
+ respond_to :mobile
+ respond_to :json
def show
- @post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
-
- #hax to upgrade logged in users who can comment
+ @post = current_user.find_visible_post_by_id params[:id]
if @post
- if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
- redirect_to "/#{@post.class.to_s.pluralize.underscore}/#{@post.id}"
- return
- end
- @landing_page = true
- @person = @post.author
- if @person.owner_id
- I18n.locale = @person.owner.language
- render "posts/#{@post.class.to_s.underscore}", :layout => true
- else
- flash[:error] = I18n.t('posts.doesnt_exist')
- redirect_to root_url
+ # mark corresponding notification as read
+ if notification = Notification.where(:recipient_id => current_user.id, :target_id => @post.id).first
+ notification.unread = false
+ notification.save
+ end
+
+ respond_with @post
+ else
+ Rails.logger.info(:event => :link_to_nonexistent_post, :ref => request.env['HTTP_REFERER'], :user_id => current_user.id, :post_id => params[:id])
+ flash[:error] = I18n.t('posts.show.not_found')
+ redirect_to :back
+ end
+ end
+
+ def destroy
+ @post = current_user.posts.where(:id => params[:id]).first
+ if @post
+ current_user.retract(@post)
+ respond_to do |format|
+ format.js {render 'destroy'}
+ format.all {redirect_to root_url}
end
else
- flash[:error] = I18n.t('posts.doesnt_exist')
- redirect_to root_url
+ Rails.logger.info "event=post_destroy status=failure user=#{current_user.diaspora_handle} reason='User does not own post'"
+ render :nothing => true, :status => 404
end
end
end
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index 1c73ac0fb..dc1a338fb 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -64,4 +64,29 @@ class PublicsController < ApplicationController
render :nothing => true, :status => 202
end
+
+ def post
+ @post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
+
+ #hax to upgrade logged in users who can comment
+ if @post
+ if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
+ redirect_to post_path(@post)
+ return
+ end
+
+ @landing_page = true
+ @person = @post.author
+ if @person.owner_id
+ I18n.locale = @person.owner.language
+ render "#{@post.class.to_s.underscore}", :layout => 'application'
+ else
+ flash[:error] = I18n.t('posts.show.not_found')
+ redirect_to root_url
+ end
+ else
+ flash[:error] = I18n.t('posts.show.not_found')
+ redirect_to root_url
+ end
+ end
end
diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb
index df69ee00a..4eb40990a 100644
--- a/app/controllers/status_messages_controller.rb
+++ b/app/controllers/status_messages_controller.rb
@@ -7,8 +7,6 @@ class StatusMessagesController < ApplicationController
respond_to :html
respond_to :mobile
- respond_to :json, :only => :show
-
# Called when a user clicks "Mention" on a profile page
# @option [Integer] person_id The id of the person to be mentioned
@@ -91,20 +89,6 @@ class StatusMessagesController < ApplicationController
end
end
- def destroy
- @status_message = current_user.posts.where(:id => params[:id]).first
- if @status_message
- current_user.retract(@status_message)
- respond_to do |format|
- format.js {render 'destroy'}
- format.all {redirect_to root_url}
- end
- else
- Rails.logger.info "event=post_destroy status=failure user=#{current_user.diaspora_handle} reason='User does not own post'"
- render :nothing => true, :status => 404
- end
- end
-
def show
@status_message = current_user.find_visible_post_by_id params[:id]
if @status_message
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1a6454c5f..3d540704b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -16,19 +16,6 @@ module ApplicationHelper
"javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
end
- def object_path(object, opts={})
- return "" if object.nil?
- object = object.person if object.instance_of? User
- object = object.model if object.instance_of? PostsFake::Fake
- if object.respond_to?(:activity_streams?) && object.activity_streams?
- class_name = object.class.name.underscore.split('/')
- method_sym = "#{class_name.first}_#{class_name.last}_path".to_sym
- else
- method_sym = "#{object.class.name.underscore}_path".to_sym
- end
- self.send(method_sym, object, opts)
- end
-
def object_fields(object)
object.attributes.keys
end
@@ -109,7 +96,7 @@ module ApplicationHelper
@rtl ||= RTL_LANGUAGES.include? I18n.locale
end
- def controller_index_path
+ def controller_index_path
self.send((request.filtered_parameters["controller"] + "_path").to_sym)
end
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index e15a1d6fd..66c69d898 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -9,21 +9,21 @@ module NotificationsHelper
if note.instance_of?(Notifications::Mentioned)
post = Mention.find(note.target_id).post
if post
- translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post)).html_safe)
+ translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), post_path(post)).html_safe)
else
t('notifications.mentioned_deleted', :actors => actors, :count => actors_count).html_safe
end
elsif note.instance_of?(Notifications::CommentOnPost)
post = Post.where(:id => note.target_id).first
if post
- translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
+ translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe
end
elsif note.instance_of?(Notifications::AlsoCommented)
post = Post.where(:id => note.target_id).first
if post
- translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
+ translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe
end
@@ -31,7 +31,7 @@ module NotificationsHelper
post = note.target
post = post.post if post.is_a? Like
if post
- translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
+ translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
t('notifications.liked_post_deleted', :actors => actors, :count => actors_count).html_safe
end
diff --git a/app/views/activity_streams/photos/show.mobile.haml b/app/views/activity_streams/photos/show.mobile.haml
deleted file mode 100644
index 98389ab0a..000000000
--- a/app/views/activity_streams/photos/show.mobile.haml
+++ /dev/null
@@ -1,21 +0,0 @@
--# Copyright (c) 2010, Diaspora Inc. This file is
--# licensed under the Affero General Public License version 3 or later. See
--# the COPYRIGHT file.
-
-#show_content{:data=>{:guid=>@photo.id}}
- = render 'shared/author_info', :person => @photo.author, :post => @photo
-
- = image_tag @photo.image_url
-
- .info
- %span.time
- = t('ago', :time => time_ago_in_words(@photo.created_at))
-
- %br
- - if current_user.owns? @photo
- = link_to t('delete'), @photo, :confirm => t('are_you_sure'), :method => :delete
- - else
- = link_to t('hide'), post_visibility_path(:id => "42", :post_id => @photo.id), :confirm => t('are_you_sure'), :method => :put, :remote => true
-
-.stream.show{:data=>{:guid=>@photo.id}}
- = render "comments/comments", :post => @photo, :comments => @photo.comments, :always_expanded => true
diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml
index 6635d9323..63d6bd723 100644
--- a/app/views/apps/show.html.haml
+++ b/app/views/apps/show.html.haml
@@ -22,7 +22,7 @@
- for post in @posts
.image-element.stream_element
.hold-me
- = link_to(image_tag(post.image_url), object_path(post))
+ = link_to(image_tag(post.image_url), post_path(post))
.via
= post.author.name
.time{:integer => post.created_at.to_i}
diff --git a/app/views/notifier/also_commented.html.haml b/app/views/notifier/also_commented.html.haml
index 471120c64..c65f0bccf 100644
--- a/app/views/notifier/also_commented.html.haml
+++ b/app/views/notifier/also_commented.html.haml
@@ -9,9 +9,9 @@
%br
%br
- = link_to t('.sign_in'), status_message_url(@comment.post)
+ = link_to t('.sign_in'), post_url(@comment.post)
%br
- = t('notifier.love')
+ = t('notifier.love')
%br
= t('notifier.diaspora')
diff --git a/app/views/notifier/comment_on_post.html.haml b/app/views/notifier/comment_on_post.html.haml
index 7ae1aec79..47049b8bb 100644
--- a/app/views/notifier/comment_on_post.html.haml
+++ b/app/views/notifier/comment_on_post.html.haml
@@ -7,9 +7,9 @@
= @comment.text
%br
- = link_to t('.sign_in'), status_message_url(@comment.post)
+ = link_to t('.sign_in'), post_url(@comment.post)
%br
- = t('notifier.love')
+ = t('notifier.love')
%br
= t('notifier.diaspora')
diff --git a/app/views/notifier/comment_on_post.text.haml b/app/views/notifier/comment_on_post.text.haml
index d6d4bd14e..ccfedab8e 100644
--- a/app/views/notifier/comment_on_post.text.haml
+++ b/app/views/notifier/comment_on_post.text.haml
@@ -4,7 +4,7 @@
!= @comment.text
-!= status_message_url(@comment.post)
+!= post_url(@comment.post)
!= "#{t('notifier.love')} \n"
!= t('notifier.diaspora')
diff --git a/app/views/notifier/liked.html.haml b/app/views/notifier/liked.html.haml
index ca9300b72..ae853a4db 100644
--- a/app/views/notifier/liked.html.haml
+++ b/app/views/notifier/liked.html.haml
@@ -8,7 +8,7 @@
%p
%br
- = link_to t('.sign_in'), status_message_url(@like.post)
+ = link_to t('.sign_in'), post_url(@like.post)
%br
= t('notifier.love')
diff --git a/app/views/notifier/mentioned.html.haml b/app/views/notifier/mentioned.html.haml
index 22f895c17..6751e62fc 100644
--- a/app/views/notifier/mentioned.html.haml
+++ b/app/views/notifier/mentioned.html.haml
@@ -8,9 +8,9 @@
%p
%br
- = link_to t('.sign_in'), status_message_url(@post)
+ = link_to t('.sign_in'), post_url(@post)
%br
- = t('notifier.love')
+ = t('notifier.love')
%br
= t('notifier.diaspora')
diff --git a/app/views/photos/_photo.haml b/app/views/photos/_photo.haml
index 4322718ec..001e1f416 100644
--- a/app/views/photos/_photo.haml
+++ b/app/views/photos/_photo.haml
@@ -2,7 +2,7 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-= link_to (image_tag post.url(:thumb_large)), object_path(post), :class => 'stream_photo'
+= link_to (image_tag post.url(:thumb_large)), photo_path(post), :class => 'stream_photo'
%h1
= post.pending
diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml
index dfc4d5dba..d71b1f6bf 100644
--- a/app/views/photos/show.html.haml
+++ b/app/views/photos/show.html.haml
@@ -42,14 +42,14 @@
%p
= markdownify(photo.status_message.text)
%span{:style=>'font-size:smaller'}
- =link_to t('.collection_permalink'), photo.status_message
+ =link_to t('.collection_permalink'), post_path(photo.status_message)
%br
%br
.span-7.prepend-1
.show_photo_attachments
- for photo in additional_photos
- = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), object_path(photo)
+ = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo)
#photo_edit_options
diff --git a/app/views/status_messages/destroy.js.erb b/app/views/posts/destroy.js.erb
index d34c42e25..e873e96c7 100644
--- a/app/views/status_messages/destroy.js.erb
+++ b/app/views/posts/destroy.js.erb
@@ -1,2 +1,2 @@
-var target = $(".stream_element[data-guid=<%= escape_javascript(@status_message.id.to_s) %>]")
+var target = $(".stream_element[data-guid=<%= escape_javascript(@post.id.to_s) %>]")
target.hide('blind', { direction: 'vertical' }, 300, function(){ target.remove() });
diff --git a/app/views/activity_streams/photos/show.html.haml b/app/views/posts/show.html.haml
index ee6d6510e..52fab9ea3 100644
--- a/app/views/activity_streams/photos/show.html.haml
+++ b/app/views/posts/show.html.haml
@@ -2,9 +2,9 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-.span-16.append-4.prepend-4.last
+.span-20.append-2.prepend-2.last
#main_stream.stream.status_message_show
- = render 'shared/stream_element', :post => @photo, :all_aspects => @photo.aspects
+ = render 'shared/stream_element', :post => @post, :all_aspects => @post.aspects
%br
%br
%br
diff --git a/app/views/posts/show.mobile.haml b/app/views/posts/show.mobile.haml
new file mode 100644
index 000000000..a897760d2
--- /dev/null
+++ b/app/views/posts/show.mobile.haml
@@ -0,0 +1,28 @@
+-# Copyright (c) 2010, Diaspora Inc. This file is
+-# licensed under the Affero General Public License version 3 or later. See
+-# the COPYRIGHT file.
+
+#show_content{:data=>{:guid=>@post.id}}
+ = render 'shared/author_info', :person => @post.author, :post => @post
+
+ - if @post.activity_streams?
+ = image_tag @photo.image_url
+ - else
+ %p
+ = markdownify(@post.text, :youtube_maps => @post[:youtube_titles])
+
+ - for photo in @post.photos
+ = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo.url(:thumb_medium)
+
+ .info
+ %span.time
+ = t('ago', :time => time_ago_in_words(@post.created_at))
+
+ %br
+ - if current_user.owns? @post
+ = link_to t('delete'), @post, :confirm => t('are_you_sure'), :method => :delete
+ - else
+ = link_to t('hide'), post_visibility_path(:id => "42", :post_id => @post.id), :confirm => t('are_you_sure'), :method => :put, :remote => true
+
+.stream.show{:data=>{:guid=>@post.id}}
+ = render "comments/comments", :post => @post, :comments => @post.comments, :always_expanded => true
diff --git a/app/views/posts/photo.html.haml b/app/views/publics/photo.html.haml
index b520c09cf..b8e2f7123 100644
--- a/app/views/posts/photo.html.haml
+++ b/app/views/publics/photo.html.haml
@@ -24,13 +24,13 @@
#original_post_info
%h4{:style=>"position:relative;"}
= t('photos.show.original_post')
- = link_to t('photos.show.view'), post_path(@post.status_message)
+ = link_to t('photos.show.view'), public_post_path(@post.status_message)
%p
= @post.status_message.text
%p
- for photo in @post.status_message.photos
- .thumb_small= link_to (image_tag photo.url(:thumb_small)), post_path(photo)
+ .thumb_small= link_to (image_tag photo.url(:thumb_small)), public_post_path(photo)
%p
- = link_to t('photos.show.permalink'), post_path(@post)
+ = link_to t('posts.show.permalink'), public_post_path(@post)
diff --git a/app/views/posts/status_message.haml b/app/views/publics/status_message.haml
index 10df97c47..a12003d78 100644
--- a/app/views/posts/status_message.haml
+++ b/app/views/publics/status_message.haml
@@ -14,8 +14,8 @@
= markdownify(@post.text, :youtube_maps => @post[:youtube_titles])
- for photo in @post.photos
- .thumb_small= link_to (image_tag photo.url(:thumb_small)), post_path(photo)
+ .thumb_small= link_to (image_tag photo.url(:thumb_small)), public_post_path(photo)
.time
= how_long_ago(@post)
- = link_to t('status_messages.show.permalink'), post_path(@post)
+ = link_to t('posts.show.permalink'), public_post_path(@post)
diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml
index eba6733b7..faf31bcb2 100644
--- a/app/views/shared/_stream_element.html.haml
+++ b/app/views/shared/_stream_element.html.haml
@@ -5,7 +5,7 @@
.stream_element{:data=>{:guid=>post.id}}
- if current_user && post.author.owner_id == current_user.id
.right.controls
- = link_to image_tag('deletelabel.png'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
+ = link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
- else
.right.controls
= link_to image_tag('deletelabel.png'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete", :title => t('hide')
@@ -23,7 +23,7 @@
%span.details
%span.timeago
- = link_to(how_long_ago(post), object_path(post))
+ = link_to(how_long_ago(post), post_path(post))
- if post.activity_streams?
= link_to image_tag(post.image_url), post.object_url
diff --git a/app/views/shared/_stream_element.mobile.haml b/app/views/shared/_stream_element.mobile.haml
index beef700e7..1dedad9e6 100644
--- a/app/views/shared/_stream_element.mobile.haml
+++ b/app/views/shared/_stream_element.mobile.haml
@@ -21,9 +21,7 @@
- if post.activity_streams?
= t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe
+ = link_to "#{t('comments', :count => post.comments.length)} →", post_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'
%br
- - else
- = link_to "#{t('comments', :count => post.comments.length)} →", status_message_path(post), :class => 'comment_link right'
diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml
deleted file mode 100644
index defca25ad..000000000
--- a/app/views/status_messages/show.html.haml
+++ /dev/null
@@ -1,11 +0,0 @@
--# Copyright (c) 2010, Diaspora Inc. This file is
--# licensed under the Affero General Public License version 3 or later. See
--# the COPYRIGHT file.
-
-.span-20.append-2.prepend-2.last
- .stream_container
- #main_stream.stream.status_message_show
- = render 'shared/stream_element', :post => @status_message, :all_aspects => @status_message.aspects
- %br
- %br
- %br
diff --git a/app/views/status_messages/show.mobile.haml b/app/views/status_messages/show.mobile.haml
deleted file mode 100644
index 24d7b0537..000000000
--- a/app/views/status_messages/show.mobile.haml
+++ /dev/null
@@ -1,25 +0,0 @@
--# Copyright (c) 2010, Diaspora Inc. This file is
--# licensed under the Affero General Public License version 3 or later. See
--# the COPYRIGHT file.
-
-#show_content{:data=>{:guid=>@status_message.id}}
- = render 'shared/author_info', :person => @status_message.author, :post => @status_message
-
- %p
- = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
-
- - for photo in @status_message.photos
- = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo.url(:thumb_medium)
-
- .info
- %span.time
- = t('ago', :time => time_ago_in_words(@status_message.created_at))
-
- %br
- - if current_user.owns? @status_message
- = link_to t('delete'), @status_message, :confirm => t('are_you_sure'), :method => :delete
- - else
- = link_to t('hide'), post_visibility_path(:id => "42", :post_id => @status_message.id), :confirm => t('are_you_sure'), :method => :put, :remote => true
-
-.stream.show{:data=>{:guid=>@status_message.id}}
- = render "comments/comments", :post => @status_message, :comments => @status_message.comments, :always_expanded => true
diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
index 4bac06a5f..df8c90194 100644
--- a/config/locales/diaspora/en.yml
+++ b/config/locales/diaspora/en.yml
@@ -490,7 +490,6 @@ en:
view: "view"
edit: "edit"
edit_delete_photo: "Edit photo description / delete photo"
- permalink: "permalink"
collection_permalink: "collection permalink"
original_post: "Original Post"
edit:
@@ -519,7 +518,10 @@ en:
or_select_one: "or select one from your already existing"
posts:
- doesnt_exist: "that post does not exist!"
+ show:
+ destroy: "Delete"
+ permalink: "permalink"
+ not_found: "Sorry, we couldn't find that post."
post_visibilites:
update:
@@ -675,10 +677,6 @@ en:
mentioning: "Mentioning: %{person}"
create:
success: "Successfully mentioned: %{names}"
- show:
- destroy: "Delete"
- permalink: "permalink"
- not_found: "Sorry, we couldn't find that post."
helper:
no_message_to_display: "No message to display."
destroy:
diff --git a/config/routes.rb b/config/routes.rb
index 4cfdf5bcc..8d1705a01 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -11,19 +11,24 @@ Diaspora::Application.routes.draw do
put 'toggle_contact_visibility' => :toggle_contact_visibility
end
- resources :status_messages, :only => [:new, :create, :destroy, :show] do
+ resources :status_messages, :only => [:new, :create] do
resources :likes, :only => [:create, :destroy, :index]
end
+ resources :comments, :only => [:create, :destroy, :index]
+ resources :posts, :only => [:show, :destroy]
+
get 'bookmarklet' => 'status_messages#bookmarklet'
- get 'p/:id' => 'posts#show', :as => 'post'
+ get 'p/:id' => 'publics#post', :as => 'public_post'
resources :photos, :except => [:index] do
put 'make_profile_photo' => :make_profile_photo
end
- resources :comments, :only => [:create, :destroy]
-
+ # ActivityStreams routes
+ scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
+ resources :photos, :controller => "photos", :only => [:create]
+ end
resources :conversations do
resources :messages, :only => [:create, :show]
@@ -66,15 +71,7 @@ Diaspora::Application.routes.draw do
get 'invitations/resend/:id' => 'invitations#resend', :as => 'invitation_resend'
end
- # generating a new user token (for devise)
-
- # ActivityStreams routes
- scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
- resources :photos, :controller => "photos", :only => [:create, :show, :destroy]
- end
-
-
- #Temporary token_authenticable route
+ #Cubbies info page
resource :token, :only => :show
get 'login' => redirect('/users/sign_in')
diff --git a/features/comments.feature b/features/comments.feature
index 1f4f39780..3d1709a84 100644
--- a/features/comments.feature
+++ b/features/comments.feature
@@ -73,7 +73,6 @@ Feature: commenting
When I follow "less than a minute ago"
Then I should see "Look at this dog"
When I open the comment box
- And I focus the comment field
And I fill in "text" with "I think thats a cat"
And I press "Comment"
And I wait for the ajax to finish
diff --git a/spec/controllers/activity_streams/photos_controller_spec.rb b/spec/controllers/activity_streams/photos_controller_spec.rb
index d088c5b9c..cb33880c9 100644
--- a/spec/controllers/activity_streams/photos_controller_spec.rb
+++ b/spec/controllers/activity_streams/photos_controller_spec.rb
@@ -1,15 +1,5 @@
require 'spec_helper'
describe ActivityStreams::PhotosController do
- describe '#show' do
- before do
- @photo = Factory(:activity_streams_photo, :author => bob.person)
- sign_in :user, alice
- end
- it 'succeeds' do
- get :show, :id => @photo.id
- response.should be_success
- end
- end
end
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index 951fd7b0b..25c12b90a 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -6,28 +6,72 @@ require 'spec_helper'
describe PostsController do
before do
- alice
- end
+ sign_in alice
+ aspect = alice.aspects.first
+ @message = alice.build_post :status_message, :text => "ohai", :to => aspect.id
+ @message.save!
+ alice.add_to_streams(@message, [aspect])
+ alice.dispatch_post @message, :to => aspect.id
+ end
describe '#show' do
- it 'shows a public post' do
- status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
- get :show, :id => status.id
- response.status= 200
+
+ it 'succeeds' do
+ get :show, "id" => @message.id.to_s
+ response.should be_success
+ end
+
+ it 'marks a corresponding notification as read' do
+ alice.comment("comment after me", :post => @message)
+ bob.comment("here you go", :post => @message)
+ note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
+ lambda{
+ get :show, :id => @message.id
+ note.reload
+ }.should change(note, :unread).from(true).to(false)
+ end
+
+ it 'redirects to back if there is no status message' do
+ get :show, :id => 2345
+ response.status.should == 302
+ end
+
+ it 'succeeds with a AS/photo' do
+ photo = Factory(:activity_streams_photo, :author => bob.person)
+ get :show, :id => photo.id
+ response.should be_success
+ end
+ end
+ describe '#destroy' do
+
+ it 'let a user delete his message' do
+ message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
+ delete :destroy, :format => :js, :id => message.id
+ response.should be_success
+ StatusMessage.find_by_id(message.id).should be_nil
+ end
+
+ it 'sends a retraction on delete' do
+ controller.stub!(:current_user).and_return alice
+ message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
+ alice.should_receive(:retract).with(message)
+ delete :destroy, :format => :js, :id => message.id
+ response.should be_success
end
- it 'does not show a private post' do
- status = alice.post(:status_message, :text => "hello", :public => false, :to => 'all')
- get :show, :id => status.id
- response.status = 302
+ it 'will not let you destroy posts visible to you' do
+ message = bob.post(:status_message, :text => "hey", :to => bob.aspects.first.id)
+ delete :destroy, :format => :js, :id => message.id
+ response.should_not be_success
+ StatusMessage.exists?(message.id).should be_true
end
- it 'redirects to the proper show page if the user has visibility of the post' do
- status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
- sign_in bob
- get :show, :id => status.id
- response.should be_redirect
+ it 'will not let you destory posts you do not own' do
+ message = eve.post(:status_message, :text => "hey", :to => eve.aspects.first.id)
+ delete :destroy, :format => :js, :id => message.id
+ response.should_not be_success
+ StatusMessage.exists?(message.id).should be_true
end
end
end
diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb
index 8783c0fad..0e4b6d465 100644
--- a/spec/controllers/publics_controller_spec.rb
+++ b/spec/controllers/publics_controller_spec.rb
@@ -61,6 +61,28 @@ describe PublicsController do
end
end
+ describe '#post' do
+ it 'shows a public post' do
+ status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
+
+ get :post, :id => status.id
+ response.status= 200
+ end
+
+ it 'does not show a private post' do
+ status = alice.post(:status_message, :text => "hello", :public => false, :to => 'all')
+ get :post, :id => status.id
+ response.status = 302
+ end
+
+ it 'redirects to the proper show page if the user has visibility of the post' do
+ status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
+ sign_in bob
+ get :post, :id => status.id
+ response.should be_redirect
+ end
+ end
+
describe '#hcard' do
it "succeeds", :fixture => true do
post :hcard, "guid" => @user.person.guid.to_s
diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb
index 5ccb76abd..ce6fa6485 100644
--- a/spec/controllers/status_messages_controller_spec.rb
+++ b/spec/controllers/status_messages_controller_spec.rb
@@ -39,36 +39,6 @@ describe StatusMessagesController do
end
end
- describe '#show' do
- before do
- @message = alice.build_post :status_message, :text => "ohai", :to => @aspect1.id
- @message.save!
-
- alice.add_to_streams(@message, [@aspect1])
- alice.dispatch_post @message, :to => @aspect1.id
- end
-
- it 'succeeds' do
- get :show, "id" => @message.id.to_s
- response.should be_success
- end
-
- it 'marks a corresponding notification as read' do
- alice.comment("comment after me", :post => @message)
- bob.comment("here you go", :post => @message)
- note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
- lambda{
- get :show, :id => @message.id
- note.reload
- }.should change(note, :unread).from(true).to(false)
- end
-
- it 'redirects to back if there is no status message' do
- get :show, :id => 2345
- response.status.should == 302
- end
- end
-
describe '#create' do
let(:status_message_hash) {
{ :status_message => {
@@ -164,32 +134,4 @@ describe StatusMessagesController do
end
end
end
-
- describe '#destroy' do
- before do
- @message = alice.post(:status_message, :text => "hey", :to => @aspect1.id)
- @message2 = bob.post(:status_message, :text => "hey", :to => @aspect2.id)
- @message3 = eve.post(:status_message, :text => "hey", :to => eve.aspects.first.id)
- end
-
- it 'let a user delete his message' do
- delete :destroy, :format => :js, :id => @message.id
- StatusMessage.find_by_id(@message.id).should be_nil
- end
-
- it 'sends a retraction on delete' do
- alice.should_receive(:retract).with(@message)
- delete :destroy, :format => :js, :id => @message.id
- end
-
- it 'will not let you destroy posts visible to you' do
- delete :destroy, :format => :js, :id => @message2.id
- StatusMessage.find_by_id(@message2.id).should be_true
- end
-
- it 'will not let you destory posts you do not own' do
- delete :destroy, :format => :js, :id => @message3.id
- StatusMessage.find_by_id(@message3.id).should be_true
- end
- end
end
diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb
index 646384aae..3e4d599a2 100644
--- a/spec/helpers/notifications_helper_spec.rb
+++ b/spec/helpers/notifications_helper_spec.rb
@@ -10,7 +10,7 @@ describe NotificationsHelper do
@person2 = Factory(:person)
@notification = Notification.notify(@user, Factory(:like, :author => @person, :post => @post), @person)
@notification = Notification.notify(@user, Factory(:like, :author => @person2, :post => @post), @person2)
-
+
end
describe '#notification_people_link' do
context 'formatting' do
@@ -68,14 +68,14 @@ describe NotificationsHelper do
describe 'for a like' do
it 'should include a link to the post' do
output = object_link(@notification, notification_people_link(@notification))
- output.should include status_message_path(@post)
+ output.should include post_path(@post)
end
it 'includes the boilerplate translation' do
output = object_link(@notification, notification_people_link(@notification))
output.should include t("#{@notification.popup_translation_key}.one",
:actors => notification_people_link(@notification),
- :post_link => "<a href=\"#{status_message_path(@post)}\" class=\"hard_object_link\" data-ref=\"#{@post.id}\">#{t('notifications.post')}</a>")
+ :post_link => "<a href=\"#{post_path(@post)}\" class=\"hard_object_link\" data-ref=\"#{@post.id}\">#{t('notifications.post')}</a>")
end
context 'when post is deleted' do
diff --git a/spec/lib/fake_spec.rb b/spec/lib/fake_spec.rb
index 7e6cb5aea..f43302381 100644
--- a/spec/lib/fake_spec.rb
+++ b/spec/lib/fake_spec.rb
@@ -55,7 +55,7 @@ describe PostsFake do
sm = Factory(:status_message)
fake = PostsFake::Fake.new(sm, @fakes)
- status_message_path(fake).should == status_message_path(sm)
+ post_path(fake).should == post_path(sm)
end
end
end
diff --git a/spec/support/i18n_raise_errors.rb b/spec/support/i18n_raise_errors.rb
index 0564e2743..414867feb 100644
--- a/spec/support/i18n_raise_errors.rb
+++ b/spec/support/i18n_raise_errors.rb
@@ -1,6 +1,6 @@
module I18n
def self.just_raise_that_exception(*args)
- raise args.first
+ raise "Translation not found: #{args.first.key}"
end
end